Skip to content

[Wildcard Variables] consider a use_wildcards lint #59528

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

Closed
pq opened this issue Aug 27, 2024 · 2 comments
Closed

[Wildcard Variables] consider a use_wildcards lint #59528

pq opened this issue Aug 27, 2024 · 2 comments
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-proposal linter-new-language-feature linter-set-core linter-set-recommended P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Aug 27, 2024

Not crazy about the name so other ideas welcome, but the idea is simply to introduce a lint that flags places where folks are using multiple underscores where they could be using a wildcard variable.

For example:

f(int _ , int __) { }

g() {
  var _ = h();
  var __ = h();
}

@useResult
int h() => ...;

#59499 and #59491 propose changing existing lints to do this nudging but after some thinking and conversation, I'm no longer convinced that we want to do this in either. Some reasons:

  1. a targeted lint would allow for better targeted documentation
  2. a targeted lint could get broader adoption (neither no_leading_underscores_for_local_identifiers nor non_constant_identifier_names are enabled in Google3 for example)
  3. Number 2 is especially significant since having an enabled lint in Google3 will greatly help with migration but enabling either no_leading_underscores_for_local_identifiers or non_constant_identifier_names isn't an option because of false positives.

/fyi @kallentu @bwilkerson

@pq pq self-assigned this Aug 27, 2024
@pq pq added type-enhancement A request for a change that isn't a bug linter-new-language-feature P2 A bug or feature request we're likely to work on labels Aug 27, 2024
@pq
Copy link
Member Author

pq commented Aug 27, 2024

Another alternative is updating no_wildcard_variable_uses to do this nudging (as suggested in #59470).

/cc @natebosch @lrhn

@pq
Copy link
Member Author

pq commented Aug 28, 2024

Closing in favor of the meta conversation in #56595

@pq pq closed this as completed Aug 28, 2024
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 20, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-proposal linter-new-language-feature linter-set-core linter-set-recommended P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants