-
Notifications
You must be signed in to change notification settings - Fork 273
feat: Create new rule avoid_collection_methods_with_unrelated_types
#705
feat: Create new rule avoid_collection_methods_with_unrelated_types
#705
Conversation
avoid_collection_methods_with_unrelated_types
avoid_collection_methods_with_unrelated_types
Tests have passed locally :) |
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.
@fzyzcjy thank you so much for the contribution. This looks 🔥
I guess, the main questions is about supporting not only maps, but sets and lists too. What do you think?
Also, was it hard to add a rule? Maybe you have faced some problems that we should address on order to make the contribution process easier?
...rs/lint_analyzer/rules/rules_list/avoid_collection_methods_with_unrelated_types/visitor.dart
Outdated
Show resolved
Hide resolved
...rs/lint_analyzer/rules/rules_list/avoid_collection_methods_with_unrelated_types/visitor.dart
Outdated
Show resolved
Hide resolved
website/docs/rules/common/avoid-collection-methods-with-unrelated-types.md
Show resolved
Hide resolved
website/docs/rules/common/avoid-collection-methods-with-unrelated-types.md
Show resolved
Hide resolved
Following the original issue, I may also add
I just copy-and-paste-and-modify from sibling rules ;) It is ok imho |
@incendial Done and ready for review (again) Maybe have a look at .md to see what is supported now |
@fzyzcjy looks amazing, thanks for addressing all the questions!
Thanks for answering, we don't have many people contributing new rules, so I was wondering, if it's something wrong with the flow. |
The only thing missing is the entry in changelog under Now we'll run the rule on different public codebases in order to avoid possible edge-cases. |
You are welcome! Done. |
Codecov Report
@@ Coverage Diff @@
## master #705 +/- ##
==========================================
+ Coverage 86.63% 86.75% +0.11%
==========================================
Files 261 263 +2
Lines 5551 5631 +80
==========================================
+ Hits 4809 4885 +76
- Misses 742 746 +4
Continue to review full report at Codecov.
|
@fzyzcjy thank you for contribute |
You are welcome! |
…#705) * add sccafold for new rule * add scaffold for tests * try to implement the rule * add tests * add toString to debug issues * pass tests * add doc * add more functions in example * refactor visitor to extract more generic info * try to implement containsKey, containsValue, remove * pass tests * add checking `Iterable.contains`, pass tests * revert issue.tostring * run dart format * refactor code * improve doc * try to also check subclasses of map (not finished) * refactor dart_type_utils to avoid duplication * make test passes * minor change to tests * refactor and make tests pass * support List.remove * change doc * support sets * make tests pass * changelog
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix
[x] New rule
[ ] Changes an existing rule
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Close #701
Is there anything you'd like reviewers to focus on?