Skip to content

Encourage the use of initializing formal parameters #58847

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
bwilkerson opened this issue Aug 31, 2022 · 5 comments
Closed

Encourage the use of initializing formal parameters #58847

bwilkerson opened this issue Aug 31, 2022 · 5 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. linter-lint-request P3 A lower priority bug or feature request

Comments

@bwilkerson
Copy link
Member

Similar to the use_super_parameters rule, there could be a rule to encourage the use of an initializing formal parameter when the parameter is assigned, unmodified, to a field with the same name as the parameter. For example:

class C {
  int field;

  C({required int field}) : field = field; // Should use 'this.field'.
}
@bwilkerson bwilkerson added linter-lint-request P3 A lower priority bug or feature request labels Aug 31, 2022
@asashour
Copy link
Contributor

asashour commented Sep 1, 2022

There is prefer_initializing_formals

@bwilkerson
Copy link
Member Author

Sad that I couldn't find it when looking to see whether we had such support.

@asashour
Copy link
Contributor

asashour commented Sep 1, 2022

Honestly, it is difficult to see which lint does what.

I am not sure if having "categories" or hierarchy of them would help. Also, having similar lints or search by synonyms/filter could add a value.

Another suggestion is to have a table of all lints with their bad example.

@bwilkerson
Copy link
Member Author

@sfshaza2 As another data point for the need to make it easier to find relevant lints.

@srawlins
Copy link
Member

srawlins commented Sep 1, 2022

@asashour see this request: #57719 and thumbs up 😄

@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-request P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

4 participants