Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliJ and Android Studio don't show custom lints #307

Closed
MartinAKovachev opened this issue Jan 22, 2025 · 13 comments · Fixed by #304 · May be fixed by #309
Closed

IntelliJ and Android Studio don't show custom lints #307

MartinAKovachev opened this issue Jan 22, 2025 · 13 comments · Fixed by #304 · May be fixed by #309
Assignees
Labels
bug Something isn't working

Comments

@MartinAKovachev
Copy link

MartinAKovachev commented Jan 22, 2025

Describe the bug
When importing a - custom_lint in the analysis_options.yaml file, IntelliJ doesn't show any INFO, WARNING or ERROR message from custom_lint in Dart Analysis tab nor in the file, in which the issue occurs.

After running dart run custom_lint it shows the ERROR in the terminal, but it's really hard to spot an issue during development.

!The same project is being opened in Visual Studio Code and it shows the ERROR in the file. !

include: package:flutter_lints/flutter.yaml

analyzer:
  plugins:
    - custom_lint

custom_lint:
  rules:
    - layer_dependency_rule: true

linter:
  rules:
    avoid_print: true
    prefer_single_quotes: true
    always_use_package_imports: true
    annotate_overrides: true
    use_super_parameters: true
    always_declare_return_types: true

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

flutter: 3.27.2
dart: 3.6.1
custom_lint: ^0.7.1
analyzer: ^7.1.0
analyzer_plugin: ^0.12.0
custom_lint_builder: ^0.7.1

To Reproduce

Open a Flutter project in IntelliJ and check if any custom_lints are detected.

Expected behavior
custom_lints are shown in the IntelliJ Dart Analysis tab and in the file, in which the issue occurs.

@rrousselGit @Rexios80 @matthiasn

@MartinAKovachev MartinAKovachev added the bug Something isn't working label Jan 22, 2025
@MartinAKovachev
Copy link
Author

There is a similar bug reported some time ago #191, but the issue still persists.

@MartinAKovachev MartinAKovachev changed the title IntelliJ doesn't detect custom_lint IntelliJ and Android Studio don't detect custom_lint in analysis_options.yaml Jan 22, 2025
@MartinAKovachev MartinAKovachev changed the title IntelliJ and Android Studio don't detect custom_lint in analysis_options.yaml IntelliJ and Android Studio don't detect custom_lint Jan 22, 2025
@MartinAKovachev MartinAKovachev changed the title IntelliJ and Android Studio don't detect custom_lint IntelliJ and Android Studio don't show custom_lint Jan 22, 2025
@MartinAKovachev MartinAKovachev changed the title IntelliJ and Android Studio don't show custom_lint IntelliJ and Android Studio don't show custom lints Jan 22, 2025
@MartinAKovachev
Copy link
Author

MartinAKovachev commented Jan 31, 2025

@EricSchlichting @rrousselGit Android Studio and IntelliJ still don't work with custom_lint: ^0.7.2 and custom_lint_builder: ^0.7.2.
The issues are visible in CLI but not in the IDEs.
Do we need to make any additional steps to fix it after the update?

@rrousselGit
Copy link
Collaborator

Do you have a reproduction?

@MartinAKovachev
Copy link
Author

MartinAKovachev commented Jan 31, 2025

This is what we have in custom_lint.log:

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
ProcessException: No such file or directory
  Command: flutter pub get
at:
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:402:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:579:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      CustomLintWorkspace.runPubGet (package:custom_lint/src/workspace.dart:755:36)
#5      CustomLintWorkspace.resolvePluginHost (package:custom_lint/src/workspace.dart:748:11)
#6      SocketCustomLintServerToClientChannel._startProcess (package:custom_lint/src/v2/server_to_client_channel.dart:151:24)
#7      SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:110:22)
#8      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:394:25)
<asynchronous suspension>
#9      CustomLintServer._handleAnalysisSetContextRoots.<anonymous closure> (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:341:9)
<asynchronous suspension>
#10     PendingOperation.run (package:custom_lint/src/async_operation.dart:22:14)
<asynchronous suspension>
#11     CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:173:22)
<asynchronous suspension>

@MartinAKovachev
Copy link
Author

dart pub deps | grep custom_lint

├── custom_lint 0.7.2
│   ├── custom_lint_core 0.7.1
│   │   ├── custom_lint_visitor 1.0.0+7.1.0
    ├── custom_lint_builder 0.7.2
    │   ├── custom_lint...
    │   ├── custom_lint_core...
    │   ├── custom_lint_visitor...

@rrousselGit rrousselGit reopened this Jan 31, 2025
@EricSchlichting
Copy link
Contributor

@rrousselGit it almost seems like it is running old code. Platform.resolvedExecutable should be an absolute path according to dart docs. Is there potentially some kind of caching happening of an old package version with the analyzer plugin?

@rrousselGit
Copy link
Collaborator

I don't see any reason why old code would be executed.

@chika3742
Copy link

Same issue.
I tried:

  • Invalidate caches and restart
  • deleting lockfile
  • flutter pub cache clean
  • deleting ~/.dartServer
  • restarting Mac

Finally I created a symlink in .pub-cache as a temporary measure.

rm -rf ~/.pub-cache/hosted/pub.dev/custom_lint-0.7.0
ln -s ~/.pub-cache/hosted/pub.dev/custom_lint-0.7.2 ~/.pub-cache/hosted/pub.dev/custom_lint-0.7.0

@iamwaseemsh
Copy link

Please use the following versions to resolve the issue.
custom_lint: ^0.6.10

analyzer: ^6.11.0
analyzer_plugin: ^0.11.3
custom_lint_builder: ^0.6.10

@pavkoccino
Copy link

I am confused. It seems for some people it works at certain setups and for some doesn't. I am currently running:

In the linting package:

  analyzer: ^6.6.0
  analyzer_plugin: ^0.11.0
  custom_lint_builder: ^0.6.8

In the project where I use it:

  custom_lint: ^0.6.8

Works in VSCode, but does not work in Android studio. Same symptoms. IDE does not show it, but if I run dart run custom_lint, it captures the error correctly.

@ronnnnn
Copy link

ronnnnn commented Feb 8, 2025

I found the issue is caused by not updating custom_lint version on packages/custom_lint/tools/analyzer_plugin/pubspec.yaml.
This may be fixed by #309.

https://github.com/dart-lang/sdk/blob/main/pkg/analyzer_plugin/doc/tutorial/package_structure.md#plugin-discovery

Workaround until new version is published is updating your pubspec.yaml and pubspeck.lock in ~/.dartServer/.plugin_manager/.../analyzer_plugin/ like below.
But, this is not good approach because these files are overridden by pub get.

pubspec.yaml

name: custom_lint_analyzer_plugin_loader
description: This pubspec determines the version of the analyzer plugin to load.
version: 0.7.0
publish_to: none

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  custom_lint: 0.7.2

pubspeck.lock

# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  # ...
  custom_lint:
    dependency: "direct main"
    description:
      name: custom_lint
      sha256: "7e6a73e1722ad90b48f77918994c17a5b177b0869804ea3c4ce9c9199de019f6"
      url: "https://pub.dev"
    source: hosted
    version: "0.7.2"
  custom_lint_core:
    dependency: transitive
    description:
      name: custom_lint_core
      sha256: "6dcee8a017181941c51a110da7e267c1d104dc74bec8862eeb8c85b5c8759a9e"
      url: "https://pub.dev"
    source: hosted
    version: "0.7.1"
  custom_lint_visitor:
    dependency: transitive
    description:
      name: custom_lint_visitor
      sha256: "14df0760dfa81b7b0c398c876045f4e4a343eb2c9d200c66163671dd3e337c1b"
      url: "https://pub.dev"
    source: hosted
    version: "1.0.0+7.1.0"

@rrousselGit
Copy link
Collaborator

Looks like my versioning broke and no-longer bumps the tool folder. I'll investigate, but in the meantime I'll just release a new version by hand

@rrousselGit
Copy link
Collaborator

Should be good now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
7 participants