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

Skip to content

proposal: no_leading_underscore_for_local_functions #58664

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
3 of 5 tasks
srawlins opened this issue Feb 25, 2022 · 3 comments
Closed
3 of 5 tasks

proposal: no_leading_underscore_for_local_functions #58664

srawlins opened this issue Feb 25, 2022 · 3 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-proposal linter-status-pending

Comments

@srawlins
Copy link
Member

no_leading_underscore_for_local_functions

Description

Do not name local functions with a leading underscore: their visibility is dictated by local scope. Similar to no_leading_underscore_for_local_variables.

Details

no_leading_underscore_for_local_variables does not trigger on local functions. Rather than treat that as a false negative, which is hard to land, we can just create a new rule.

I often catch this in readability reviews.

Kind

Does this enforce style advice? Guard against errors? Other?

Style, I suppose. Meets with Effective Dart recommendations.

Good Examples

void foo10() {
  void foo11() {}
}

Bad Examples

void foo10() {
  void _foo11() {}
}

Discussion

Discussion checklist

  • List any existing rules this proposal complements, overlaps or conflict with.
  • List any relevant issues (reported here, the SDK Tracker, or elsewhere).
  • If there's any prior art (e.g., in other linters), please add references here.
  • If this proposal corresponds to Effective Dart or Flutter Style Guide advice, please call it out. (If there isn’t any corresponding advice, should there be?)
  • If this proposal is motivated by real-world examples, please provide as many details as you can. Demonstrating potential impact is especially valuable.
@srawlins
Copy link
Member Author

CC @goderbauer I found this while implementing a fix for no_leading_underscore_for_local_identifiers.

@goderbauer
Copy link
Contributor

I naively thought that no_leading_underscore_for_local_variables would already cover it, but since it doesn't I am in factor of this new lint.

When the lint exists, we should also consider it for inclusion into package:lints.

@srawlins
Copy link
Member Author

srawlins commented Sep 2, 2022

Handled in no_leading_underscores_for_local_identifiers in #58715

@srawlins srawlins closed this as completed Sep 2, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 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-status-pending
Projects
None yet
Development

No branches or pull requests

3 participants