Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

[Question] only analyze opened files in VSCode #946

Closed
taibaiyinxing opened this issue Jul 27, 2022 · 17 comments
Closed

[Question] only analyze opened files in VSCode #946

taibaiyinxing opened this issue Jul 27, 2022 · 17 comments
Assignees
Labels
area-plugin type: question Further information is requested

Comments

@taibaiyinxing
Copy link

taibaiyinxing commented Jul 27, 2022

What do you want to discuss?
I just learned to add dart-code-metrics to my test project, but after I added configurations to the analysis_options.yaml, and written some code that against a rule ('avoid-returning-widgets', which is added to the analysis_options.yaml file), then I switched to another file which didn't have any proplem, and finaly I restart my VS Code, and found that the warning info only show when I switch back to the one with proplem. My question is 'How to make the analyzer plugin analyze the full project when I open the IDE or project?', thanks.

@incendial
Copy link
Member

@taibaiyinxing hi, it should analyze the whole project by default. Can you share the package version and the sdk version you have?

@incendial incendial added type: question Further information is requested area-plugin labels Jul 27, 2022
@taibaiyinxing
Copy link
Author

@incendial Thanks. My dart-code-metircs version is 4.16.0, and Dart version is 2.16.1, Flutter version is based on 2.10.2 (which has a little custom made from my company)

@taibaiyinxing
Copy link
Author

and the analyzer version is 4.1.0; the analyzer_plugin version is 0.10.0 in the pubspec.lock file

@incendial
Copy link
Member

Can you please try to clear plugin_manager folder as described here https://github.com/dart-code-checker/dart-code-metrics/blob/master/CONTRIBUTING.md#run-the-plugin-in-ide, 5 step and then reload the IDE?

@taibaiyinxing
Copy link
Author

@incendial I have tried to delete the .dartServer folder following the step 5 from the link just now, and found that the clear couldn't solve my problem. I also tried this in the Android Studio, the problem was still exist.
But when I runned the command line 'dart run dart_code_metrics:metrics analyze lib', I found that this cli can print the warnning infos of the files from whole project.

@incendial
Copy link
Member

incendial commented Jul 29, 2022

Strange, I see that you created an issue in sdk repo dart-lang/sdk#49551, let's see what the Dart team will say, coz it looks mostly like integration issue on their side

@taibaiyinxing
Copy link
Author

@incendial Thanks. I got the logs and had a new discover and commented it in that issue, maybe we can discuss it there.

@taibaiyinxing
Copy link
Author

@incendial Hi, I just tried to solve the problem as described in sdk repo dart-lang/sdk#49551, and it seems work. Do you have any suggestions about it? Thanks.

@incendial
Copy link
Member

@taibaiyinxing sorry for the delay. I've checked the example with adding the path to the context root excludes and I think that it should be supported just from analysis_options. I'll check our code today

@taibaiyinxing
Copy link
Author

Thanks. I've get some info from dart-lang/sdk#49551 as they said:

I would expect that you don't need to exclude the directory because I thought we were already excluding all folders whose name started with a period, but that appears to not be the case.

Maybe we should wait for a conclusion about this.

@incendial
Copy link
Member

@taibaiyinxing sorry for the long delay, but have you found a solution for the problem?

@taibaiyinxing
Copy link
Author

@incendial I'm sorry for such a long delay. My solution is adding the ".flutterw" folder which has lots of dart files to the 'exclude' field of the ContextRoot instance in the 'createAnalysisDriver' method, and it did work for me.

@incendial
Copy link
Member

@taibaiyinxing so you have a fork of DCM plugin?

@taibaiyinxing
Copy link
Author

@incendial Emmm, I just downloaded the source code of v4.16.0 and modified it and used it locally. My main flutter project does not support Flutter3.0 now.

@incendial
Copy link
Member

Yeah, I meant that you use some modified version and it works for you? Looks like since you're on the old version, there is not much we can do

@taibaiyinxing
Copy link
Author

@incendial Yes, my modification works for me now, and I don't think there's any thing you need to do, because it's not a common situation.

@incendial
Copy link
Member

Okay, so I'm closing this for now. Feel free to reopen when you update to the latest version. We'll see what we can do (maybe some API for those type of excludes).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-plugin type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants