-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Code clean up, additional lints #1594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution I've just reviewed the first modified files but here's some of my concerns:
- While it's nice to have more opiniated linting rules and uniformize the coding style you should've probably discussed those beforehand with one of the maintainers to establish clear rules to add to the
CONTRIBUTING.md
file. - I find useless to specify every time you create a list
growable: false
it doesn't bring any performance improvement nor warnings/errors from the analyzer before execution of the code, personally I find it unneeded as if we really wanted to have an immutable list we could've used directly anIList
object from fast_immutable_collections or dartz - Using
=>
for fast return might feel faster because you're saving some lines of code but from my experience it reduces readability and it is preferable to keep brackets with an explicitreturn
- About the linting rules you've added there's 2 that I find to be too bothersome when coding: omit_local_variable_types because I wouldn't be able to write a variable like this
double myVar = 1.0
it would expect avar myVar = 1.0
but I find it to reduce type safety and the fact that you've ignored this rule by yourself inlatlng_bounds.dart
makes me think that it shouldn't be part of the linting rules, prefer_single_quotes has also proven to me to be a bit too much opiniated as I like to use double quotes when I've got characters such as'
in my string instead of writing\'
.
Other than that the other linting rules seems fair to me and some refacto you've been doing are much appreciated and improve code readability but you probably should have opened an issue explaining the changes you had in mind to improve the coding style so it could've been discussed with maintainers and contributors before starting this draft. (would love opinions of other maintainers on this btw @JaffaKetchup @ibrierley @mootw)
I'll reply a little more a little later, but just for now I'll say that 'prefer_single_quotes' does still allow double quotes when single quotes are inside the string @TesteurManiak. |
You're right! My bad then, this rule can be kept 👍 |
Thank you that you guys already had a look through the pr, @TesteurManiak @JaffaKetchup! I wanted to dive deeper into the flutter_map code and took the chance to do some minor improvements on the way.
I knew that introducing more lints will lead to discussions and I'm completely fine to make changes to this pull request like removing lint rules. (: As mentioned the lint rules are opinionated and should defently get discussed. The lints that I added are purely meant to ensure code consistency and code readability.
I'm a bit confused because making Lists immutable wasn't my focus. I added
No indeed there is no performance improvements here. I idea behind it is a reduce nesting. But I can revert those changes (especially in
But I can defently remove that lint as it might complicate things.
I completely agree on that, but the thing is that flutter_map is currently 100% minus one szenario written with single quotes!😄 So I thought why not add this rule for concistency in the future. And like @JaffaKetchup said it doesn't prevents you to use double quotes when you're using a single quote inside.
I keep that it mind for furture contributions, thanks! Don't worry if you need to revert things in this draft pull request as it got created while i dug through the code. I'm completely open to make changes and hear about possible concerns from the other maintainers. Just because I created a pull request directly doesn't mean that I don't want to open it up for discussion. (: |
I think I prefer specifying the local variable types than using I ALWAYS use I've never specified |
I don't really get why |
@TesteurManiak Can you review this, as you started reviewing first? |
Sorry for the delay, I'll try to review changes as soon as I can 😓 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
@immutable
annotation to make it clear what classes are completely immutable and use const and final where possiblelib\src\layer\label.dart
Most of the changes are refactoring. I tested it with the demo application and haven't experienced any problems.
Lint references:
https://dart.dev/tools/linter-rules/use_super_parameters
https://dart.dev/tools/linter-rules/cast_nullable_to_non_nullable
https://dart.dev/tools/linter-rules/only_throw_errors
https://dart.dev/tools/linter-rules/sort_unnamed_constructors_first
https://dart.dev/tools/linter-rules/prefer_asserts_with_message
https://dart.dev/tools/linter-rules/missing_whitespace_between_adjacent_strings
https://dart.dev/tools/linter-rules/avoid_multiple_declarations_per_line
https://dart.dev/tools/linter-rules/noop_primitive_operations
https://dart.dev/tools/linter-rules/avoid_void_async
https://dart.dev/tools/linter-rules/avoid_redundant_argument_values
https://dart.dev/tools/linter-rules/avoid_types_on_closure_parameters
https://dart.dev/tools/linter-rules/omit_local_variable_typeshttps://dart.dev/tools/linter-rules/matching_super_parameters
https://dart.dev/tools/linter-rules/unnecessary_null_checks
https://dart.dev/tools/linter-rules/prefer_single_quotes
https://dart.dev/tools/linter-rules/unnecessary_parenthesis
https://dart.dev/tools/linter-rules/use_if_null_to_convert_nulls_to_bools