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

Analysis options bugged after upgrading from Flutter 3.22.0-0.2.pre to 3.23.0-0.1.pre #55975

Closed
cabaucom376 opened this issue Jun 10, 2024 · 4 comments
Labels
analyzer-analysis-options area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@cabaucom376
Copy link

For the last 6 moths I have been using this guide to essentially include all linter rules and then override the conflicts and tune the rules to my taste. I have made this simple little setup into a package that I host on a private GitHub repo and just update the all_linter_rules.yaml file whenever new rules are added, as well as make sure all conflicts are resolved. With the 3.23 beta I am encountering a new error even though my overall methods have remained consistent.

I am now getting warnings about conflicting linter rules in my all_linter_rules.yaml file even though conflicts are properly overridden and the included_file_warning: ignore analyzer error is properly set. The weird part is that when I reference my custom analysis packages' analysis_options.yaml locally the errors are not present. Only when referencing the analysis_options.yaml using a package import, from git hosted or local path, do these warnings appear.

  1. nv_analysis package files

  2. Project files

pubspec.yaml:

dev_dependencies:
  flutter_test:
    sdk: flutter
  nv_analysis:
    git:
      url: [email protected]:Novoid-LLC/nv_flutter_analysis.git
      ref: master

analysis_options.yaml:

include: package:nv_analysis/analysis_options.yaml # local barrel import of file removes warnings
analyzer:
  plugins:
    - custom_lint
  1. Warnings:
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(1497..1529): The rule 'avoid_types_on_closure_parameters' is incompatible with the rule 'always_specify_types'.dart(included_file_warning)
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(3522..3546): The rule 'omit_local_variable_types' is incompatible with the rule 'always_specify_types'.dart(included_file_warning)
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(4302..4324): The rule 'prefer_final_parameters' is incompatible with the rule 'avoid_final_parameters'.dart(included_file_warning)
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(4906..4928): The rule 'prefer_relative_imports' is incompatible with the rule 'always_use_package_imports'.dart(included_file_warning)
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(4936..4955): The rule 'prefer_single_quotes' is incompatible with the rule 'prefer_double_quotes'.dart(included_file_warning)
Warning in the included options file /Users/$User/.pub-cache/git/nv_flutter_analysis-b80a6a1f77bd738d967c1ff52af94e50788bb94f/lib/all_lint_rules.yaml(5799..5815): The rule 'unnecessary_final' is incompatible with the rule 'prefer_final_locals'.dart(included_file_warning)

Expected results

The expected results is that I should be able to include: package:nv_analysis/analysis_options.yaml and not receive conflicts from the all_lint_rules.yaml file since they have been resolved using overrides and even supposedly silenced using included_file_warning: ignore.

Actual results

My best guess of what is actually happening is for some reason the included_file_warning: ignore is not being applied to subsequent inclusions in yaml files. This is resulting in linter rules showing up as conflicts. Interestingly this is only reproducible when importing as a package.

Code sample

Attempt to import this analysis package in your projects analysis_options.yaml:

include: package:nv_analysis/analysis_options.yaml

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.23.0-0.1.pre, on macOS 14.5 23F79 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google
    Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.90.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable
      or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Originally posted by @cabaucom376 in flutter/flutter#149981

@cabaucom376 cabaucom376 changed the title ### Steps to reproduce Analysis options bugged after upgrading from Flutter 3.22.0-0.2.pre to 3.23.0-0.1.pre Jun 10, 2024
@srawlins srawlins transferred this issue from dart-lang/linter Jun 11, 2024
@srawlins srawlins added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-analysis-options type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Jun 11, 2024
@foxanna
Copy link

foxanna commented Jun 12, 2024

I experience similar behavior in my project. In this monorepo, there is a package www_analysis dedicated to configuring analyzer, which only contains lib/analysis_options.yaml file with the following content:

analyzer:
  exclude:
    - lib/**.g.dart
    - lib/**.freezed.dart
    - lib/**.i69n.dart
    - lib/**.config.dart

  errors:
    missing_required_param: error
    missing_return: error
    invalid_assignment: warning
    invalid_annotation_target: ignore

This package is referenced by path by every other package, and their analysis_options.yaml file contains:

include: package:www_analysis/analysis_options.yaml

With this configuration, the project used to have no analyzer warnings in generated files, and also did not have invalid_annotation_target warnings because it was instructed to ignore those.

However, after I switched from stable channel Flutter 3.22.2 and Dart 3.4.3 to beta Flutter 3.23.0-0.1.pre and Dart 3.5.0-180.3.beta, this configuration provided with include seems to be ignored as there are now invalid_annotation_target warnings everywhere.

If I copy the content of www_analysis/lib/analysis_options.yaml file to analysis_options.yaml of other packages, warnings in those packages disappear.

@bwilkerson
Copy link
Member

There is another possible reason for the behavior being reported here: it's possible that the interpretation of relative paths changed. If the relative path is now interpreted relative to the analysis_options.yaml file in www_analysis and was previously interpreted relative to the including analysis_options.yaml file, that would account for the difference.

@pq

@utamori
Copy link

utamori commented Jul 26, 2024

Still occurs in Flutter 3.24.0-0.1.pre

@cabaucom376
Copy link
Author

Fixed via this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-analysis-options area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants