Skip to content

flutter analyze behaviour with a command line argument is very confusing #7274

Closed

Description

@Hixie

It's not at all clear to me what happens when you run flutter analyze foo where foo is a path.

In particular:

  • if the path is invalid we seem to just ignore it
  • consider the differences here, where temp contains a single .dart file, and dev is the directory that contains my flutter checkout dart sdk checkout, engine checkout, etc:
$ cd ~/temp
$ flutter analyze ../dev
Analyzing ../dev...
No analyzer warnings! (ran in 0.2s)
$ cd ~/dev
$ flutter analyze ../dev
Analyzing ....
No analyzer warnings! (ran in 0.2s)
$ flutter analyze
Analyzing 31030 files...

See also #4387 which may be contributing to the confusion.

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Jan 13, 2017
  2. added this to the milestone on Jan 13, 2017
  3. Hixie commented on Jan 13, 2017

    @Hixie
    ContributorAuthor

    @danrubel and I talked about this this morning and came to the following conclusion (I may have elaborated a bit from our discussion, let me know if I made any mistakes!):

    • The --current-directory command line argument should be removed.
    • If there are non-option arguments, then they list directories (or files, in the non --watch case) that we should use to start a deep crawl finding all the pubspec.yaml files (all the "contexts") that we should then analyze. Directories that contain .dartignore files get skipped by this crawl. The analyzer further ignores files based on the relevant .analysis_options files.
    • The --flutter-repo argument is a shorthand for also listing the path of the root of the flutter repo.
    • The --current-package argument is a shorthand for also listing the nearest enclosing directory going up from the current directory that contains a pubspec.yaml.
    • If neither --flutter-repo nor --current-package are listed and there are not non-option arguments, default to the --current-package behaviour.
  4. danrubel commented on Jan 13, 2017

    @danrubel

    Yes, this sounds good to me. I suggest we remove --current-package and make it the default behavior if no non-option arguments are supplied.

  5. danrubel commented on Jan 13, 2017

    @danrubel

    Since --flutter-repo is shorthand for the flutter repo root path, I amend my current suggestion to be ...

    We remove --current-package and make it the default behavior if no non-option arguments are supplied and --flutter-repo is not supplied.

  6. Hixie commented on Jan 13, 2017

    @Hixie
    ContributorAuthor

    That would mean that you can't only scan the flutter repo, no?

  7. danrubel commented on Jan 13, 2017

    @danrubel

    Adding --flutter-repo would be the same as adding /the/path/to/the/flutter/repo, and would be included with any other paths of files/directories to be analyzed. IOW, this is would analyze the flutter repo along with files in the other specified directories...

    flutter analyze --flutter-repo /my/first/project /my/second/project

    And this would just analyze just the flutter repo regardless of the current working directory

    flutter analyze --flutter-repo

  8. Hixie commented on Jan 13, 2017

    @Hixie
    ContributorAuthor

    The use cases my ideal world would support are:

    1. "analyze this project (implied from current directory)"
    2. "analyze these projects (by path)"
    3. "analyze the flutter repo (but not the current directory, which might contain weird stuff)"
    4. "analyze my current project (even though I'm in some subdirectory), and analyze my library over there" (where "my library over there" could either be a path, or --flutter-repo).

    I think if we don't have --current-package as a way to trigger the default behaviour even in the presence of other options, we can't get use case 4. If we always imply --current-package, we can't get use case 3.

  9. danrubel commented on Jan 13, 2017

    @danrubel

    Updated my comment above to clarify using --flutter-repo with no other arguments.

    Hmmm... fair enough. IOW flutter analyze and flutter analyze --current-package are the same, but we continue to support --current-package so that you don't have to explicitly specify the path of the project containing the current directory when specifying multiple targets.

    For example flutter analyze --flutter-repo --current-package /path/to/yet/another/project would analyze...

    • the flutter repo
    • the package containing the current working directory
    • "yet another project"

    ...all at the same time.

  10. Hixie commented on Jan 13, 2017

    @Hixie
    ContributorAuthor

    Right.

    In theory the argument should be almost trivial to support since it's just a way to trigger the default behaviour. It also makes it easier to "explain" what the default behaviour is.

  11. xster commented on Jan 23, 2017

    @xster
    Member

    My clueless new guy 2-cents. I ran into this looking at the onboarding guides and was a bit confused with the difference between [no-arguments], flutter-repo, current-directory, current-package.

    • The first line of the doc says "Analyze the project's Dart code". Agree with comment 272536360 that --current-package is then implied if no arguments are supplied. Seems like --current-directory is redundantly a strict subset of --current-package. Less options/reading for the user, the better I think :)

    • re:flutter-repo. Had to re-read it a few times. Initially I was thinking, wouldn't all the packages you want to analyze in some flutter-based repo? But I guess this is referring to the tool/framework repo. Is this special enough for our users to have a special option flag? Most people would just do brew install flutter and never look at that tool/framework repo again right?

    • For foolproof understandings, maybe we can avoid mixing directories and option flags by having no option flags be shorthands for directories. e.g.
      1- flutter analyze -> current package
      2- flutter analyze x -> recursively x only
      3- flutter analyze . x -> recursively current directory and x
      4- flutter analyze $FLUTTER_ROOT -> recursively the flutter framework repo only
      This way, flags are all instructions on how to run flutter analyze, not a mixture of how to run and what to run on.

    4 makes it a bit more painful for us (framework contributors) but we're such a command doc reader minority that clarity overweight our convenience.

  12. Hixie commented on Jan 23, 2017

    @Hixie
    ContributorAuthor

    I'm fine with hiding --flutter-repo from the --help listing, but it is hugely useful to the team and that's important to Flutter's ability to evolve, so I think we should keep it.

  13. HansMuller commented on Jan 24, 2017

    @HansMuller
    Contributor

    I agree with Ian. I use --flutter-repo all the time and wouldn't mind if it didn't appear in the --help listing.

  14. modified the milestones: , on Jan 30, 2017
  15. 8 remaining items

  16. removed this from the milestone on Jun 1, 2020
  17. removed this from the milestone on Jun 16, 2020
  18. removed this from the milestone on Jul 7, 2020
  19. modified the milestone: on Jul 22, 2020
  20. removed this from the milestone on Aug 17, 2020
  21. tmaihoff commented on Oct 5, 2021

    @tmaihoff

    I have a similar issue.
    I want to analyze only the lib folder with flutter analyze lib.
    However, problems inside example which is a sibling folder are still found

  22. bkonyi commented on Sep 30, 2024

    @bkonyi
    Contributor

    The issues mentioned here all seem to be resolved based on some quick tests.

  23. github-actions commented on Oct 14, 2024

    @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.

  24. locked as resolved and limited conversation to collaborators on Oct 14, 2024
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

    P3Issues that are less important to the Flutter projectteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions