-
Notifications
You must be signed in to change notification settings - Fork 275
feat: update const border radius rule #482
feat: update const border radius rule #482
Conversation
Codecov Report
@@ Coverage Diff @@
## master #482 +/- ##
==========================================
+ Coverage 83.64% 83.68% +0.04%
==========================================
Files 189 199 +10
Lines 3906 4124 +218
==========================================
+ Hits 3267 3451 +184
- Misses 639 673 +34
Continue to review full report at Codecov.
|
lib/src/analyzers/lint_analyzer/rules/rules_list/prefer_const_border_radius/visitor.dart
Outdated
Show resolved
Hide resolved
incendial
left a comment
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 rule update. Added several small comments.
CHANGELOG.md
Outdated
|
|
||
| ## Unreleased | ||
|
|
||
| * feat: Update static code diagnostic `prefer-const-border-radius`. |
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.
Since we didn't release the rule yet, we don't need to mention the rule change.
| static const ruleId = 'prefer-const-border-radius'; | ||
| static const _issueMessage = 'Prefer use const constructor BorderRadius.all.'; | ||
| static const _issueMessage = | ||
| 'Prefer to use const constructor BorderRadius.all.'; |
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.
Let's have either Prefer using const constructor BorderRadius.all or Prefer const constructor BorderRadius.all.. We don't use to use in any other rule.
|
|
||
| const borderRadiusClassName = 'BorderRadius'; | ||
| const borderRadiusConstConstructorName = 'circular'; | ||
| const borderRadiusConstructorName = 'circular'; |
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.
Please make these variables private.
| @@ -1,47 +1,29 @@ | |||
| const _constRadius = BorderRadius.all(16); | |||
| final _finalRadius = BorderRadius.circular(8); // LINT | |||
| import 'flutter_define.dart'; | |||
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.
Let's keep all the rule code in the example file.
| ClipRRect( | ||
| borderRadius: | ||
| BorderRadius.circular(_constValue - _constValue)), // LINT | ||
| ClipRRect(borderRadius: BorderRadius.circular(_constValue - _finalValue)), |
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.
Could you add test cases for conditional expression as BorderRadius argument and for method invocation as argument?
| startColumns: [22, 31, 31, 31], | ||
| endOffsets: [88, 195, 295, 442], | ||
| startOffsets: [113, 273, 373, 440, 588, 870], | ||
| startLines: [4, 9, 12, 13, 17, 22], |
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.
I see seven // LINT comments and only 6 actual triggers (line 25 doesn't trigger the rule). Please update the test file.
This reverts commit 77dcc80.
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix
[ ] New rule
[x] 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)