dart-decimate 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +572 -0
- package/Cargo.toml +41 -0
- package/LICENSE +21 -0
- package/README.md +617 -0
- package/assets/dart-decimate-banner.png +0 -0
- package/npm/bin/dart-decimate-mcp.js +48 -0
- package/npm/bin/dart-decimate.js +48 -0
- package/npm/scripts/postinstall.js +46 -0
- package/npm/scripts/test-npx-local.js +54 -0
- package/npm/scripts/test-npx-mcp-local.js +56 -0
- package/package.json +45 -0
- package/src/baseline.rs +643 -0
- package/src/bin/dart-decimate-mcp.rs +11 -0
- package/src/boundaries/tests.rs +60 -0
- package/src/boundaries.rs +317 -0
- package/src/changed_scope.rs +117 -0
- package/src/ci_template.rs +399 -0
- package/src/cli/analyze.rs +462 -0
- package/src/cli/analyzer_options.rs +82 -0
- package/src/cli/audit_run.rs +327 -0
- package/src/cli/boundary_args.rs +44 -0
- package/src/cli/ci_template_run.rs +196 -0
- package/src/cli/command_name.rs +20 -0
- package/src/cli/common_args.rs +167 -0
- package/src/cli/config_run.rs +78 -0
- package/src/cli/coverage_run.rs +393 -0
- package/src/cli/decision_surface_run.rs +99 -0
- package/src/cli/default_command.rs +69 -0
- package/src/cli/dupes_args.rs +150 -0
- package/src/cli/entry_points.rs +121 -0
- package/src/cli/error.rs +149 -0
- package/src/cli/error_output.rs +68 -0
- package/src/cli/explain_run.rs +72 -0
- package/src/cli/fix_run.rs +162 -0
- package/src/cli/flags_args.rs +23 -0
- package/src/cli/health_args.rs +200 -0
- package/src/cli/hooks_run.rs +191 -0
- package/src/cli/impact_run.rs +95 -0
- package/src/cli/init_run.rs +49 -0
- package/src/cli/inspect_args.rs +20 -0
- package/src/cli/inspect_run.rs +66 -0
- package/src/cli/issue_filter_args.rs +240 -0
- package/src/cli/list_run.rs +311 -0
- package/src/cli/mode_args.rs +72 -0
- package/src/cli/output_format.rs +62 -0
- package/src/cli/regression_args.rs +156 -0
- package/src/cli/request_args.rs +175 -0
- package/src/cli/schema_commands.rs +72 -0
- package/src/cli/scope_args.rs +174 -0
- package/src/cli/security_args.rs +175 -0
- package/src/cli/security_gate_run.rs +66 -0
- package/src/cli/security_summary_run.rs +43 -0
- package/src/cli/summary_args.rs +12 -0
- package/src/cli/tests.rs +516 -0
- package/src/cli/trace_args.rs +67 -0
- package/src/cli/trace_run.rs +131 -0
- package/src/cli/trace_tests.rs +235 -0
- package/src/cli/unsupported_run.rs +116 -0
- package/src/cli/watch_run.rs +153 -0
- package/src/cli.rs +603 -0
- package/src/config/boundary_config.rs +235 -0
- package/src/config/cache.rs +25 -0
- package/src/config/dependencies.rs +114 -0
- package/src/config/health.rs +237 -0
- package/src/config/jsonc.rs +66 -0
- package/src/config/policy.rs +91 -0
- package/src/config/rule_aliases.rs +487 -0
- package/src/config/rules.rs +339 -0
- package/src/config.rs +635 -0
- package/src/coverage.rs +469 -0
- package/src/dart_parser.rs +673 -0
- package/src/decision_surface.rs +405 -0
- package/src/dependencies/analyze.rs +218 -0
- package/src/dependencies/codegen.rs +118 -0
- package/src/dependencies/discovery.rs +60 -0
- package/src/dependencies/overrides.rs +76 -0
- package/src/dependencies/private_src_imports.rs +32 -0
- package/src/dependencies/pubspec_document.rs +86 -0
- package/src/dependencies/pubspec_entry.rs +96 -0
- package/src/dependencies/tests.rs +544 -0
- package/src/dependencies/usage.rs +33 -0
- package/src/dependencies.rs +553 -0
- package/src/dependency_scripts.rs +91 -0
- package/src/dupes/lex.rs +236 -0
- package/src/dupes/tests.rs +119 -0
- package/src/dupes.rs +625 -0
- package/src/explain.rs +692 -0
- package/src/extract/directives.rs +252 -0
- package/src/extract/error_tests.rs +25 -0
- package/src/extract/members.rs +210 -0
- package/src/extract/primary_constructors.rs +421 -0
- package/src/extract/references.rs +151 -0
- package/src/extract/routes.rs +691 -0
- package/src/extract/signatures.rs +266 -0
- package/src/extract/string_tests.rs +18 -0
- package/src/extract/strings.rs +107 -0
- package/src/extract/tests.rs +697 -0
- package/src/extract.rs +680 -0
- package/src/feature_flags/tests.rs +76 -0
- package/src/feature_flags.rs +453 -0
- package/src/finding_identity.rs +60 -0
- package/src/fix.rs +551 -0
- package/src/generated.rs +53 -0
- package/src/graph/augment_tests.rs +212 -0
- package/src/graph/conditionals.rs +74 -0
- package/src/graph/package_config_tests.rs +100 -0
- package/src/graph/parts.rs +248 -0
- package/src/graph/pubspec_tests.rs +119 -0
- package/src/graph/tests.rs +837 -0
- package/src/graph/uri_tests.rs +102 -0
- package/src/graph.rs +644 -0
- package/src/health/coverage.rs +309 -0
- package/src/health/ownership.rs +175 -0
- package/src/health/runtime_coverage.rs +616 -0
- package/src/health/runtime_intelligence.rs +511 -0
- package/src/health/scores.rs +296 -0
- package/src/health/tests.rs +240 -0
- package/src/health/threshold_types.rs +163 -0
- package/src/health/thresholds.rs +229 -0
- package/src/health/types.rs +636 -0
- package/src/health.rs +597 -0
- package/src/hooks/agent_settings.rs +175 -0
- package/src/hooks/templates.rs +51 -0
- package/src/hooks.rs +569 -0
- package/src/impact.rs +287 -0
- package/src/init.rs +237 -0
- package/src/inspect.rs +142 -0
- package/src/intelligence/tests.rs +232 -0
- package/src/intelligence.rs +305 -0
- package/src/lib.rs +198 -0
- package/src/main.rs +5 -0
- package/src/manifest/mcp.rs +565 -0
- package/src/manifest.rs +552 -0
- package/src/mcp/cli_args/value_args.rs +175 -0
- package/src/mcp/cli_args.rs +658 -0
- package/src/mcp/cli_args_tests.rs +522 -0
- package/src/mcp/code_execute.rs +671 -0
- package/src/mcp/tools.rs +660 -0
- package/src/mcp.rs +325 -0
- package/src/output/audit_risk.rs +135 -0
- package/src/output/dependency_findings.rs +327 -0
- package/src/output/duplication_findings.rs +114 -0
- package/src/output/feature_flag_findings.rs +122 -0
- package/src/output/format.rs +31 -0
- package/src/output/graph_findings.rs +461 -0
- package/src/output/health_findings.rs +612 -0
- package/src/output/human.rs +27 -0
- package/src/output/next_steps.rs +92 -0
- package/src/output/route_findings.rs +76 -0
- package/src/output/runtime_coverage.rs +515 -0
- package/src/output/scope.rs +183 -0
- package/src/output/security_findings.rs +390 -0
- package/src/output/security_sarif.rs +150 -0
- package/src/output/suppressions.rs +323 -0
- package/src/output/symbol_findings.rs +257 -0
- package/src/output/tests.rs +114 -0
- package/src/output/types.rs +604 -0
- package/src/output/widget_findings.rs +213 -0
- package/src/output.rs +682 -0
- package/src/package_map.rs +495 -0
- package/src/policy/packs.rs +232 -0
- package/src/policy/tests.rs +134 -0
- package/src/policy.rs +640 -0
- package/src/project_list.rs +376 -0
- package/src/report_schema/inventory.rs +418 -0
- package/src/report_schema.rs +488 -0
- package/src/routes.rs +354 -0
- package/src/scan/tests.rs +250 -0
- package/src/scan.rs +275 -0
- package/src/security/detect.rs +639 -0
- package/src/security/tests.rs +178 -0
- package/src/security.rs +373 -0
- package/src/security_gate.rs +555 -0
- package/src/symbols/path_filters.rs +27 -0
- package/src/symbols/private_type_leaks.rs +125 -0
- package/src/symbols/riverpod.rs +113 -0
- package/src/symbols/tests.rs +692 -0
- package/src/symbols.rs +693 -0
- package/src/trace/tests.rs +225 -0
- package/src/trace.rs +690 -0
- package/src/unsupported.rs +47 -0
- package/src/widgets/lifecycle.rs +484 -0
- package/src/widgets/params.rs +236 -0
- package/src/widgets/tests.rs +430 -0
- package/src/widgets/top_level.rs +110 -0
- package/src/widgets/unrendered.rs +374 -0
- package/src/widgets.rs +590 -0
- package/src/workspace_scope.rs +358 -0
package/README.md
ADDED
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
# Dart Decimate
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Find dead Dart code, circular dependencies, duplicated code, complex functions,
|
|
6
|
+
dependency problems, risky Flutter wiring, and PR risk fast.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
Dart Decimate is a Rust-native codebase intelligence tool for Dart and Flutter. It
|
|
13
|
+
looks at your repo as a graph:
|
|
14
|
+
|
|
15
|
+
- Dart files are nodes.
|
|
16
|
+
- `import`, `export`, `part`, `part of`, and `library augment` are edges.
|
|
17
|
+
- The report tells you what is unused, risky, duplicated, tangled, or hard to
|
|
18
|
+
maintain.
|
|
19
|
+
|
|
20
|
+
It is not a formatter. It is not a replacement for `dart analyze`. It is not a
|
|
21
|
+
Flutter style guide. It does not enforce opinions like "all providers must use
|
|
22
|
+
Riverpod code generation."
|
|
23
|
+
|
|
24
|
+
It answers practical questions:
|
|
25
|
+
|
|
26
|
+
- What code can probably be deleted?
|
|
27
|
+
- What files depend on each other in a circle?
|
|
28
|
+
- What functions are too complex?
|
|
29
|
+
- What code was copied around?
|
|
30
|
+
- What dependency is unused or missing from `pubspec.yaml`?
|
|
31
|
+
- What changed code is risky before a PR lands?
|
|
32
|
+
- What should an AI coding agent inspect before making a fix?
|
|
33
|
+
|
|
34
|
+
## Start Here
|
|
35
|
+
|
|
36
|
+
Inside any Dart or Flutter project:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
dart-decimate check . --format json --summary | jq .summary
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If you do not want JSON:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
dart-decimate check .
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If the report says `"verdict": "fail"`, Dart Decimate worked. It means it found
|
|
49
|
+
error-level issues. It does not mean the tool crashed.
|
|
50
|
+
|
|
51
|
+
Exit codes:
|
|
52
|
+
|
|
53
|
+
- `0`: no error-level findings
|
|
54
|
+
- `1`: Dart Decimate found issues
|
|
55
|
+
- `2`: command, config, or runtime error
|
|
56
|
+
- `8`: security gate found new review-required candidates
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
From GitHub:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cargo install --git https://github.com/sgaabdu4/dart-decimate
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Cargo installs `dart-decimate` and `dart-decimate-mcp` into `~/.cargo/bin`.
|
|
67
|
+
|
|
68
|
+
Fish:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
fish_add_path ~/.cargo/bin
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Bash or Zsh:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
export PATH="$HOME/.cargo/bin:$PATH"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
From a local checkout:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/sgaabdu4/dart-decimate.git
|
|
84
|
+
cd dart-decimate
|
|
85
|
+
cargo install --path . --force
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then run it in your app:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
cd /path/to/flutter_or_dart_repo
|
|
92
|
+
dart-decimate check . --format json
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## npx
|
|
96
|
+
|
|
97
|
+
The npm package name is `dart-decimate`.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx dart-decimate check . --format json
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
To run the GitHub version directly:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx --yes --package github:sgaabdu4/dart-decimate dart-decimate check . --format json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## What Dart Decimate Looks For
|
|
110
|
+
|
|
111
|
+
### 1. Dead Code
|
|
112
|
+
|
|
113
|
+
Dead code is code that is not reachable from your entry points.
|
|
114
|
+
|
|
115
|
+
Dart Decimate finds:
|
|
116
|
+
|
|
117
|
+
- dead Dart files
|
|
118
|
+
- unused public exports
|
|
119
|
+
- unused type aliases
|
|
120
|
+
- unused enum values
|
|
121
|
+
- unused private class members
|
|
122
|
+
- unrendered Flutter widgets
|
|
123
|
+
- missing entry points
|
|
124
|
+
- stale `dart-decimate-ignore` comments
|
|
125
|
+
|
|
126
|
+
Useful commands:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
dart-decimate dead-code . --entry lib/main.dart --format json
|
|
130
|
+
dart-decimate check . --unused-files --unused-exports --unused-deps --format json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 2. Complex Code
|
|
134
|
+
|
|
135
|
+
Cyclomatic complexity means "how many paths can this function take?"
|
|
136
|
+
|
|
137
|
+
Cognitive complexity means "how hard is this function to understand?"
|
|
138
|
+
|
|
139
|
+
CRAP score combines complexity with test coverage. A complex function with poor
|
|
140
|
+
coverage gets a worse score.
|
|
141
|
+
|
|
142
|
+
Dart Decimate finds:
|
|
143
|
+
|
|
144
|
+
- high cyclomatic complexity
|
|
145
|
+
- high cognitive complexity
|
|
146
|
+
- high combined complexity
|
|
147
|
+
- high CRAP score
|
|
148
|
+
- coverage gaps
|
|
149
|
+
- low health score files
|
|
150
|
+
- hotspots
|
|
151
|
+
- refactoring targets
|
|
152
|
+
|
|
153
|
+
Useful commands:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
dart-decimate health . --format json
|
|
157
|
+
dart-decimate health . --complexity-breakdown --top 10 --format json
|
|
158
|
+
dart-decimate health . --file-scores --hotspots --targets --format json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 3. Duplicated Code
|
|
162
|
+
|
|
163
|
+
Duplication means the same Dart code appears in more than one place.
|
|
164
|
+
|
|
165
|
+
Dart Decimate finds exact and semantic clone groups. Each clone group gets a stable
|
|
166
|
+
fingerprint like `dup:abc12345`, so agents can trace it before touching code.
|
|
167
|
+
|
|
168
|
+
Useful commands:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
dart-decimate dupes . --format json
|
|
172
|
+
dart-decimate dupes . --mode semantic --min-lines 5 --format json
|
|
173
|
+
dart-decimate dupes . --threshold 5 --format json
|
|
174
|
+
dart-decimate trace-clone . --fingerprint dup:abc12345 --format json
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 4. Circular Dependencies
|
|
178
|
+
|
|
179
|
+
A circular dependency means file A depends on file B, and B eventually depends
|
|
180
|
+
back on A. Cycles make code harder to move, test, and delete.
|
|
181
|
+
|
|
182
|
+
Dart Decimate finds:
|
|
183
|
+
|
|
184
|
+
- circular dependencies
|
|
185
|
+
- re-export cycles
|
|
186
|
+
- import/export/part/augment targets that do not resolve
|
|
187
|
+
- invalid `part` / `part of` relationships
|
|
188
|
+
|
|
189
|
+
Useful commands:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
dart-decimate cycles . --format json
|
|
193
|
+
dart-decimate check . --circular-deps --re-export-cycles --format json
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 5. Architecture Drift
|
|
197
|
+
|
|
198
|
+
Architecture drift means code crosses boundaries it should not cross.
|
|
199
|
+
|
|
200
|
+
Example: `lib/domain/` depending on `lib/ui/`.
|
|
201
|
+
|
|
202
|
+
Dart Decimate finds:
|
|
203
|
+
|
|
204
|
+
- boundary violations
|
|
205
|
+
- files outside configured boundary zones
|
|
206
|
+
- forbidden direct calls across boundaries
|
|
207
|
+
- policy-pack violations for banned imports, exports, and calls
|
|
208
|
+
|
|
209
|
+
Useful command:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
dart-decimate check . \
|
|
213
|
+
--boundary lib/domain:lib/ui \
|
|
214
|
+
--boundary-coverage \
|
|
215
|
+
--format json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 6. Dependency Hygiene
|
|
219
|
+
|
|
220
|
+
Dependency hygiene means your imports and `pubspec.yaml` agree.
|
|
221
|
+
|
|
222
|
+
Dart Decimate finds:
|
|
223
|
+
|
|
224
|
+
- unused runtime dependencies
|
|
225
|
+
- unused dev dependencies
|
|
226
|
+
- runtime dependencies used only by tests
|
|
227
|
+
- imports missing from `pubspec.yaml`
|
|
228
|
+
- unused dependency overrides
|
|
229
|
+
- invalid dependency overrides
|
|
230
|
+
- imports into another package's private `lib/src`
|
|
231
|
+
- duplicate public API exports
|
|
232
|
+
|
|
233
|
+
Useful commands:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
dart-decimate trace-dependency . --dependency collection --format json
|
|
237
|
+
dart-decimate check . --unused-deps --unlisted-deps --private-src-imports --format json
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 7. Flutter-Specific Graph Issues
|
|
241
|
+
|
|
242
|
+
Dart Decimate does not care which state-management style you use. It uses Flutter
|
|
243
|
+
and Dart patterns only to avoid false positives and to find graph problems.
|
|
244
|
+
|
|
245
|
+
Dart Decimate finds:
|
|
246
|
+
|
|
247
|
+
- GoRouter route path/name collisions
|
|
248
|
+
- private Flutter widget classes
|
|
249
|
+
- top-level widget helper functions
|
|
250
|
+
- unused widget constructor parameters
|
|
251
|
+
- widget classes that are never constructed
|
|
252
|
+
- missing `context.mounted` guards after awaited widget work
|
|
253
|
+
|
|
254
|
+
### 8. Security Candidates
|
|
255
|
+
|
|
256
|
+
These are review prompts, not proof of an exploit.
|
|
257
|
+
|
|
258
|
+
Dart Decimate finds candidates for:
|
|
259
|
+
|
|
260
|
+
- hardcoded secrets
|
|
261
|
+
- insecure HTTP transport
|
|
262
|
+
- TLS validation bypasses
|
|
263
|
+
- risky WebView settings
|
|
264
|
+
- process execution
|
|
265
|
+
- raw SQL
|
|
266
|
+
- plain local storage of secret-like material
|
|
267
|
+
|
|
268
|
+
Useful commands:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
dart-decimate security . --surface --format json
|
|
272
|
+
dart-decimate security . --ci --sarif-file dart-decimate-security.sarif
|
|
273
|
+
git diff --cached --unified=0 | dart-decimate security . --gate new --diff-stdin --format json
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 9. PR Risk
|
|
277
|
+
|
|
278
|
+
Use this before merging changed code.
|
|
279
|
+
|
|
280
|
+
Dart Decimate reports:
|
|
281
|
+
|
|
282
|
+
- risk score
|
|
283
|
+
- pass / warn / fail risk level
|
|
284
|
+
- findings introduced by the PR
|
|
285
|
+
- findings that already existed
|
|
286
|
+
- risky changed files
|
|
287
|
+
|
|
288
|
+
Useful commands:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
dart-decimate audit . --base origin/main --format json
|
|
292
|
+
dart-decimate audit . --base origin/main --gate new-only --format json
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 10. Runtime Intelligence
|
|
296
|
+
|
|
297
|
+
Static analysis says what is connected. Runtime coverage says what actually ran.
|
|
298
|
+
|
|
299
|
+
Dart Decimate can read LCOV, V8, and Istanbul coverage data.
|
|
300
|
+
|
|
301
|
+
Useful commands:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
dart-decimate health . --coverage coverage/lcov.info --coverage-gaps --max-crap 30 --format json
|
|
305
|
+
dart-decimate coverage analyze . --runtime-coverage coverage-final.json --format json
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## How To Read The Summary
|
|
309
|
+
|
|
310
|
+
Example:
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"files": 466,
|
|
315
|
+
"edges": 1231,
|
|
316
|
+
"quality_score": 93,
|
|
317
|
+
"cycles": 2,
|
|
318
|
+
"code_duplications": 26,
|
|
319
|
+
"complex_functions": 13,
|
|
320
|
+
"dead_files": 11,
|
|
321
|
+
"findings": 125
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Plain English:
|
|
326
|
+
|
|
327
|
+
- `files`: Dart files Dart Decimate parsed
|
|
328
|
+
- `edges`: imports, exports, parts, and augments it resolved
|
|
329
|
+
- `quality_score`: project health from `0` to `100`
|
|
330
|
+
- `cycles`: circular dependency groups
|
|
331
|
+
- `code_duplications`: duplicated code groups
|
|
332
|
+
- `complex_functions`: functions over the complexity limits
|
|
333
|
+
- `dead_files`: files Dart Decimate thinks are unreachable
|
|
334
|
+
- `findings`: total issues in the report
|
|
335
|
+
|
|
336
|
+
## JSON For Agents
|
|
337
|
+
|
|
338
|
+
Use JSON when another tool or AI agent will read the result:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
dart-decimate check . --format json
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Every finding includes:
|
|
345
|
+
|
|
346
|
+
- `rule_id`
|
|
347
|
+
- `kind`
|
|
348
|
+
- `severity`
|
|
349
|
+
- `path`
|
|
350
|
+
- `line`
|
|
351
|
+
- `column`
|
|
352
|
+
- `safe_to_delete`
|
|
353
|
+
- related `files`
|
|
354
|
+
- suggested `actions`
|
|
355
|
+
|
|
356
|
+
Example shape:
|
|
357
|
+
|
|
358
|
+
```json
|
|
359
|
+
{
|
|
360
|
+
"schema_version": "dart-decimate.report.v1",
|
|
361
|
+
"kind": "combined",
|
|
362
|
+
"tool": "dart-decimate",
|
|
363
|
+
"command": "check",
|
|
364
|
+
"verdict": "fail",
|
|
365
|
+
"summary": {
|
|
366
|
+
"files": 466,
|
|
367
|
+
"edges": 1231,
|
|
368
|
+
"quality_score": 93,
|
|
369
|
+
"findings": 125
|
|
370
|
+
},
|
|
371
|
+
"findings": [],
|
|
372
|
+
"next_steps": []
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
If a JSON command fails before a report can be built, stdout still stays
|
|
377
|
+
machine-readable:
|
|
378
|
+
|
|
379
|
+
```json
|
|
380
|
+
{ "error": true, "message": "coverage analyze requires --runtime-coverage PATH", "exit_code": 2 }
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Fixes
|
|
384
|
+
|
|
385
|
+
Preview safe fixes:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
dart-decimate fix . --format json
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Apply confirmed safe fixes:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
dart-decimate fix . --apply --confirm --format json
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Safe fixes are intentionally conservative. Dart Decimate can currently apply:
|
|
398
|
+
|
|
399
|
+
- simple dead-file deletion
|
|
400
|
+
- stale suppression removal
|
|
401
|
+
- one-line unused Pub dependency removal
|
|
402
|
+
- one-line unused top-level Dart declaration removal
|
|
403
|
+
|
|
404
|
+
Everything else stays review-only.
|
|
405
|
+
|
|
406
|
+
## Watch Mode
|
|
407
|
+
|
|
408
|
+
Rerun checks while you work:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
dart-decimate watch . --no-clear
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Run once and exit, useful for scripts:
|
|
415
|
+
|
|
416
|
+
```bash
|
|
417
|
+
dart-decimate watch . --once --format json
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## MCP
|
|
421
|
+
|
|
422
|
+
Start the MCP server:
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
dart-decimate-mcp
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Agents can use it to inspect a project, trace files, trace symbols, inspect
|
|
429
|
+
duplicates, review PR risk, read runtime coverage slices, preview fixes, and
|
|
430
|
+
ask what is safest to do next.
|
|
431
|
+
|
|
432
|
+
`fix_apply` is the only mutating MCP tool and requires explicit `yes: true`.
|
|
433
|
+
|
|
434
|
+
## Config
|
|
435
|
+
|
|
436
|
+
Dart Decimate reads config from:
|
|
437
|
+
|
|
438
|
+
1. `.dart-decimaterc`
|
|
439
|
+
2. `.dart-decimaterc.json`
|
|
440
|
+
3. `.dart-decimaterc.jsonc`
|
|
441
|
+
4. `dart-decimate.toml`
|
|
442
|
+
5. `.dart-decimate.toml`
|
|
443
|
+
|
|
444
|
+
Example:
|
|
445
|
+
|
|
446
|
+
```toml
|
|
447
|
+
[cli]
|
|
448
|
+
format = "json"
|
|
449
|
+
entry = ["lib/main.dart"]
|
|
450
|
+
production = true
|
|
451
|
+
|
|
452
|
+
[health]
|
|
453
|
+
max_cyclomatic = 20
|
|
454
|
+
max_cognitive = 15
|
|
455
|
+
coverage_gaps = true
|
|
456
|
+
fileScores = true
|
|
457
|
+
hotspots = true
|
|
458
|
+
targets = true
|
|
459
|
+
|
|
460
|
+
[dupes]
|
|
461
|
+
mode = "semantic"
|
|
462
|
+
min_tokens = 80
|
|
463
|
+
threshold = 5
|
|
464
|
+
|
|
465
|
+
[boundaries]
|
|
466
|
+
presets = ["layered"]
|
|
467
|
+
rules = ["lib/domain:lib/ui"]
|
|
468
|
+
|
|
469
|
+
[security]
|
|
470
|
+
surface = true
|
|
471
|
+
categories = ["hardcoded-secret", "insecure-transport", "tls-bypass"]
|
|
472
|
+
|
|
473
|
+
[rules]
|
|
474
|
+
unused-files = "error"
|
|
475
|
+
unused-exports = "warn"
|
|
476
|
+
security-candidate = "warn"
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Full Issue List
|
|
480
|
+
|
|
481
|
+
Run this for the live list:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
dart-decimate schema --format json | jq .issue_types
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Current issue types:
|
|
488
|
+
|
|
489
|
+
```text
|
|
490
|
+
dead-file
|
|
491
|
+
unused-export
|
|
492
|
+
unused-type
|
|
493
|
+
private-type-leak
|
|
494
|
+
unused-enum-member
|
|
495
|
+
unused-class-member
|
|
496
|
+
duplicate-export
|
|
497
|
+
route-collision
|
|
498
|
+
private-widget-class
|
|
499
|
+
widget-top-level-function-boundary
|
|
500
|
+
unused-widget-param
|
|
501
|
+
unrendered-widget
|
|
502
|
+
missing-context-mounted-after-await
|
|
503
|
+
missing-entry-point
|
|
504
|
+
circular-dependency
|
|
505
|
+
re-export-cycle
|
|
506
|
+
boundary-violation
|
|
507
|
+
boundary-coverage
|
|
508
|
+
boundary-call-violation
|
|
509
|
+
policy-violation
|
|
510
|
+
unresolved-dependency
|
|
511
|
+
part-of-violation
|
|
512
|
+
unused-dependency
|
|
513
|
+
unused-dev-dependency
|
|
514
|
+
test-only-dependency
|
|
515
|
+
unused-dependency-override
|
|
516
|
+
misconfigured-dependency-override
|
|
517
|
+
unlisted-dependency
|
|
518
|
+
private-src-import
|
|
519
|
+
code-duplication
|
|
520
|
+
high-cyclomatic-complexity
|
|
521
|
+
high-cognitive-complexity
|
|
522
|
+
high-complexity
|
|
523
|
+
coverage-gap
|
|
524
|
+
high-crap-score
|
|
525
|
+
health-hotspot
|
|
526
|
+
refactoring-target
|
|
527
|
+
feature-flag
|
|
528
|
+
security-candidate
|
|
529
|
+
stale-suppression
|
|
530
|
+
missing-suppression-reason
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## CI
|
|
534
|
+
|
|
535
|
+
Use this in CI to review only changed code:
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
dart-decimate audit . --base origin/main --format json --fail-on-regression
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
This repository already runs:
|
|
542
|
+
|
|
543
|
+
- Rust format, clippy, and tests
|
|
544
|
+
- npm package checks
|
|
545
|
+
- version sync between `Cargo.toml` and `package.json`
|
|
546
|
+
- a release-version gate so published versions cannot be reused
|
|
547
|
+
- migration checks that block previous package, command, schema, and MCP names
|
|
548
|
+
- Dependabot and weekly dependency/security audits
|
|
549
|
+
|
|
550
|
+
Generate CI templates:
|
|
551
|
+
|
|
552
|
+
```bash
|
|
553
|
+
dart-decimate ci-template github --format yaml
|
|
554
|
+
dart-decimate ci-template gitlab --format yaml
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Preview review-thread reconciliation without changing GitHub or GitLab:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
dart-decimate ci reconcile-review \
|
|
561
|
+
--provider github \
|
|
562
|
+
--repo owner/repo \
|
|
563
|
+
--pr 123 \
|
|
564
|
+
--envelope review-github.json \
|
|
565
|
+
--dry-run \
|
|
566
|
+
--format json
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
## Scope
|
|
570
|
+
|
|
571
|
+
Dart Decimate implements local Fallow-style codebase intelligence for Dart and
|
|
572
|
+
Flutter.
|
|
573
|
+
|
|
574
|
+
Fallow features that are JS-specific or require hosted backends return clear
|
|
575
|
+
unsupported JSON instead of pretending to work:
|
|
576
|
+
|
|
577
|
+
```bash
|
|
578
|
+
dart-decimate migrate --dry-run --format json
|
|
579
|
+
dart-decimate telemetry status --format json
|
|
580
|
+
dart-decimate license status --format json
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
## Development
|
|
584
|
+
|
|
585
|
+
```bash
|
|
586
|
+
cargo fmt --check
|
|
587
|
+
cargo clippy --all-targets -- -D warnings
|
|
588
|
+
cargo test --all-targets
|
|
589
|
+
npm run version:check
|
|
590
|
+
npm run release:check
|
|
591
|
+
npm run migration:check
|
|
592
|
+
npm run pack:check
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
This repository forbids `unsafe_code`.
|
|
596
|
+
|
|
597
|
+
## Release Flow
|
|
598
|
+
|
|
599
|
+
Current version: `0.0.1`.
|
|
600
|
+
|
|
601
|
+
After the first public release, changes should go through pull requests.
|
|
602
|
+
|
|
603
|
+
To release a new version:
|
|
604
|
+
|
|
605
|
+
1. Update both `Cargo.toml` and `package.json`.
|
|
606
|
+
2. Open a PR.
|
|
607
|
+
3. Let CI pass.
|
|
608
|
+
4. Merge to `main`.
|
|
609
|
+
5. GitHub Actions publishes `dart-decimate` to npm, creates tag `vX.Y.Z`, and
|
|
610
|
+
creates the GitHub release.
|
|
611
|
+
|
|
612
|
+
Local hooks block stale package names, mismatched versions, reused npm versions,
|
|
613
|
+
and direct pushes to `main`.
|
|
614
|
+
|
|
615
|
+
## License
|
|
616
|
+
|
|
617
|
+
Licensed under the MIT License. See [LICENSE](LICENSE).
|
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const root = path.resolve(__dirname, "../..");
|
|
8
|
+
const exeName = process.platform === "win32" ? "dart-decimate-mcp.exe" : "dart-decimate-mcp";
|
|
9
|
+
const cachedBinary = path.join(root, "npm", "bin-cache", exeName);
|
|
10
|
+
const releaseBinary = path.join(root, "target", "release", exeName);
|
|
11
|
+
const debugBinary = path.join(root, "target", "debug", exeName);
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
for (const candidate of [cachedBinary, releaseBinary, debugBinary]) {
|
|
15
|
+
if (fs.existsSync(candidate)) {
|
|
16
|
+
run(candidate, args);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cargo = process.env.CARGO || "cargo";
|
|
21
|
+
run(cargo, ["run", "--release", "--locked", "--bin", "dart-decimate-mcp", "--", ...args], root);
|
|
22
|
+
|
|
23
|
+
function run(command, commandArgs, cwd = undefined) {
|
|
24
|
+
const result = spawnSync(command, commandArgs, {
|
|
25
|
+
cwd,
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
windowsHide: false
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (result.error) {
|
|
31
|
+
if (result.error.code === "ENOENT") {
|
|
32
|
+
console.error(
|
|
33
|
+
"dart-decimate-mcp: Rust/Cargo is required to build the npm source package. " +
|
|
34
|
+
"Install Rust from https://rustup.rs or use a release package with a prebuilt binary."
|
|
35
|
+
);
|
|
36
|
+
process.exit(127);
|
|
37
|
+
}
|
|
38
|
+
console.error(`dart-decimate-mcp: failed to execute ${command}: ${result.error.message}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (result.signal) {
|
|
43
|
+
process.kill(process.pid, result.signal);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
process.exit(result.status ?? 1);
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require("node:child_process");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
|
|
7
|
+
const root = path.resolve(__dirname, "../..");
|
|
8
|
+
const exeName = process.platform === "win32" ? "dart-decimate.exe" : "dart-decimate";
|
|
9
|
+
const cachedBinary = path.join(root, "npm", "bin-cache", exeName);
|
|
10
|
+
const releaseBinary = path.join(root, "target", "release", exeName);
|
|
11
|
+
const debugBinary = path.join(root, "target", "debug", exeName);
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
for (const candidate of [cachedBinary, releaseBinary, debugBinary]) {
|
|
15
|
+
if (fs.existsSync(candidate)) {
|
|
16
|
+
run(candidate, args);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cargo = process.env.CARGO || "cargo";
|
|
21
|
+
run(cargo, ["run", "--release", "--locked", "--bin", "dart-decimate", "--", ...args], root);
|
|
22
|
+
|
|
23
|
+
function run(command, commandArgs, cwd = undefined) {
|
|
24
|
+
const result = spawnSync(command, commandArgs, {
|
|
25
|
+
cwd,
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
windowsHide: false
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (result.error) {
|
|
31
|
+
if (result.error.code === "ENOENT") {
|
|
32
|
+
console.error(
|
|
33
|
+
"dart-decimate: Rust/Cargo is required to build the npm source package. " +
|
|
34
|
+
"Install Rust from https://rustup.rs or use a release package with a prebuilt binary."
|
|
35
|
+
);
|
|
36
|
+
process.exit(127);
|
|
37
|
+
}
|
|
38
|
+
console.error(`dart-decimate: failed to execute ${command}: ${result.error.message}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (result.signal) {
|
|
43
|
+
process.kill(process.pid, result.signal);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
process.exit(result.status ?? 1);
|
|
48
|
+
}
|