dart-decimate 0.0.43 → 0.0.44
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 +1 -1
- package/Cargo.toml +1 -1
- package/README.md +67 -56
- package/npm/scripts/test-release-install-parity.js +237 -0
- package/package.json +2 -1
- package/src/baseline.rs +5 -1
- package/src/ci_template.rs +7 -19
- package/src/cli/common_args.rs +8 -0
- package/src/cli/dupes_args.rs +1 -0
- package/src/cli/fix_run.rs +1 -0
- package/src/cli/list_run.rs +1 -0
- package/src/cli/security_summary_run.rs +15 -7
- package/src/cli.rs +56 -2
- package/src/config/rules.rs +9 -7
- package/src/dupes/tests.rs +6 -0
- package/src/dupes.rs +20 -7
- package/src/lib.rs +5 -0
- package/src/manifest/mcp.rs +7 -0
- package/src/manifest.rs +8 -8
- package/src/mcp/cli_args.rs +22 -6
- package/src/mcp/cli_args_tests.rs +2 -0
- package/src/mcp/tools.rs +7 -0
- package/src/output/scope.rs +24 -0
- package/src/output.rs +39 -3
- package/src/report_schema.rs +4 -1
package/src/cli.rs
CHANGED
|
@@ -153,6 +153,7 @@ struct CommandRequest {
|
|
|
153
153
|
save_regression_baseline: Option<PathBuf>,
|
|
154
154
|
regression_tolerance: RegressionTolerance,
|
|
155
155
|
fail_on_regression: bool,
|
|
156
|
+
finding_gate: FindingGate,
|
|
156
157
|
trace_file: Option<PathBuf>,
|
|
157
158
|
trace_symbol: Option<TraceSymbolSpec>,
|
|
158
159
|
trace_dependency: Option<String>,
|
|
@@ -174,6 +175,13 @@ struct SymbolRequestOptions {
|
|
|
174
175
|
private_type_leaks: bool,
|
|
175
176
|
}
|
|
176
177
|
|
|
178
|
+
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
|
179
|
+
enum FindingGate {
|
|
180
|
+
#[default]
|
|
181
|
+
ErrorsOnly,
|
|
182
|
+
All,
|
|
183
|
+
}
|
|
184
|
+
|
|
177
185
|
impl CommandRequest {
|
|
178
186
|
fn entry_point_mode(&self) -> entry_points::EntryPointMode {
|
|
179
187
|
mode_args::production_mode(self.production)
|
|
@@ -279,8 +287,18 @@ fn run_request<W: Write>(request: &CommandRequest, mut writer: W) -> Result<i32,
|
|
|
279
287
|
}
|
|
280
288
|
security_summary_run::apply_security_summary(request, &mut report);
|
|
281
289
|
audit_run::apply_risk(&project.root, &audit_context, &mut report);
|
|
290
|
+
let verdict_before_duplication = report.verdict;
|
|
282
291
|
apply_duplication_threshold_gate(&mut report);
|
|
283
|
-
let
|
|
292
|
+
let duplication_failed = report.summary.duplication_threshold_exceeded;
|
|
293
|
+
let strict_failed = apply_strict_gate(request, &mut report);
|
|
294
|
+
let code = security_summary_run::exit_code(
|
|
295
|
+
request,
|
|
296
|
+
&report,
|
|
297
|
+
regressed,
|
|
298
|
+
duplication_failed,
|
|
299
|
+
strict_failed,
|
|
300
|
+
verdict_before_duplication,
|
|
301
|
+
);
|
|
284
302
|
|
|
285
303
|
match request.format {
|
|
286
304
|
ReportOutputFormat::Human => writer.write_all(render_human_report(&report).as_bytes())?,
|
|
@@ -307,8 +325,28 @@ fn apply_duplication_threshold_gate(report: &mut crate::output::JsonReport) {
|
|
|
307
325
|
}
|
|
308
326
|
}
|
|
309
327
|
|
|
328
|
+
fn apply_strict_gate(request: &CommandRequest, report: &mut crate::output::JsonReport) -> bool {
|
|
329
|
+
let finding_count = if request.command == ReportCommand::Audit
|
|
330
|
+
&& request.audit_gate == audit_run::AuditGate::NewOnly
|
|
331
|
+
{
|
|
332
|
+
report
|
|
333
|
+
.summary
|
|
334
|
+
.attribution
|
|
335
|
+
.as_ref()
|
|
336
|
+
.map_or(0, |attribution| attribution.introduced.findings)
|
|
337
|
+
} else {
|
|
338
|
+
report.summary.findings
|
|
339
|
+
};
|
|
340
|
+
let failed = request.finding_gate == FindingGate::All && finding_count > 0;
|
|
341
|
+
if failed {
|
|
342
|
+
report.verdict = Verdict::Fail;
|
|
343
|
+
}
|
|
344
|
+
failed
|
|
345
|
+
}
|
|
346
|
+
|
|
310
347
|
fn command() -> Command {
|
|
311
348
|
let command = Command::new("dart-decimate")
|
|
349
|
+
.version(crate::VERSION)
|
|
312
350
|
.about("Rust-native Dart and Flutter module-graph intelligence")
|
|
313
351
|
.subcommand_required(false)
|
|
314
352
|
.arg_required_else_help(false);
|
|
@@ -408,7 +446,8 @@ fn audit_command() -> Command {
|
|
|
408
446
|
Arg::new("brief")
|
|
409
447
|
.long("brief")
|
|
410
448
|
.help("Emit a Fallow-style advisory review brief and always exit 0")
|
|
411
|
-
.action(ArgAction::SetTrue)
|
|
449
|
+
.action(ArgAction::SetTrue)
|
|
450
|
+
.conflicts_with("strict"),
|
|
412
451
|
)
|
|
413
452
|
.arg(
|
|
414
453
|
Arg::new("base")
|
|
@@ -544,6 +583,7 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
544
583
|
save_regression_baseline,
|
|
545
584
|
regression_tolerance: regression.tolerance,
|
|
546
585
|
fail_on_regression: regression.fail_on_regression,
|
|
586
|
+
finding_gate: finding_gate(subcommand),
|
|
547
587
|
trace_file: trace.file,
|
|
548
588
|
trace_symbol: trace.symbol,
|
|
549
589
|
trace_dependency: trace.dependency,
|
|
@@ -563,6 +603,20 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
563
603
|
})
|
|
564
604
|
}
|
|
565
605
|
|
|
606
|
+
fn finding_gate(subcommand: &ArgMatches) -> FindingGate {
|
|
607
|
+
if subcommand
|
|
608
|
+
.try_get_one::<bool>("strict")
|
|
609
|
+
.ok()
|
|
610
|
+
.flatten()
|
|
611
|
+
.copied()
|
|
612
|
+
.unwrap_or_default()
|
|
613
|
+
{
|
|
614
|
+
FindingGate::All
|
|
615
|
+
} else {
|
|
616
|
+
FindingGate::ErrorsOnly
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
566
620
|
fn request_format(
|
|
567
621
|
subcommand: &ArgMatches,
|
|
568
622
|
config: &DartDecimateConfig,
|
package/src/config/rules.rs
CHANGED
|
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|
|
5
5
|
use crate::SecurityCategory;
|
|
6
6
|
use crate::output::{
|
|
7
7
|
Finding, FindingKind, JsonAttackSurfaceEntry, JsonReport, JsonSecurityCandidate, Severity,
|
|
8
|
-
Verdict,
|
|
8
|
+
Verdict, recompute_visible_duplication_summary,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
use super::rule_aliases::{
|
|
@@ -75,12 +75,14 @@ pub fn apply_rules_to_report(report: &mut JsonReport, rules: &RuleConfig) -> Res
|
|
|
75
75
|
report
|
|
76
76
|
.findings
|
|
77
77
|
.retain_mut(|finding| apply_finding_level(finding, &rules) != RuleLevel::Off);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
if rules.level(
|
|
79
|
+
"dart-decimate/code-duplication",
|
|
80
|
+
FindingKind::CodeDuplication,
|
|
81
|
+
) == RuleLevel::Off
|
|
82
|
+
{
|
|
83
|
+
report.clone_groups.clear();
|
|
84
|
+
recompute_visible_duplication_summary(report);
|
|
85
|
+
}
|
|
84
86
|
report.complexity.retain(|finding| {
|
|
85
87
|
rules.level(&finding.rule_id, complexity_kind(&finding.rule_id)) != RuleLevel::Off
|
|
86
88
|
});
|
package/src/dupes/tests.rs
CHANGED
|
@@ -5,6 +5,12 @@ use tempfile::TempDir;
|
|
|
5
5
|
use super::*;
|
|
6
6
|
use crate::scan_project;
|
|
7
7
|
|
|
8
|
+
#[test]
|
|
9
|
+
fn zero_threshold_does_not_round_small_duplicates_down_to_pass() {
|
|
10
|
+
assert!(duplication_threshold_exceeded(120_010, 10, Some(0)));
|
|
11
|
+
assert!(!duplication_threshold_exceeded(120_010, 10, Some(1)));
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
#[test]
|
|
9
15
|
fn detects_exact_duplicate_dart_blocks() -> Result<(), Box<dyn std::error::Error>> {
|
|
10
16
|
let fixture = tempfile::tempdir()?;
|
package/src/dupes.rs
CHANGED
|
@@ -86,7 +86,7 @@ impl Default for DuplicateOptions {
|
|
|
86
86
|
ignore_imports: true,
|
|
87
87
|
ignore_mapper_pairs: true,
|
|
88
88
|
top: None,
|
|
89
|
-
threshold:
|
|
89
|
+
threshold: Some(DuplicationThreshold::ZERO),
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -100,6 +100,9 @@ const fn default_ignore_mapper_pairs() -> bool {
|
|
|
100
100
|
pub struct DuplicationThreshold(u32);
|
|
101
101
|
|
|
102
102
|
impl DuplicationThreshold {
|
|
103
|
+
/// Default threshold: any duplicated lines fail the duplication gate.
|
|
104
|
+
pub const ZERO: Self = Self(0);
|
|
105
|
+
|
|
103
106
|
/// Build a threshold from a human percentage in the inclusive range `0..=100`.
|
|
104
107
|
///
|
|
105
108
|
/// # Errors
|
|
@@ -140,10 +143,17 @@ impl DuplicationThreshold {
|
|
|
140
143
|
fn as_percent(self) -> f64 {
|
|
141
144
|
f64::from(self.0) / 100.0
|
|
142
145
|
}
|
|
146
|
+
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
pub(crate) fn duplication_threshold_exceeded(
|
|
149
|
+
analyzed_lines: usize,
|
|
150
|
+
duplicated_lines: usize,
|
|
151
|
+
threshold_basis_points: Option<u32>,
|
|
152
|
+
) -> bool {
|
|
153
|
+
analyzed_lines > 0
|
|
154
|
+
&& threshold_basis_points.is_some_and(|threshold| {
|
|
155
|
+
(duplicated_lines as u128) * 10_000 > u128::from(threshold) * (analyzed_lines as u128)
|
|
156
|
+
})
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
impl Serialize for DuplicationThreshold {
|
|
@@ -589,8 +599,11 @@ fn duplicate_stats(
|
|
|
589
599
|
let raw = ((duplicated_lines as u128) * 10_000) / (analyzed_lines as u128);
|
|
590
600
|
u32::try_from(raw).unwrap_or(u32::MAX)
|
|
591
601
|
};
|
|
592
|
-
let threshold_exceeded =
|
|
593
|
-
|
|
602
|
+
let threshold_exceeded = duplication_threshold_exceeded(
|
|
603
|
+
analyzed_lines,
|
|
604
|
+
duplicated_lines,
|
|
605
|
+
threshold.map(DuplicationThreshold::basis_points),
|
|
606
|
+
);
|
|
594
607
|
|
|
595
608
|
DuplicateStats {
|
|
596
609
|
analyzed_lines,
|
|
@@ -651,7 +664,7 @@ fn clone_group_from_occurrences(
|
|
|
651
664
|
})
|
|
652
665
|
}
|
|
653
666
|
|
|
654
|
-
fn is_ignored_path(path: &Path) -> bool {
|
|
667
|
+
pub(crate) fn is_ignored_path(path: &Path) -> bool {
|
|
655
668
|
if is_generated_dart_path(path) {
|
|
656
669
|
return true;
|
|
657
670
|
}
|
package/src/lib.rs
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
//! syntax facts. Phase 3 runs graph traversals without evaluating variables,
|
|
6
6
|
//! types, or function bodies. Phase 4 exposes the CLI and JSON output contract.
|
|
7
7
|
|
|
8
|
+
/// Version compiled into the CLI and release artifacts.
|
|
9
|
+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
10
|
+
/// Versioned producer identity used by `dart-decimate.report.v1` reports.
|
|
11
|
+
pub const REPORT_TOOL: &str = concat!("dart-decimate ", env!("CARGO_PKG_VERSION"));
|
|
12
|
+
|
|
8
13
|
pub mod baseline;
|
|
9
14
|
pub mod boundaries;
|
|
10
15
|
pub(crate) mod changed_scope;
|
package/src/manifest/mcp.rs
CHANGED
|
@@ -49,6 +49,7 @@ fn mcp_overview_tools() -> Vec<Value> {
|
|
|
49
49
|
"baseline",
|
|
50
50
|
"regression_baseline",
|
|
51
51
|
"fail_on_regression",
|
|
52
|
+
"strict",
|
|
52
53
|
"tolerance",
|
|
53
54
|
"production",
|
|
54
55
|
],
|
|
@@ -161,6 +162,7 @@ fn analyze_mcp_tool() -> Value {
|
|
|
161
162
|
"baseline",
|
|
162
163
|
"regression_baseline",
|
|
163
164
|
"fail_on_regression",
|
|
165
|
+
"strict",
|
|
164
166
|
"tolerance",
|
|
165
167
|
"include_entry_exports",
|
|
166
168
|
"private_type_leaks",
|
|
@@ -239,6 +241,7 @@ fn dupes_mcp_tool() -> Value {
|
|
|
239
241
|
"baseline",
|
|
240
242
|
"regression_baseline",
|
|
241
243
|
"fail_on_regression",
|
|
244
|
+
"strict",
|
|
242
245
|
"tolerance",
|
|
243
246
|
"production",
|
|
244
247
|
"mode",
|
|
@@ -273,6 +276,7 @@ fn health_mcp_tool() -> Value {
|
|
|
273
276
|
"baseline",
|
|
274
277
|
"regression_baseline",
|
|
275
278
|
"fail_on_regression",
|
|
279
|
+
"strict",
|
|
276
280
|
"tolerance",
|
|
277
281
|
"production",
|
|
278
282
|
"max_cyclomatic",
|
|
@@ -371,6 +375,7 @@ fn security_mcp_tool() -> Value {
|
|
|
371
375
|
"baseline",
|
|
372
376
|
"regression_baseline",
|
|
373
377
|
"fail_on_regression",
|
|
378
|
+
"strict",
|
|
374
379
|
"tolerance",
|
|
375
380
|
"top",
|
|
376
381
|
"surface",
|
|
@@ -403,6 +408,7 @@ fn feature_flags_mcp_tool() -> Value {
|
|
|
403
408
|
"baseline",
|
|
404
409
|
"regression_baseline",
|
|
405
410
|
"fail_on_regression",
|
|
411
|
+
"strict",
|
|
406
412
|
"tolerance",
|
|
407
413
|
"production",
|
|
408
414
|
"top",
|
|
@@ -536,6 +542,7 @@ fn audit_mcp_tool() -> Value {
|
|
|
536
542
|
"production",
|
|
537
543
|
"brief",
|
|
538
544
|
"max_decisions",
|
|
545
|
+
"strict",
|
|
539
546
|
],
|
|
540
547
|
)
|
|
541
548
|
}
|
package/src/manifest.rs
CHANGED
|
@@ -147,14 +147,14 @@ fn analysis_commands() -> Value {
|
|
|
147
147
|
"kind": "combined",
|
|
148
148
|
"description": "Run all enabled graph, symbol, dependency, duplicate, health, flag, and security checks.",
|
|
149
149
|
"schema": SCHEMA_VERSION,
|
|
150
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
150
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"name": "audit",
|
|
154
154
|
"kind": "audit",
|
|
155
155
|
"description": "Run changed-code graph checks scoped from a Git base ref.",
|
|
156
156
|
"schema": SCHEMA_VERSION,
|
|
157
|
-
"flags": ["--root", "--brief", "--base", "--gate", "--dead-code-baseline", "--health-baseline", "--dupes-baseline", "--max-decisions", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks"]
|
|
157
|
+
"flags": ["--root", "--brief", "--base", "--gate", "--strict", "--dead-code-baseline", "--health-baseline", "--dupes-baseline", "--max-decisions", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks"]
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
"name": "review",
|
|
@@ -175,42 +175,42 @@ fn analysis_commands() -> Value {
|
|
|
175
175
|
"kind": "dead-code",
|
|
176
176
|
"description": "Find unreachable Dart files and conservative symbol-level dead code.",
|
|
177
177
|
"schema": SCHEMA_VERSION,
|
|
178
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
178
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
181
|
"name": "cycles",
|
|
182
182
|
"kind": "cycles",
|
|
183
183
|
"description": "Find import/export/part/augment dependency cycles.",
|
|
184
184
|
"schema": SCHEMA_VERSION,
|
|
185
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline"]
|
|
185
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline"]
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
188
|
"name": "dupes",
|
|
189
189
|
"kind": "dupes",
|
|
190
190
|
"description": "Find duplicated Dart code blocks.",
|
|
191
191
|
"schema": SCHEMA_VERSION,
|
|
192
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports"]
|
|
192
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports"]
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
"name": "health",
|
|
196
196
|
"kind": "health",
|
|
197
197
|
"description": "Find complex functions, coverage gaps, hotspots, and refactoring targets.",
|
|
198
198
|
"schema": SCHEMA_VERSION,
|
|
199
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--top", "--flutter-style"]
|
|
199
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--max-cyclomatic", "--max-cognitive", "--max-unit-size", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--top", "--flutter-style"]
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
"name": "flags",
|
|
203
203
|
"kind": "flags",
|
|
204
204
|
"description": "Inventory Dart and Flutter feature flag patterns.",
|
|
205
205
|
"schema": SCHEMA_VERSION,
|
|
206
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top"]
|
|
206
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top"]
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
209
|
"name": "security",
|
|
210
210
|
"kind": "security",
|
|
211
211
|
"description": "Surface local deterministic security review candidates.",
|
|
212
212
|
"schema": SCHEMA_VERSION,
|
|
213
|
-
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top", "--surface", "--sarif-file", "--ci", "--fail-on-issues", "--summary", "--gate", "--diff-file", "--diff-stdin", "--changed-since", "--compare"]
|
|
213
|
+
"flags": ["--root", "--format", "--open", "--strict", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top", "--surface", "--sarif-file", "--ci", "--fail-on-issues", "--summary", "--gate", "--diff-file", "--diff-stdin", "--changed-since", "--compare"]
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
216
|
"name": "impact",
|
package/src/mcp/cli_args.rs
CHANGED
|
@@ -33,6 +33,7 @@ const BASELINE_KEYS: &[&str] = &[
|
|
|
33
33
|
"fail_on_regression",
|
|
34
34
|
"tolerance",
|
|
35
35
|
];
|
|
36
|
+
const REPORT_GATE_KEYS: &[&str] = &["strict"];
|
|
36
37
|
const SYMBOL_KEYS: &[&str] = &["include_entry_exports", "private_type_leaks"];
|
|
37
38
|
const BOUNDARY_KEYS: &[&str] = &[
|
|
38
39
|
"boundary",
|
|
@@ -161,12 +162,14 @@ fn extend_analyze_allowed(allowed: &mut Vec<&'static str>) {
|
|
|
161
162
|
allowed.extend(BOUNDARY_KEYS);
|
|
162
163
|
allowed.extend(DUPLICATE_KEYS);
|
|
163
164
|
allowed.extend(HEALTH_KEYS);
|
|
165
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
fn extend_check_changed_allowed(allowed: &mut Vec<&'static str>) {
|
|
167
169
|
allowed.extend(["since", "changed_since", "compare"]);
|
|
168
170
|
allowed.extend(BASELINE_KEYS);
|
|
169
171
|
allowed.extend(["dart_platform", "production"]);
|
|
172
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
170
173
|
}
|
|
171
174
|
|
|
172
175
|
fn extend_project_info_allowed(allowed: &mut Vec<&'static str>) {
|
|
@@ -184,6 +187,7 @@ fn extend_dupes_allowed(allowed: &mut Vec<&'static str>) {
|
|
|
184
187
|
allowed.extend(REPORT_SCOPE_KEYS);
|
|
185
188
|
allowed.extend(BASELINE_KEYS);
|
|
186
189
|
allowed.extend(DUPLICATE_KEYS);
|
|
190
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
fn extend_trace_clone_allowed(allowed: &mut Vec<&'static str>) {
|
|
@@ -195,6 +199,7 @@ fn extend_health_allowed(allowed: &mut Vec<&'static str>) {
|
|
|
195
199
|
allowed.extend(REPORT_SCOPE_KEYS);
|
|
196
200
|
allowed.extend(BASELINE_KEYS);
|
|
197
201
|
allowed.extend(HEALTH_KEYS);
|
|
202
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
fn extend_runtime_allowed(allowed: &mut Vec<&'static str>) {
|
|
@@ -221,12 +226,14 @@ fn extend_security_allowed(allowed: &mut Vec<&'static str>) {
|
|
|
221
226
|
"fail_on_issues",
|
|
222
227
|
"summary",
|
|
223
228
|
]);
|
|
229
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
fn extend_flags_allowed(allowed: &mut Vec<&'static str>) {
|
|
227
233
|
allowed.extend(REPORT_SCOPE_KEYS);
|
|
228
234
|
allowed.extend(BASELINE_KEYS);
|
|
229
235
|
allowed.extend(["top"]);
|
|
236
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
230
237
|
}
|
|
231
238
|
|
|
232
239
|
fn extend_fix_allowed(allowed: &mut Vec<&'static str>) {
|
|
@@ -254,6 +261,7 @@ fn extend_audit_allowed(allowed: &mut Vec<&'static str>) {
|
|
|
254
261
|
"dupes_baseline",
|
|
255
262
|
"max_decisions",
|
|
256
263
|
]);
|
|
264
|
+
allowed.extend(REPORT_GATE_KEYS);
|
|
257
265
|
}
|
|
258
266
|
|
|
259
267
|
fn report_args<F>(
|
|
@@ -285,6 +293,7 @@ fn analyze_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(),
|
|
|
285
293
|
push_boundary_args(cli, args)?;
|
|
286
294
|
push_duplicate_args(cli, args)?;
|
|
287
295
|
push_health_args(cli, args)?;
|
|
296
|
+
push_report_gate_args(cli, args)?;
|
|
288
297
|
if let Some(issue_types) = args.get("issue_types") {
|
|
289
298
|
for issue_type in array_strings(issue_types, "issue_types")? {
|
|
290
299
|
cli.push(issue_filter_flag(issue_type)?);
|
|
@@ -301,7 +310,8 @@ fn check_changed_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Resul
|
|
|
301
310
|
cli.extend(["--changed-since".to_owned(), since]);
|
|
302
311
|
push_baseline_args(cli, args)?;
|
|
303
312
|
push_string_flag(cli, args, "dart_platform", "--dart-platform")?;
|
|
304
|
-
push_bool_mode(cli, args, "production", "--production", "--no-production")
|
|
313
|
+
push_bool_mode(cli, args, "production", "--production", "--no-production")?;
|
|
314
|
+
push_report_gate_args(cli, args)
|
|
305
315
|
}
|
|
306
316
|
|
|
307
317
|
fn project_info_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
@@ -403,7 +413,8 @@ fn trace_clone_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<
|
|
|
403
413
|
fn dupes_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
404
414
|
push_report_scope_args(cli, args)?;
|
|
405
415
|
push_baseline_args(cli, args)?;
|
|
406
|
-
push_duplicate_args(cli, args)
|
|
416
|
+
push_duplicate_args(cli, args)?;
|
|
417
|
+
push_report_gate_args(cli, args)
|
|
407
418
|
}
|
|
408
419
|
|
|
409
420
|
fn push_duplicate_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
@@ -429,7 +440,8 @@ fn push_duplicate_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Resu
|
|
|
429
440
|
fn health_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
430
441
|
push_report_scope_args(cli, args)?;
|
|
431
442
|
push_baseline_args(cli, args)?;
|
|
432
|
-
push_health_args(cli, args)
|
|
443
|
+
push_health_args(cli, args)?;
|
|
444
|
+
push_report_gate_args(cli, args)
|
|
433
445
|
}
|
|
434
446
|
|
|
435
447
|
fn coverage_analyze_args(args: &Map<String, Value>) -> Result<Vec<String>, String> {
|
|
@@ -509,14 +521,14 @@ fn security_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(),
|
|
|
509
521
|
] {
|
|
510
522
|
push_bool_flag(cli, args, key, flag)?;
|
|
511
523
|
}
|
|
512
|
-
|
|
524
|
+
push_report_gate_args(cli, args)
|
|
513
525
|
}
|
|
514
526
|
|
|
515
527
|
fn flags_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
516
528
|
push_report_scope_args(cli, args)?;
|
|
517
529
|
push_baseline_args(cli, args)?;
|
|
518
530
|
push_number_flag(cli, args, "top", "--top")?;
|
|
519
|
-
|
|
531
|
+
push_report_gate_args(cli, args)
|
|
520
532
|
}
|
|
521
533
|
|
|
522
534
|
fn impact_args(args: &Map<String, Value>) -> Result<Vec<String>, String> {
|
|
@@ -576,7 +588,11 @@ fn audit_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), St
|
|
|
576
588
|
}
|
|
577
589
|
push_number_flag(cli, args, "max_decisions", "--max-decisions")?;
|
|
578
590
|
push_bool_flag(cli, args, "brief", "--brief")?;
|
|
579
|
-
|
|
591
|
+
push_report_gate_args(cli, args)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
fn push_report_gate_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
595
|
+
push_bool_flag(cli, args, "strict", "--strict")
|
|
580
596
|
}
|
|
581
597
|
|
|
582
598
|
fn decision_surface_args(cli: &mut Vec<String>, args: &Map<String, Value>) -> Result<(), String> {
|
|
@@ -17,6 +17,7 @@ fn analyze_maps_read_only_parity_flags() -> Result<(), String> {
|
|
|
17
17
|
"baseline": "baseline.json",
|
|
18
18
|
"regression_baseline": "regression.json",
|
|
19
19
|
"fail_on_regression": true,
|
|
20
|
+
"strict": true,
|
|
20
21
|
"tolerance": "10%",
|
|
21
22
|
"include_entry_exports": true,
|
|
22
23
|
"private_type_leaks": true,
|
|
@@ -65,6 +66,7 @@ fn analyze_maps_read_only_parity_flags() -> Result<(), String> {
|
|
|
65
66
|
assert_pair(&cli, "--baseline", "baseline.json");
|
|
66
67
|
assert_pair(&cli, "--regression-baseline", "regression.json");
|
|
67
68
|
assert_flag(&cli, "--fail-on-regression");
|
|
69
|
+
assert_flag(&cli, "--strict");
|
|
68
70
|
assert_pair(&cli, "--tolerance", "10%");
|
|
69
71
|
assert_flag(&cli, "--include-entry-exports");
|
|
70
72
|
assert_flag(&cli, "--private-type-leaks");
|
package/src/mcp/tools.rs
CHANGED
|
@@ -56,6 +56,7 @@ fn analyze_tool() -> Value {
|
|
|
56
56
|
("baseline", "string"),
|
|
57
57
|
("regression_baseline", "string"),
|
|
58
58
|
("fail_on_regression", "boolean"),
|
|
59
|
+
("strict", "boolean"),
|
|
59
60
|
("tolerance", "string"),
|
|
60
61
|
("include_entry_exports", "boolean"),
|
|
61
62
|
("private_type_leaks", "boolean"),
|
|
@@ -110,6 +111,7 @@ fn check_changed_tool() -> Value {
|
|
|
110
111
|
("baseline", "string"),
|
|
111
112
|
("regression_baseline", "string"),
|
|
112
113
|
("fail_on_regression", "boolean"),
|
|
114
|
+
("strict", "boolean"),
|
|
113
115
|
("tolerance", "string"),
|
|
114
116
|
("production", "boolean"),
|
|
115
117
|
],
|
|
@@ -300,6 +302,7 @@ fn dupes_tool() -> Value {
|
|
|
300
302
|
("baseline", "string"),
|
|
301
303
|
("regression_baseline", "string"),
|
|
302
304
|
("fail_on_regression", "boolean"),
|
|
305
|
+
("strict", "boolean"),
|
|
303
306
|
("tolerance", "string"),
|
|
304
307
|
("production", "boolean"),
|
|
305
308
|
("min_tokens", "integer"),
|
|
@@ -339,6 +342,7 @@ fn health_tool() -> Value {
|
|
|
339
342
|
("baseline", "string"),
|
|
340
343
|
("regression_baseline", "string"),
|
|
341
344
|
("fail_on_regression", "boolean"),
|
|
345
|
+
("strict", "boolean"),
|
|
342
346
|
("tolerance", "string"),
|
|
343
347
|
("runtime_coverage", "string"),
|
|
344
348
|
("min_invocations_hot", "integer"),
|
|
@@ -398,6 +402,7 @@ fn security_tool() -> Value {
|
|
|
398
402
|
("baseline", "string"),
|
|
399
403
|
("regression_baseline", "string"),
|
|
400
404
|
("fail_on_regression", "boolean"),
|
|
405
|
+
("strict", "boolean"),
|
|
401
406
|
("tolerance", "string"),
|
|
402
407
|
("surface", "boolean"),
|
|
403
408
|
("production", "boolean"),
|
|
@@ -448,6 +453,7 @@ fn feature_flags_tool() -> Value {
|
|
|
448
453
|
("baseline", "string"),
|
|
449
454
|
("regression_baseline", "string"),
|
|
450
455
|
("fail_on_regression", "boolean"),
|
|
456
|
+
("strict", "boolean"),
|
|
451
457
|
("tolerance", "string"),
|
|
452
458
|
("production", "boolean"),
|
|
453
459
|
],
|
|
@@ -573,6 +579,7 @@ fn audit_tool() -> Value {
|
|
|
573
579
|
("production", "boolean"),
|
|
574
580
|
("brief", "boolean"),
|
|
575
581
|
("max_decisions", "integer"),
|
|
582
|
+
("strict", "boolean"),
|
|
576
583
|
],
|
|
577
584
|
&["base"],
|
|
578
585
|
),
|
package/src/output/scope.rs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
use std::collections::BTreeSet;
|
|
2
|
+
use std::fs;
|
|
2
3
|
|
|
3
4
|
use super::format;
|
|
4
5
|
use super::{
|
|
@@ -7,6 +8,7 @@ use super::{
|
|
|
7
8
|
JsonRefactoringTarget, JsonSecurityCandidate,
|
|
8
9
|
};
|
|
9
10
|
use crate::{HealthReport, SemanticOmissionReason, SemanticReport, scan::ScannedProject};
|
|
11
|
+
use crate::{dupes::is_ignored_path, graph::normalize_against};
|
|
10
12
|
|
|
11
13
|
pub(super) fn file_scope(
|
|
12
14
|
project: &ScannedProject,
|
|
@@ -201,6 +203,28 @@ pub(super) fn project_file_scope_count(
|
|
|
201
203
|
.count()
|
|
202
204
|
}
|
|
203
205
|
|
|
206
|
+
pub(super) fn scoped_duplication_analyzed_lines(
|
|
207
|
+
project: &ScannedProject,
|
|
208
|
+
scope: &BTreeSet<String>,
|
|
209
|
+
) -> usize {
|
|
210
|
+
project
|
|
211
|
+
.files
|
|
212
|
+
.iter()
|
|
213
|
+
.filter_map(|file| {
|
|
214
|
+
let path = normalize_against(&project.root, &file.path);
|
|
215
|
+
if !path.starts_with(&project.root)
|
|
216
|
+
|| is_ignored_path(&path)
|
|
217
|
+
|| !scope.contains(&format::display_path(&project.root, &path))
|
|
218
|
+
{
|
|
219
|
+
return None;
|
|
220
|
+
}
|
|
221
|
+
fs::read_to_string(path)
|
|
222
|
+
.ok()
|
|
223
|
+
.map(|source| source.lines().count())
|
|
224
|
+
})
|
|
225
|
+
.sum()
|
|
226
|
+
}
|
|
227
|
+
|
|
204
228
|
pub(super) fn health_file_score_count(
|
|
205
229
|
project: &ScannedProject,
|
|
206
230
|
scores: &[crate::FileHealthScore],
|