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

[CY-6067] Reporting false positive issues in Flutter project #13

Open
zeshuaro opened this issue May 3, 2022 · 8 comments
Open

[CY-6067] Reporting false positive issues in Flutter project #13

zeshuaro opened this issue May 3, 2022 · 8 comments
Labels
jira-issue Issue tracked on JIRA

Comments

@zeshuaro
Copy link

zeshuaro commented May 3, 2022

Apologies if I'm not supposed to raise/report issues related to dartanalyzer on my project here, I was searching through Codacy support then I realised the existence of this repository. I figured it might be easier to raise the issue here.

This is the Flutter project that I'm trying to use Codacy analysis: https://github.com/zeshuaro/appainter. I enabled the dartanalyzer for this project, but it's reporting a bunch of issues which I'm not seeing locally (see the list of Codacy issues here). It's also weird that there's only 2 particular files that it's reporting the issues:

  • lib/input_decoration_theme/widgets/border_side_fields.dart
  • test/basic_theme/basic_theme_cubit_test.dart

I've tried running dartanalyzer locally through dartanalyzer lib/ and dartanalyzer test/, but I didn't see any of the issues reported by Codacy. This is the version I have for dartanalyzer:

dartanalyzer version 2.15.0

Anyway, I think this might be related where the project also uses code generation. I need to run the following command to generate all the files used in the project (it's a Flutter project, so I generally use the flutter CLI, but I think the dart CLI should work the same):

flutter pub run build_runner build --delete-conflicting-outputs

Would someone be able to help look into it? If this is not the right channel, happy to raise the issue elsewhere.

@github-actions github-actions bot changed the title Reporting false positive issues in Flutter project [CY-6067] Reporting false positive issues in Flutter project May 3, 2022
@github-actions
Copy link

github-actions bot commented May 3, 2022

Internal ticket created : CY-6067

@github-actions github-actions bot added the jira-issue Issue tracked on JIRA label May 3, 2022
@stefanvacareanu7
Copy link
Contributor

Hi there,

Thanks for reaching out to our community!

I am proposing your case to the Engineering Team and return as soon as I have an update.

Best,
Stefan

@rubencodacy
Copy link
Contributor

rubencodacy commented May 26, 2022

Hi @zeshuaro
We just fixed a wrong parsing of the tool when there were too many issues, which might fix one of your problems with the tool. Also, it was bumped to dart SDK 2.17.0.
Regarding the false positives, keep in mind that Codacy does not analyze all the old commits and we only analyze the changed files of a commit, that's why in some commits you might see on the tab "New Issues" of a commit, the new issues found, on the changes of that commit, and below those, on a collapsed selector, the possible new issues which are old issues that were not introduced on this commit.

@zeshuaro
Copy link
Author

Thanks for explaining this. With regard to this:

keep in mind that Codacy does not analyze all the old commits and we only analyze the changed files of a commit

Is there a way to make Codacy to run a full analysis of the repository? If not, I would imagine that it would keep reporting issues in each PR as some files might be missing in the PR.

@rubencodacy
Copy link
Contributor

rubencodacy commented May 30, 2022

When you add the repository for the first time this full analysis should occur. Since there was a bug with the tool that analysis might have failed.
What we recommend you to do is to remove and then add it to Codacy again, so this first analysis is triggered again.
If you have custom pattern configurations you might want to create a coding standard to save those pattern configurations and apply those to the repository again. You can do this here

@Barabas5532
Copy link

I'm seeing similar issues in my project. It seems to be caused by running the analyzer without installing package dependencies or the flutter framework.

we only analyze the changed files of a commit

I don't think this is possible using dart analyser. You must analyse the entire project at once.

Some examples:

Target of URI doesn't exist: 'package:provider/provider.dart'.
Undefined class 'BuildContext'. 
Classes can only extend other classes. triggered by: class KnobWithLabel extends StatelessWidget {
The method '_$AudioParameterDoubleToJson' isn't defined for the type 'AudioParameterDouble'. 

These are all false positives, and there are hundreds more.

  • provider is a package that must be installed using flutter pub get.
  • BuildContext and StatelessWidget are classes from Flutter
  • _$AudioParameterDoubleToJson is inherited from a generated class which must be built using flutter pub run build_runner build before running the analyser

I also run the analyser in GitHub Actions, and no issues are reported there: https://github.com/ShrapnelDSP/ShrapnelMonorepo/actions/runs/3068683044/jobs/4956442251

Unfortunately, these problems make the dart analyzer in codacy useless for Flutter projects.

@tomas-carv-com
Copy link

Any update on this ?!

@tijee
Copy link

tijee commented Feb 9, 2023

I'm facing this issue as well, with errors such as Undefined class 'Widget' (while obviously the file imports material.dart).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-issue Issue tracked on JIRA
Projects
None yet
Development

No branches or pull requests

6 participants