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

Commit c6f22ae

Browse files
committed
docs: update readme
1 parent 860d0ce commit c6f22ae

9 files changed

+50
-29
lines changed

README.md

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
align="right">
3030
</a>
3131

32-
DCM is a static analysis tool that helps you analyse and improve your code quality.
32+
DCM is a toolkit that helps you identify and fix problems in your Dart and Flutter code. These problems can range from potential runtime bugs and violations of best practices to styling issues. DCM includes over 70 built-in rules to validate your code against various expectations, and you can customize these rules to fit your specific needs.
3333

3434
- Reports [code metrics](https://dcm.dev/docs/individuals/metrics)
3535
- Provides [additional rules](https://dcm.dev/docs/individuals/rules) for the dart analyzer
3636
- Checks for [anti-patterns](https://dcm.dev/docs/individuals/anti-patterns)
3737
- Checks [unused `*.dart` files](https://dcm.dev/docs/individuals/cli/check-unused-files)
3838
- Checks [unused l10n](https://dcm.dev/docs/individuals/cli/check-unused-l10n)
3939
- Checks [unnecessary nullable parameters](https://dcm.dev/docs/individuals/cli/check-unnecessary-nullable)
40-
- Can be used as [CLI](https://dcm.dev/docs/individuals/cli), [analyzer plugin](https://dcm.dev/docs/individuals/analyzer-plugin) or [library](https://dcm.dev/docs/individuals/getting-started/#library)
40+
- Can be used as [CLI](https://dcm.dev/docs/individuals/cli) and the [analyzer plugin](https://dcm.dev/docs/individuals/analyzer-plugin)
4141

4242
## Links
4343

@@ -54,64 +54,83 @@ $ dart pub add --dev dart_code_metrics
5454
$ flutter pub add --dev dart_code_metrics
5555
```
5656

57-
## OR
57+
## Basic configuration
5858

59-
add it manually to `pubspec.yaml`
59+
Add configuration to `analysis_options.yaml` and reload IDE to allow the analyzer to discover the plugin config.
6060

61-
```yaml
62-
dev_dependencies:
63-
dart_code_metrics: ^5.5.1
64-
```
61+
You can read more about the configuration [on the website](https://dcm.dev/docs/individuals/configuration).
6562

66-
and then run
63+
### Basic config example
6764

68-
```sh
69-
$ dart pub get
65+
```yaml title="analysis_options.yaml"
66+
analyzer:
67+
plugins:
68+
- dart_code_metrics
7069

71-
# or for a Flutter package
72-
$ flutter pub get
70+
dart_code_metrics:
71+
rules:
72+
- avoid-dynamic
73+
- avoid-redundant-async
74+
- avoid-passing-async-when-sync-expected
75+
- avoid-redundant-async
76+
- avoid-unnecessary-type-assertions
77+
- avoid-unnecessary-type-casts
78+
- avoid-unrelated-type-assertions
79+
- avoid-unused-parameters
80+
- avoid-nested-conditional-expressions
81+
- newline-before-return
82+
- no-boolean-literal-compare
83+
- no-empty-block
84+
- prefer-trailing-comma
85+
- prefer-conditional-expressions
86+
- no-equal-then-else
87+
- prefer-moving-to-variable
88+
- prefer-match-file-name
7389
```
7490
75-
## Basic configuration
91+
### Basic config with metrics
7692
77-
Add configuration to `analysis_options.yaml`
93+
```yaml title="analysis_options.yaml"
94+
analyzer:
95+
plugins:
96+
- dart_code_metrics
7897

79-
```yaml
8098
dart_code_metrics:
81-
anti-patterns:
82-
- long-method
83-
- long-parameter-list
8499
metrics:
85100
cyclomatic-complexity: 20
86-
maximum-nesting-level: 5
87101
number-of-parameters: 4
88-
source-lines-of-code: 50
102+
maximum-nesting-level: 5
89103
metrics-exclude:
90104
- test/**
91105
rules:
106+
- avoid-dynamic
107+
- avoid-redundant-async
108+
- avoid-passing-async-when-sync-expected
109+
- avoid-redundant-async
110+
- avoid-unnecessary-type-assertions
111+
- avoid-unnecessary-type-casts
112+
- avoid-unrelated-type-assertions
113+
- avoid-unused-parameters
114+
- avoid-nested-conditional-expressions
92115
- newline-before-return
93116
- no-boolean-literal-compare
94117
- no-empty-block
95118
- prefer-trailing-comma
96119
- prefer-conditional-expressions
97120
- no-equal-then-else
121+
- prefer-moving-to-variable
122+
- prefer-match-file-name
98123
```
99124
100-
Reload IDE to allow the analyzer to discover the plugin config.
101-
102-
You can read more about the configuration [on the website](https://dcm.dev/docs/individuals/configuration).
103-
104125
## Usage
105126
106127
### Analyzer plugin
107128
108129
DCM can be used as a plugin for the Dart `analyzer` [package](https://pub.dev/packages/analyzer) providing additional rules. All issues produced by rules or anti-patterns will be highlighted in IDE.
109130

110-
![Highlighted issue example](https://raw.githubusercontent.com/dart-code-checker/dart-code-metrics/master/assets/plugin-example.png)
111-
112-
Rules that marked with a `has auto-fix` badge have auto-fixes available through the IDE context menu. VS Code example:
131+
Rules that marked with 🛠 have auto-fixes available through the IDE context menu. VS Code example:
113132

114-
![VS Code example](https://raw.githubusercontent.com/dart-code-checker/dart-code-metrics/master/assets/quick-fix.gif)
133+
![VS Code example](https://raw.githubusercontent.com/dart-code-checker/dart-code-metrics/master/assets/quick-fixes.png)
115134

116135
### CLI
117136

@@ -261,6 +280,8 @@ If you are interested in contributing, please check out the [contribution guidel
261280

262281
### En
263282

283+
- [What’s new in DCM for Teams 1.1.0](https://medium.com/@incendial/whats-new-in-dcm-for-teams-1-1-0-501fd6223b0)
284+
- [Announcing DCM for Teams](https://incendial.medium.com/announcing-dcm-for-teams-84db2cffce99)
264285
- [Finding Unused Files With DCM](https://medium.com/wriketechclub/finding-unused-files-with-dart-code-metrics-b9aba48ad7ca) - This article considers one of the first commands, checking unused Dart files, by [Dmitry Zhifarsky](https://github.com/incendial)
265286
- [Improving Code Quality With DCM](https://medium.com/wriketechclub/improving-code-quality-with-dart-code-metrics-430a5e3e316d) - Advantages of using DCM, by [Dmitry Zhifarsky](https://github.com/incendial)
266287
- [Creating a Custom Plugin for Dart Analyzer](https://medium.com/wriketechclub/creating-a-custom-plugin-for-dart-analyzer-48b76d81a239) - How to develop a custom Dart code analyzer plugin, by [Dmitry Zhifarsky](https://github.com/incendial)

assets/analyze-console-report.png

-444 KB
Loading

assets/plugin-example.png

-95.5 KB
Binary file not shown.

assets/quick-fix.gif

-322 KB
Binary file not shown.

assets/quick-fixes.png

257 KB
Loading
-142 KB
Loading

assets/unused-code-console-report.png

-33.1 KB
Loading
16.6 KB
Loading

assets/unused-l10n-console-report.png

50.9 KB
Loading

0 commit comments

Comments
 (0)