Thanks to visit codestin.com
Credit goes to github.com

Skip to content

no_leading_underscores_for_local_identifiers doesn't complain about local functions #58715

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
goderbauer opened this issue Apr 25, 2022 · 2 comments · Fixed by dart-archive/linter#3361
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@goderbauer
Copy link
Contributor

The following code does not produce a no_leading_underscores_for_local_identifiers lint, even though I would have expected it to complain about _bar:

int foo() {
  int _bar() { // Why no no_leading_underscores_for_local_identifiers lint here?
    return 10;
  }
  return _bar();
}

Complaining here would also seem to be in line with "Effective Dart" [1] (emphasize mine):

There is no concept of “private” for local variables, parameters, local functions, or library prefixes. When one of those has a name that starts with an underscore, it sends a confusing signal to the reader. To avoid that, don’t use leading underscores in those names.

[1] https://dart.dev/guides/language/effective-dart/style#dont-use-a-leading-underscore-for-identifiers-that-arent-private

@goderbauer
Copy link
Contributor Author

For extra context, I noticed this while reviewing flutter/flutter#102419. The tests there use local functions with leading underscores and our analysis check is green with the no_leading_underscores_for_local_identifiers enabled.

@pq
Copy link
Member

pq commented Apr 25, 2022

100% agreed. This one was just an oversight. Fixing now.

Thanks!

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants