-
Notifications
You must be signed in to change notification settings - Fork 1.7k
proposal: unnecessary_final
. Allow final local variables that shadow fields
#59446
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
Comments
Should Assuming so, I'm in favor. @lrhn @munificent @natebosch @jakemac53 WDYT? |
Why? Is it to prevent someone accidentally assigning to the local variable, when they intended to assign to the instance variable? Honestly, I'd prefer this as a separate opt-in exception/other lint. If I were to use a lint to enforce no local finals, I'd want it to actually do that. |
I think there has been some precedent for changing a lint behavior based on whether another lint is enabled. We could consider a |
Yes, that's the reasoning behind our exception to the rule. I'm not convinced that adding the exception to the lint is in the best interest of our users, and the ideas about creating a new lint, whether to replace or augment the existing lint, are interesting, so thanks for mentioning them. |
But don't enable it yet, pending https://github.com/dart-lang/linter/issues/4938 Change-Id: I42df6e5c2699b08d729518c0565165d81e07ad3d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363160 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
With https://dart-review.googlesource.com/c/sdk/+/366960 landed, we basically decided that we don't want this exception. |
unnecessary_final
Description
Allow final local variables that shadow fields.
Details
Bad Examples
Same as now.
Good Examples
Allow
Discussion
This is the code style that the analyzer team follows.
See https://dart-review.googlesource.com/c/sdk/+/362901 for the change (will be removed in new updates) and the bulk updates to
analysis_server
.The text was updated successfully, but these errors were encountered: