dart-decimate 0.0.42 → 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/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 code = security_summary_run::exit_code(request, &report, regressed);
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,
@@ -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
- report.clone_groups.retain(|_| {
79
- rules.level(
80
- "dart-decimate/code-duplication",
81
- FindingKind::CodeDuplication,
82
- ) != RuleLevel::Off
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
  });
@@ -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()?;
@@ -284,6 +290,25 @@ fn trace_clone_matches_fingerprint_and_source_line() -> Result<(), Box<dyn std::
284
290
  Ok(())
285
291
  }
286
292
 
293
+ #[test]
294
+ fn does_not_group_distinct_windows_with_a_colliding_fingerprint()
295
+ -> Result<(), Box<dyn std::error::Error>> {
296
+ assert_fingerprint_collision_is_not_a_clone(
297
+ "lib/builder.dart",
298
+ "lib/validation.dart",
299
+ "void build4sh0() {\n final palette4sh0 = select(red, green, blue, amber, ivory, slate, navy, mint);\n final surface4sh0 = compose(palette4sh0, red, green, blue, amber, ivory, slate);\n final result4sh0 = create(surface4sh0, red, green, blue, amber, ivory, slate);\n report(result4sh0, red, green, blue, amber, ivory, slate);\n}",
300
+ "bool verify9zz() {\n final record9zz = collect(one, two, three, four, five, six, seven, eight);\n if (record9zz == one && record9zz == two && record9zz == three && record9zz == four) {\n return record9zz == five || record9zz == six || record9zz == seven || record9zz == eight;\n }\n return false;\n}",
301
+ )?;
302
+ assert_fingerprint_collision_is_not_a_clone(
303
+ "lib/invariant.dart",
304
+ "lib/catalog.dart",
305
+ "Record parse4o3l(Map values) {\n final stamp = values['stamp'] == null ? null : DateTime.parse(values['stamp']).toUtc();\n if (values['phase'] == 'sent' && stamp == null) throw StateError('missing');\n if (values['phase'] == 'ready' && stamp != null) throw StateError('unexpected');\n return Record(stamp: stamp, phase: values['phase']);\n}",
306
+ "Record localizedhed() {\n final state = Record(label: 'alpha', detail: 'beta', title: 'gamma', note: 'delta');\n if (state.label == 'alpha' && state.detail == 'beta') return state;\n if (state.title == 'gamma' || state.note == 'delta') return Record(label: 'next', detail: 'value');\n return state;\n}",
307
+ )?;
308
+
309
+ Ok(())
310
+ }
311
+
287
312
  fn pagination_clone_source() -> &'static str {
288
313
  r"Future<List<String>> fetchAllRowIds(Pages pages) async {
289
314
  final values = <String>[];
@@ -327,6 +352,73 @@ fn options(mode: DuplicateMode, min_lines: usize, min_tokens: usize) -> Duplicat
327
352
  }
328
353
  }
329
354
 
355
+ fn assert_fingerprint_collision_is_not_a_clone(
356
+ first_path: &str,
357
+ second_path: &str,
358
+ first_source: &str,
359
+ second_source: &str,
360
+ ) -> Result<(), Box<dyn std::error::Error>> {
361
+ let fixture = tempfile::tempdir()?;
362
+ let options = options(DuplicateMode::Mild, 5, 50);
363
+ write(&fixture, "pubspec.yaml", "name: app\n")?;
364
+ write(&fixture, first_path, first_source)?;
365
+ write(&fixture, second_path, second_source)?;
366
+
367
+ let first_window = first_clone_window_text(first_source, &options)?;
368
+ let second_window = first_clone_window_text(second_source, &options)?;
369
+ assert_ne!(first_window, second_window);
370
+ assert_eq!(
371
+ super::fingerprint(&first_window),
372
+ super::fingerprint(&second_window)
373
+ );
374
+
375
+ let project = scan_project(fixture.path())?;
376
+ let report = detect_duplicates(&project, &options)?;
377
+ assert!(report.clone_groups.is_empty());
378
+
379
+ write(&fixture, "lib/exact_copy.dart", first_source)?;
380
+ let project = scan_project(fixture.path())?;
381
+ let report = detect_duplicates(&project, &options)?;
382
+ assert_eq!(report.clone_groups.len(), 1);
383
+ assert_eq!(report.clone_groups[0].instances.len(), 2);
384
+ assert!(
385
+ report.clone_groups[0]
386
+ .instances
387
+ .iter()
388
+ .any(|instance| instance.path.ends_with(first_path))
389
+ );
390
+ assert!(
391
+ report.clone_groups[0]
392
+ .instances
393
+ .iter()
394
+ .any(|instance| instance.path.ends_with("lib/exact_copy.dart"))
395
+ );
396
+ assert!(
397
+ report.clone_groups[0]
398
+ .instances
399
+ .iter()
400
+ .all(|instance| !instance.path.ends_with(second_path))
401
+ );
402
+
403
+ Ok(())
404
+ }
405
+
406
+ fn first_clone_window_text(
407
+ source: &str,
408
+ options: &DuplicateOptions,
409
+ ) -> Result<String, std::io::Error> {
410
+ let lines = super::lex::normalized_lines(source, options);
411
+ let window = super::clone_windows(&lines, options)
412
+ .into_iter()
413
+ .next()
414
+ .ok_or_else(|| std::io::Error::other("fixture contains a clone window"))?;
415
+ Ok(lines[window.start..=window.end]
416
+ .iter()
417
+ .map(|line| line.text.as_str())
418
+ .collect::<Vec<_>>()
419
+ .join("\n"))
420
+ }
421
+
330
422
  fn instance(
331
423
  path: &std::path::Path,
332
424
  start_line: usize,
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: None,
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
- fn is_exceeded_by(self, percentage_basis_points: u32) -> bool {
145
- percentage_basis_points > self.0
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 {
@@ -337,7 +347,9 @@ pub fn detect_duplicates(
337
347
  project: &ScannedProject,
338
348
  options: &DuplicateOptions,
339
349
  ) -> Result<DuplicateCodeReport, DuplicateCodeError> {
340
- let mut by_fingerprint = BTreeMap::<String, Vec<(CloneOccurrence, usize)>>::new();
350
+ // Fingerprints identify report groups, but exact normalized text defines a clone.
351
+ let mut by_fingerprint =
352
+ BTreeMap::<String, BTreeMap<String, Vec<(CloneOccurrence, usize)>>>::new();
341
353
  let mut analyzed_lines = 0usize;
342
354
 
343
355
  for file in &project.files {
@@ -369,24 +381,31 @@ pub fn detect_duplicates(
369
381
  continue;
370
382
  };
371
383
  let fingerprint = fingerprint(&text);
372
- by_fingerprint.entry(fingerprint).or_default().push((
373
- CloneOccurrence {
374
- parent: path.parent().map_or_else(PathBuf::new, Path::to_path_buf),
375
- path: path.clone(),
376
- start_line: first.line,
377
- end_line: last.line,
378
- column: first.column,
379
- line_count: window.len(),
380
- },
381
- clone_window.token_count,
382
- ));
384
+ by_fingerprint
385
+ .entry(fingerprint)
386
+ .or_default()
387
+ .entry(text)
388
+ .or_default()
389
+ .push((
390
+ CloneOccurrence {
391
+ parent: path.parent().map_or_else(PathBuf::new, Path::to_path_buf),
392
+ path: path.clone(),
393
+ start_line: first.line,
394
+ end_line: last.line,
395
+ column: first.column,
396
+ line_count: window.len(),
397
+ },
398
+ clone_window.token_count,
399
+ ));
383
400
  }
384
401
  }
385
402
 
386
403
  let mut clone_groups = by_fingerprint
387
404
  .into_iter()
388
- .filter_map(|(fingerprint, occurrences)| {
389
- clone_group_from_occurrences(&fingerprint, occurrences, options)
405
+ .flat_map(|(fingerprint, by_text)| {
406
+ by_text.into_values().filter_map(move |occurrences| {
407
+ clone_group_from_occurrences(&fingerprint, occurrences, options)
408
+ })
390
409
  })
391
410
  .collect::<Vec<_>>();
392
411
 
@@ -580,8 +599,11 @@ fn duplicate_stats(
580
599
  let raw = ((duplicated_lines as u128) * 10_000) / (analyzed_lines as u128);
581
600
  u32::try_from(raw).unwrap_or(u32::MAX)
582
601
  };
583
- let threshold_exceeded = threshold
584
- .is_some_and(|threshold| threshold.is_exceeded_by(duplication_percentage_basis_points));
602
+ let threshold_exceeded = duplication_threshold_exceeded(
603
+ analyzed_lines,
604
+ duplicated_lines,
605
+ threshold.map(DuplicationThreshold::basis_points),
606
+ );
585
607
 
586
608
  DuplicateStats {
587
609
  analyzed_lines,
@@ -642,7 +664,7 @@ fn clone_group_from_occurrences(
642
664
  })
643
665
  }
644
666
 
645
- fn is_ignored_path(path: &Path) -> bool {
667
+ pub(crate) fn is_ignored_path(path: &Path) -> bool {
646
668
  if is_generated_dart_path(path) {
647
669
  return true;
648
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;
@@ -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",
@@ -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
- Ok(())
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
- Ok(())
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
- Ok(())
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> {