Skip to content

flutter analyze --flutter-repo should analyze analysis_options.yaml #127989

Description

@goderbauer

flutter analyze --flutter-repo currently does not analyze the analysis_options.yaml at the root of the repository. This caused us to miss some warnings about deprecated lints in that file. The command should be updated to analyze that file as well since it is part of the repository and it may have issues reported by the analyzer.

Steps to repro the failure to report deprecated lints in that file:

  1. Add the deprecated lint iterable_contains_unrelated_type to the analysis_options.yaml at the root of the repository.
  2. Verify that the analyzer reports a deprecated lint when analyzing this specific file alone: flutter analyze analysis_options.yaml.
  3. Run flutter analyze --flutter-repo and observe that no deprecated lint is reported.

Expected Output:

   info • 'iterable_contains_unrelated_type' is deprecated and should be replaced by 'collection_methods_unrelated_type' • analysis_options.yaml:113:7 •
          deprecated_lint_hint_with_replacement

Actual Output: nothing reported.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on May 31, 2023
  2. goderbauer commented on May 31, 2023

    @goderbauer
    MemberAuthor

    While looking at this I noticed that the Flutter tool actually jumps through some extra hoops to only analyze the dev, examples, and packages directory:

    List<String> getRepoRoots() {
    final String root = globals.fs.path.absolute(Cache.flutterRoot!);
    // not bin, and not the root
    return <String>['dev', 'examples', 'packages'].map<String>((String item) {
    return globals.fs.path.join(root, item);
    }).toList();
    }

    I wonder why we decided to do that? It seems like it would be easier to just run the analyze command on the root of the repository and use the excludes section in the analysis_options.yaml file to exclude the only directory we don't want to analyze: bin. (We already use the excludes section to exclude other parts of the repo from analysis.) This would also ensure that the analysis_options.yaml file itself at the root of the repo is analyzed.

    In theory, with this approach we could even deprecated the --flutter-repo special flag and just run flutter analyze . in the root of the repository everywhere (e.g. on CI)...

  3. goderbauer commented on May 31, 2023

    @goderbauer
    MemberAuthor

    cc @christopherfujino

    cc @Hixie This should explains why the deprecation notices you saw locally are not breaking our CI. It doesn't explain why you saw those notices locally in the first place, though...

  4. whesse commented on Jun 7, 2023

    @whesse
    Contributor

    The fix landed for this issue runs the analyzer on all subdirectories of the flutter checkout, and that can include user-created directories that don't contain flutter source at all.

    For example, to make a hermetic image for flutter, Golem puts the pub cache in a pub-cache directory, and sets the analysis server temp directory to .dartServer, both in the root directory of flutter. I see notes where other users put config directories here rather than in their home directory. Only files that are part of the flutter repo should be analyzed by this command.

  5. github-actions commented on Jun 21, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  6. locked as resolved and limited conversation to collaborators on Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions