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

Custom lints for several projects inside one repo #204

Closed
mschlegelaware opened this issue Nov 17, 2023 · 8 comments
Closed

Custom lints for several projects inside one repo #204

mschlegelaware opened this issue Nov 17, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@mschlegelaware
Copy link

Describe the bug
Hello, I followed your readme and created a custom lint package (lets name it CL). I added it (same as the custom_lint package to the pubspec.yaml of my project A) and everything works as expected. The custom rule findings are shown in the dart analyse section of my IDE. But the repository/ project setup is a little bit more complex. Here is the summarised folder structure:

/A
/SP
/CL
/analysis_options.yaml

I have a, lets say, main flutter project A, which is importing another sub-project (SP) within the same repo via:

  SP:
    path: "../SP"

The problem now is, that the custom lint rules are not applied to the code inside SP (even though the analysis_options file is setup correctly and it works for A). I thought, that I maybe have to add the CL reference (and custom_lint) to the pubspec.yaml of SP (similar how I did it for A). When doing this, following is the output of the 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:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:578:18)
#3      Process.run (dart:io-patch/process_patch.dart:49:12)
#4      CustomLintWorkspace.runPubGet (package:custom_lint/src/workspace.dart:829:36)
#5      CustomLintWorkspace.resolvePluginHost (package:custom_lint/src/workspace.dart:804:13)
<asynchronous suspension>
#6      SocketCustomLintServerToClientChannel._startProcess (package:custom_lint/src/v2/server_to_client_channel.dart:160:7)
<asynchronous suspension>
#7      SocketCustomLintServerToClientChannel.init (package:custom_lint/src/v2/server_to_client_channel.dart:111:21)
<asynchronous suspension>
#8      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:364:5)
<asynchronous suspension>
#9      CustomLintServer._handleAnalysisSetContextRoots.<anonymous closure> (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:328: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:160:22)
<asynchronous suspension>

When I add CL just to SP (not to both):

  SP:
    path: "../SP"

The findings from the custom lint rules are just shown for the SP but not for A. Somehow there is a problem when applying CL for both projects. Do you have any idea?

To Reproduce

Is it needed/ doable for this complex setup?

Expected behavior
Custom lint rule findings in project A and SP are shown in the analyze error section of my IDE.

Thank you in advance!

@mschlegelaware mschlegelaware added the bug Something isn't working label Nov 17, 2023
@mschlegelaware
Copy link
Author

somtimes, also this appears:

The request analysis.setContextRoots failed with the following error:
RequestErrorCode.PLUGIN_ERROR
UnimplementedError
at:
#0      SocketCustomLintServerToClientChannel.setContextRoots (package:custom_lint/src/v2/server_to_client_channel.dart:148:5)
#1      CustomLintServer._maybeSpawnCustomLintPlugin (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:340:35)
#2      CustomLintServer._handleAnalysisSetContextRoots.<anonymous closure> (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:328:15)
#3      PendingOperation.run (package:custom_lint/src/async_operation.dart:18:22)
#4      CustomLintServer._handleAnalysisSetContextRoots (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:325:15)
#5      RequestX.when (package:custom_lint/src/request_extension.dart:136:47)
#6      CustomLintServer._handleRequest (package:custom_lint/src/v2/custom_lint_analyzer_plugin.dart:160:36)
#7      _rootRunUnary (dart:async/zone.dart:1407:47)
#8      _CustomZone.runUnary (dart:async/zone.dart:1308:19)
#9      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#10     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#11     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#12     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#13     _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#14     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#15     _rootRunUnary (dart:async/zone.dart:1407:47)
#16     _CustomZone.runUnary (dart:async/zone.dart:1308:19)
#17     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#18     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#19     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#20     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#21     _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
#22     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#23     _rootRunUnary (dart:async/zone.dart:1407:47)
#24     _CustomZone.runUnary (dart:async/zone.dart:1308:19)
#25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#26     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#27     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#28     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:377:25)
#29     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
#30     _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:474:11)
#31     _rootRunUnary (dart:async/zone.dart:1415:13)
#32     _CustomZone.runUnary (dart:async/zone.dart:1308:19)
#33     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
#34     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#35     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#36     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#37     _StreamController._add (dart:async/stream_controller.dart:658:7)
#38     _StreamController.add (dart:async/stream_controller.dart:606:5)
#39     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

@rrousselGit
Copy link
Collaborator

To Reproduce
Is it needed/ doable for this complex setup?

Yes, please, share a reproducible sample. Make a github repository that I can use somewhere. Otherwise I'll have a hard time fixing this.

@torbenkeller
Copy link

I also have the same problem and I am able to reproduce it. Given the following project structure:

monorepo/
├─ packages/
│  ├─ domain_one/
│  │  ├─ flutter_project_a/
│  │  ├─ flutter_project_b/
│  ├─ domain_two/
│  │  ├─ flutter_project_c/

Then adding the custom_linter plugin to flutter_project_a and flutter_project_b works, because the flutter projects are on the same folder level. But when you add the custom_linterplugin to flutter_project_c, the custom linter on all projects will crash.

I hope that helps!

@mschlegelaware
Copy link
Author

I also have the same problem and I am able to reproduce it. Given the following project structure:

monorepo/
├─ packages/
│  ├─ domain_one/
│  │  ├─ flutter_project_a/
│  │  ├─ flutter_project_b/
│  ├─ domain_two/
│  │  ├─ flutter_project_c/

Then adding the custom_linter plugin to flutter_project_a and flutter_project_b works, because the flutter projects are on the same folder level. But when you add the custom_linterplugin to flutter_project_c, the custom linter on all projects will crash.

I hope that helps!

Thanks for your input on this topic. My setup is even simpler than yours, and the import of the custom_lint works.

monorepo/
├─ main_flutter_project/
         (here I import my sub_custom_analyzer and the custom_lint package in the pubspec.yaml)
         sub_custom_analyzer:
            path: "../sub_custom_analyzer
        custom_lint: ^0.5.7
├─ sub_package_1/
        custom_lint: ^0.5.7
├─ sub_package_2/
        custom_lint: ^0.5.7
├─ sub_custom_analyzer/
        analyzer: ^5.13.0
        analyzer_plugin: ^0.11.2
        custom_lint_builder: ^0.5.7
├─ analysis_options.yaml
       (where I added)
        plugins:
          - custom_lint

All good, but in the moment I include the sub_custom_analyzer in the sub_package_1 or sub_package_2 pubspec.yaml files, similar to how I do it in the main_flutter_project, it crashes. So the problem is not with the import of the custom_lint but with the import of my sub_custom_analyzer. Maybe I did messed up sth. with my setup.

@kensamare
Copy link

Are there any solutions to this problem?

@rrousselGit
Copy link
Collaborator

This issue should've been closed when the PR was merged recently. Closing

@rrousselGit
Copy link
Collaborator

@kensamare Use the latest custom_lint version and you should be good

@kensamare
Copy link

@rrousselGit Latest version does work in VS Code and Cli, but somehow I get the same error when using Android Studio

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
Development

No branches or pull requests

4 participants