-
Notifications
You must be signed in to change notification settings - Fork 169
Add new lint: unnecessary_final. #1827
Add new lint: unnecessary_final. #1827
Conversation
Personnally I would never enable |
Thanks @a14n . We have fans of both approaches--as on that stackoverflow answer. In google3 it looks like >50% prefers With this lint, the linter can now enforce whichever of the two you like, or neither :) My personal interest is to try to make the tools good enough that nobody wants |
I find this idea confusing. IMO the value of |
Unlike Java It looks like the benefits of using // in java
String s = "";
// with java>=11
final var s = "";
//--- with final
final String s = "";
// with java>=11
final var s = ""; In Dart the difference is smaller (so the main drawback is lowered): // in java
var s = '';
// with java>=11
final s = ''; |
We've had this discussion a lot of times internally :) Originally I was on the side of People didn't want to :) ... they argued that the extra typing (just two characters, but in lots of places) doesn't add enough value. Eventually, after raising this topic repeatedly over a number of years, I figured it's never going to happen: we can't make So I changed my own code to use And my personal experience is that it makes no difference whatsoever. I can't think of a single case where using I hope that one day either enforcement of |
One more thought. Enforcing this lint has the nice property that it makes Thanks. |
This lint is more or less the opposite of
prefer_final_locals
plusprefer_final_in_foreach
, plus checking parameters. (There isn't aprefer_final_parameters
).What do you think, please? This seems much closer to common usage. I'm not sure we'll ever get around to enforcing it, but it's nice to have a lint that matches what people do, so that people aren't just citing the existence of those lints as an argument :)