Skip to content

Commit 136cd48

Browse files
Illia Romanenkosolid-yuriiprykhodko
andauthored
add more useful rules (#7)
* add more useful rules migrate to dcm 4.9 * Added test runner and clarification about issues with running DCM checks * Update README.md to make run commands simpler Co-authored-by: Yuri Prykhodko <[email protected]> * Improved wording thanks to @solid-yuriiprykhodko! Co-authored-by: Yuri Prykhodko <[email protected]>
1 parent 5dc6e67 commit 136cd48

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ Then you can see suggestions in your IDE or you can run checks manually:
2929

3030
```bash
3131
dart analyze;
32-
dart run dart_code_metrics:metrics analyze lib;
33-
dart run dart_code_metrics:metrics check-unused-files lib;
34-
dart run dart_code_metrics:metrics check-unused-l10n lib;
32+
dart run dart_code_metrics:metrics analyze lib test;
33+
dart run dart_code_metrics:metrics check-unused-files lib test;
34+
dart run dart_code_metrics:metrics check-unused-l10n lib test;
3535
3636
```
37+
Beware that some of the `dart_code_metrics` checks are not displayed in IDE so running checks
38+
manually or in your actions (CI) is essential.
3739

3840
Learn more: https://github.com/dart-code-checker/dart-code-metrics#cli
3941
# Badge

example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ environment:
66
sdk: '>=2.14.4 <3.0.0'
77

88
dev_dependencies:
9-
dart_code_metrics: ^4.8.0
109
solid_lints:
1110
path: ../
1211
test: ^1.20.1

lib/analysis_options.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,31 @@ dart_code_metrics:
3030
# We use source-lines-of-code instead of this as we don't want to count comment or blank lines.
3131
# lines-of-code: 50
3232
rules:
33+
- avoid-global-state
3334
- avoid-late-keyword
3435
- avoid-non-null-assertion
3536
- avoid-returning-widgets
3637
- avoid-unnecessary-setstate
38+
- avoid-unnecessary-type-assertions
39+
- avoid-unnecessary-type-casts
40+
- avoid-unrelated-type-assertions
41+
- avoid-unused-parameters
42+
- double-literal-format
43+
- member-ordering-extended:
44+
order:
45+
- fields
46+
- getters-setters
47+
- constructors
48+
- methods
3749
- newline-before-return
50+
- no-empty-block
51+
- no-equal-then-else
3852
- no-magic-number
53+
- prefer-conditional-expressions
54+
- prefer-first
55+
- prefer-last
56+
# This improves navigation by matching file content and file name.
57+
- prefer-match-file-name
3958
anti-patterns:
4059
- long-method
4160
- long-parameter-list

lib/analysis_options_test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ dart_code_metrics:
4848
# many places inside the test code, adding uninformative visual noise.
4949
# - The use of this operator is also discouraged by the main ruleset.
5050
avoid-late-keyword: false
51+
# It's acceptable to include stubs or other helper classes into the test file.
52+
prefer-match-file-name: false
5153
anti-patterns:
5254
# Same as for `source-lines-of-code`
5355
long-method: false

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ environment:
77
sdk: '>=2.14.4 <3.0.0'
88

99
dependencies:
10-
dart_code_metrics: ^4.8.0
10+
dart_code_metrics: ^4.9.0

0 commit comments

Comments
 (0)