Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Conversation

@grafovdenis
Copy link
Contributor

@grafovdenis grafovdenis commented Sep 30, 2021

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)

  • Update doc
  • Update test example
  • Update test
  • Update rule visitor

@grafovdenis grafovdenis changed the title Update const border radius rule feat: update const border radius rule Sep 30, 2021
@codecov
Copy link

codecov bot commented Sep 30, 2021

Codecov Report

Merging #482 (6f97a03) into master (69678b6) will increase coverage by 0.04%.
The diff coverage is 86.47%.

❗ Current head 6f97a03 differs from pull request most recent head f472a80. Consider uploading reports for the commit f472a80 to get more accurate results
Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
...onst_border_radius/prefer_const_border_radius.dart 100.00% <ø> (ø)
lib/src/cli/commands/check_unused_l10n.dart 57.14% <57.14%> (ø)
lib/src/analyzers/lint_analyzer/lint_analyzer.dart 91.74% <66.66%> (-1.84%) ⬇️
lib/src/config_builder/config_builder.dart 81.81% <77.77%> (-1.52%) ⬇️
...yzers/unused_l10n_analyzer/unused_l10n_config.dart 81.81% <81.81%> (ø)
...ers/unused_l10n_analyzer/unused_l10n_analyzer.dart 86.58% <86.58%> (ø)
...zers/unused_l10n_analyzer/unused_l10n_visitor.dart 90.90% <90.90%> (ø)
...ics/metrics_list/maintainability_index_metric.dart 100.00% <100.00%> (ø)
...rics/metrics_list/number_of_parameters_metric.dart 100.00% <100.00%> (ø)
...list/source_lines_of_code/source_code_visitor.dart 100.00% <100.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69678b6...f472a80. Read the comment docs.

Copy link
Member

@incendial incendial left a 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`.
Copy link
Member

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.';
Copy link
Member

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';
Copy link
Member

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';
Copy link
Member

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)),
Copy link
Member

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],
Copy link
Member

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.

@incendial incendial added the type: enhancement New feature or request label Oct 3, 2021
@incendial incendial added this to the 4.4.0 milestone Oct 3, 2021
@grafovdenis grafovdenis requested a review from incendial October 4, 2021 07:38
@dkrutskikh dkrutskikh merged commit 624874f into dart-code-checker:master Oct 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants