dart-decimate 0.0.7 → 0.0.9
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 +37 -48
- package/package.json +2 -1
- package/src/config.rs +3 -2
- package/src/dupes/tests.rs +33 -0
- package/src/dupes.rs +51 -13
- package/src/output/duplication_findings.rs +2 -2
- package/src/output/html/assets.rs +164 -0
- package/src/output/html/tests.rs +410 -0
- package/src/output/html.rs +176 -241
package/src/output/html.rs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use std::fmt::Write as _;
|
|
1
|
+
use std::{collections::HashMap, fmt::Write as _, mem};
|
|
2
2
|
|
|
3
3
|
use crate::decision_surface::{
|
|
4
4
|
DecisionSurfaceCategory, DecisionSurfaceDecision, DecisionSurfaceReport,
|
|
@@ -11,9 +11,14 @@ use super::{
|
|
|
11
11
|
types::{Finding, FindingEdge, FindingKind, JsonReport, Severity, Verdict},
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
mod assets;
|
|
15
|
+
|
|
16
|
+
use assets::{render_interaction_script, render_style};
|
|
17
|
+
|
|
14
18
|
const MAX_RELATED_FILES: usize = 12;
|
|
19
|
+
const MAX_GROUP_RULE_IDS: usize = 3;
|
|
15
20
|
|
|
16
|
-
/// Render a browser-ready static report
|
|
21
|
+
/// Render a browser-ready static report with grouped finding navigation.
|
|
17
22
|
#[must_use]
|
|
18
23
|
pub fn render_html_report(report: &JsonReport) -> String {
|
|
19
24
|
let mut html = String::new();
|
|
@@ -74,60 +79,6 @@ fn render_decision_surface_document_start(html: &mut String, report: &DecisionSu
|
|
|
74
79
|
let _ = writeln!(html, "<body>");
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
fn render_style(html: &mut String) {
|
|
78
|
-
let _ = writeln!(
|
|
79
|
-
html,
|
|
80
|
-
"<style>
|
|
81
|
-
:root {{
|
|
82
|
-
color-scheme: dark;
|
|
83
|
-
--bg: #070707;
|
|
84
|
-
--panel: #111111;
|
|
85
|
-
--line: #2b2b2b;
|
|
86
|
-
--text: #f1f1f1;
|
|
87
|
-
--muted: #a6a6a6;
|
|
88
|
-
--accent: #8fdcff;
|
|
89
|
-
--error: #ff5c5c;
|
|
90
|
-
--warn: #ffd166;
|
|
91
|
-
--pass: #5ee091;
|
|
92
|
-
}}
|
|
93
|
-
* {{ box-sizing: border-box; }}
|
|
94
|
-
body {{
|
|
95
|
-
margin: 0;
|
|
96
|
-
background: var(--bg);
|
|
97
|
-
color: var(--text);
|
|
98
|
-
font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;
|
|
99
|
-
}}
|
|
100
|
-
main {{ max-width: 1180px; margin: 0 auto; padding: 40px 24px 56px; }}
|
|
101
|
-
h1, h2, h3, p {{ margin: 0; }}
|
|
102
|
-
h1 {{ font-size: clamp(32px, 5vw, 60px); letter-spacing: 0; line-height: 1; }}
|
|
103
|
-
h2 {{ margin-top: 36px; font-size: 22px; }}
|
|
104
|
-
.topline {{ color: var(--muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }}
|
|
105
|
-
.hero {{ border-bottom: 1px solid var(--line); padding-bottom: 28px; }}
|
|
106
|
-
.verdict {{ display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; }}
|
|
107
|
-
.pass {{ color: var(--pass); }}
|
|
108
|
-
.fail, .error {{ color: var(--error); }}
|
|
109
|
-
.warning {{ color: var(--warn); }}
|
|
110
|
-
.metrics, .groups {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 24px; }}
|
|
111
|
-
.metric, .group, .finding, .step {{ background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }}
|
|
112
|
-
.metric span, .group span, .label {{ color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }}
|
|
113
|
-
.metric strong, .group strong {{ display: block; margin-top: 4px; font-size: 24px; }}
|
|
114
|
-
.group p {{ margin-top: 8px; color: var(--text); }}
|
|
115
|
-
.findings {{ display: grid; gap: 14px; margin-top: 14px; }}
|
|
116
|
-
.finding header {{ display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }}
|
|
117
|
-
.finding h3 {{ font-size: 18px; }}
|
|
118
|
-
.rule, .location, .mono {{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }}
|
|
119
|
-
.rule {{ color: var(--muted); font-size: 13px; }}
|
|
120
|
-
.section {{ margin-top: 12px; }}
|
|
121
|
-
.section p {{ margin-top: 3px; }}
|
|
122
|
-
.evidence {{ margin: 8px 0 0; padding-left: 18px; color: var(--text); }}
|
|
123
|
-
.evidence li {{ margin: 3px 0; }}
|
|
124
|
-
.command {{ overflow-wrap: anywhere; color: var(--accent); }}
|
|
125
|
-
a {{ color: var(--accent); text-decoration: none; }}
|
|
126
|
-
a:hover {{ text-decoration: underline; }}
|
|
127
|
-
</style>"
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
82
|
fn render_summary(html: &mut String, report: &JsonReport) {
|
|
132
83
|
let verdict_class = match report.verdict {
|
|
133
84
|
Verdict::Pass => "pass",
|
|
@@ -286,17 +237,176 @@ fn render_findings(html: &mut String, report: &JsonReport) {
|
|
|
286
237
|
return;
|
|
287
238
|
}
|
|
288
239
|
|
|
289
|
-
let
|
|
290
|
-
|
|
291
|
-
|
|
240
|
+
let groups = grouped_findings(&report.findings);
|
|
241
|
+
render_finding_controls(html, &groups);
|
|
242
|
+
let _ = writeln!(
|
|
243
|
+
html,
|
|
244
|
+
"<p class=\"empty-results\" data-empty-results hidden>No findings match the current filters.</p>"
|
|
245
|
+
);
|
|
246
|
+
let _ = writeln!(html, "<div class=\"finding-groups\">");
|
|
247
|
+
for (group_index, group) in groups.iter().enumerate() {
|
|
248
|
+
render_finding_group(html, group_index, group);
|
|
292
249
|
}
|
|
293
250
|
let _ = writeln!(html, "</div>");
|
|
294
251
|
let _ = writeln!(html, "</section>");
|
|
295
252
|
}
|
|
296
253
|
|
|
254
|
+
struct FindingGroup<'a> {
|
|
255
|
+
kind: FindingKind,
|
|
256
|
+
rule_ids: Vec<&'a str>,
|
|
257
|
+
entries: Vec<(usize, &'a Finding)>,
|
|
258
|
+
error_count: usize,
|
|
259
|
+
warning_count: usize,
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
fn grouped_findings(findings: &[Finding]) -> Vec<FindingGroup<'_>> {
|
|
263
|
+
let mut groups: Vec<FindingGroup<'_>> = Vec::new();
|
|
264
|
+
let mut group_indices = HashMap::<mem::Discriminant<FindingKind>, usize>::new();
|
|
265
|
+
for (index, finding) in findings.iter().enumerate() {
|
|
266
|
+
let kind_key = mem::discriminant(&finding.kind);
|
|
267
|
+
if let Some(group_index) = group_indices.get(&kind_key).copied() {
|
|
268
|
+
let group = &mut groups[group_index];
|
|
269
|
+
group.push(index + 1, finding);
|
|
270
|
+
} else {
|
|
271
|
+
group_indices.insert(kind_key, groups.len());
|
|
272
|
+
groups.push(FindingGroup::new(index + 1, finding));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
groups
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
impl<'a> FindingGroup<'a> {
|
|
279
|
+
fn new(index: usize, finding: &'a Finding) -> Self {
|
|
280
|
+
let mut group = Self {
|
|
281
|
+
kind: finding.kind,
|
|
282
|
+
rule_ids: Vec::new(),
|
|
283
|
+
entries: Vec::new(),
|
|
284
|
+
error_count: 0,
|
|
285
|
+
warning_count: 0,
|
|
286
|
+
};
|
|
287
|
+
group.push(index, finding);
|
|
288
|
+
group
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
fn push(&mut self, index: usize, finding: &'a Finding) {
|
|
292
|
+
match finding.severity {
|
|
293
|
+
Severity::Error => self.error_count += 1,
|
|
294
|
+
Severity::Warning => self.warning_count += 1,
|
|
295
|
+
}
|
|
296
|
+
let rule_id = finding.rule_id.as_str();
|
|
297
|
+
if !self.rule_ids.contains(&rule_id) {
|
|
298
|
+
self.rule_ids.push(rule_id);
|
|
299
|
+
}
|
|
300
|
+
self.entries.push((index, finding));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
fn render_finding_controls(html: &mut String, groups: &[FindingGroup<'_>]) {
|
|
305
|
+
let total = groups
|
|
306
|
+
.iter()
|
|
307
|
+
.map(|group| group.entries.len())
|
|
308
|
+
.sum::<usize>();
|
|
309
|
+
let _ = writeln!(html, "<div class=\"finding-tools\" data-finding-controls>");
|
|
310
|
+
let _ = writeln!(
|
|
311
|
+
html,
|
|
312
|
+
"<label>Search<input type=\"search\" placeholder=\"Path, message, rule, evidence\" data-finding-search></label>"
|
|
313
|
+
);
|
|
314
|
+
let _ = writeln!(
|
|
315
|
+
html,
|
|
316
|
+
"<div class=\"filter-set\" role=\"group\" aria-label=\"Filter findings by type\">"
|
|
317
|
+
);
|
|
318
|
+
let _ = writeln!(html, "<span class=\"filter-label\">Type</span>");
|
|
319
|
+
let _ = writeln!(html, "<div class=\"filter-buttons\">");
|
|
320
|
+
let _ = writeln!(
|
|
321
|
+
html,
|
|
322
|
+
"<button class=\"type-filter\" type=\"button\" data-finding-filter data-kind=\"\" aria-pressed=\"true\">All types</button>"
|
|
323
|
+
);
|
|
324
|
+
for (index, group) in groups.iter().enumerate() {
|
|
325
|
+
let label = kind_label(group.kind);
|
|
326
|
+
let _ = writeln!(
|
|
327
|
+
html,
|
|
328
|
+
"<button class=\"type-filter\" type=\"button\" data-finding-filter data-kind=\"{}\" aria-pressed=\"false\">{}. {} ({})</button>",
|
|
329
|
+
escape(label),
|
|
330
|
+
index + 1,
|
|
331
|
+
escape(label),
|
|
332
|
+
group.entries.len()
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
let _ = writeln!(html, "</div></div>");
|
|
336
|
+
let _ = writeln!(
|
|
337
|
+
html,
|
|
338
|
+
"<p class=\"finding-status\" data-finding-status data-total=\"{total}\" aria-live=\"polite\">Showing {total} of {total} findings in {} {}.</p>",
|
|
339
|
+
groups.len(),
|
|
340
|
+
plural(groups.len(), "type", "types")
|
|
341
|
+
);
|
|
342
|
+
let _ = writeln!(html, "</div>");
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
fn render_finding_group(html: &mut String, group_index: usize, group: &FindingGroup<'_>) {
|
|
346
|
+
let label = kind_label(group.kind);
|
|
347
|
+
let open = if group_index == 0 { " open" } else { "" };
|
|
348
|
+
let _ = writeln!(
|
|
349
|
+
html,
|
|
350
|
+
"<details class=\"finding-group\" data-finding-group data-kind=\"{}\"{}>",
|
|
351
|
+
escape(label),
|
|
352
|
+
open
|
|
353
|
+
);
|
|
354
|
+
let _ = writeln!(html, "<summary>");
|
|
355
|
+
let rule_summary = group_rule_summary(group);
|
|
356
|
+
let rule_html = rule_summary.map_or_else(String::new, |rule_ids| {
|
|
357
|
+
format!("<span class=\"rule\">{}</span>", escape(&rule_ids))
|
|
358
|
+
});
|
|
359
|
+
let _ = writeln!(
|
|
360
|
+
html,
|
|
361
|
+
"<span class=\"summary-title\"><span class=\"group-number\">{}.</span><span class=\"summary-text\"><strong>{}</strong>{}</span></span>",
|
|
362
|
+
group_index + 1,
|
|
363
|
+
escape(label),
|
|
364
|
+
rule_html
|
|
365
|
+
);
|
|
366
|
+
let _ = writeln!(
|
|
367
|
+
html,
|
|
368
|
+
"<span class=\"summary-right\"><span class=\"summary-meta\">{}</span><span class=\"chevron\" aria-hidden=\"true\"></span></span>",
|
|
369
|
+
escape(&group_summary(group))
|
|
370
|
+
);
|
|
371
|
+
let _ = writeln!(html, "</summary>");
|
|
372
|
+
let _ = writeln!(html, "<div class=\"findings\">");
|
|
373
|
+
for (index, finding) in &group.entries {
|
|
374
|
+
render_finding(html, *index, finding);
|
|
375
|
+
}
|
|
376
|
+
let _ = writeln!(html, "</div>");
|
|
377
|
+
let _ = writeln!(html, "</details>");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
fn group_rule_summary(group: &FindingGroup<'_>) -> Option<String> {
|
|
381
|
+
if group.rule_ids.is_empty() || group.rule_ids.len() > MAX_GROUP_RULE_IDS {
|
|
382
|
+
return None;
|
|
383
|
+
}
|
|
384
|
+
Some(group.rule_ids.join(", "))
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
fn group_summary(group: &FindingGroup<'_>) -> String {
|
|
388
|
+
let total = group.entries.len();
|
|
389
|
+
let mut parts = vec![format!("{total} {}", plural(total, "finding", "findings"))];
|
|
390
|
+
if group.error_count > 0 {
|
|
391
|
+
parts.push(format!(
|
|
392
|
+
"{} {}",
|
|
393
|
+
group.error_count,
|
|
394
|
+
plural(group.error_count, "error", "errors")
|
|
395
|
+
));
|
|
396
|
+
}
|
|
397
|
+
if group.warning_count > 0 {
|
|
398
|
+
parts.push(format!(
|
|
399
|
+
"{} {}",
|
|
400
|
+
group.warning_count,
|
|
401
|
+
plural(group.warning_count, "warning", "warnings")
|
|
402
|
+
));
|
|
403
|
+
}
|
|
404
|
+
parts.join(" | ")
|
|
405
|
+
}
|
|
406
|
+
|
|
297
407
|
fn render_finding(html: &mut String, index: usize, finding: &Finding) {
|
|
298
408
|
let severity_class = severity_class(finding.severity);
|
|
299
|
-
let _ = writeln!(html, "<article class=\"finding\">");
|
|
409
|
+
let _ = writeln!(html, "<article class=\"finding\" data-finding>");
|
|
300
410
|
let _ = writeln!(html, "<header>");
|
|
301
411
|
let _ = writeln!(
|
|
302
412
|
html,
|
|
@@ -394,6 +504,7 @@ fn render_next_steps(html: &mut String, report: &JsonReport) {
|
|
|
394
504
|
|
|
395
505
|
fn render_document_end(html: &mut String) {
|
|
396
506
|
let _ = writeln!(html, "</main>");
|
|
507
|
+
render_interaction_script(html);
|
|
397
508
|
let _ = writeln!(html, "</body>");
|
|
398
509
|
let _ = writeln!(html, "</html>");
|
|
399
510
|
}
|
|
@@ -489,6 +600,10 @@ fn related_files_preview(files: &[String]) -> String {
|
|
|
489
600
|
visible.join(", ")
|
|
490
601
|
}
|
|
491
602
|
|
|
603
|
+
const fn plural<'a>(count: usize, singular: &'a str, plural: &'a str) -> &'a str {
|
|
604
|
+
if count == 1 { singular } else { plural }
|
|
605
|
+
}
|
|
606
|
+
|
|
492
607
|
fn escape(value: &str) -> String {
|
|
493
608
|
let mut escaped = String::with_capacity(value.len());
|
|
494
609
|
for character in value.chars() {
|
|
@@ -508,184 +623,4 @@ fn escape(value: &str) -> String {
|
|
|
508
623
|
}
|
|
509
624
|
|
|
510
625
|
#[cfg(test)]
|
|
511
|
-
mod tests
|
|
512
|
-
use super::*;
|
|
513
|
-
use crate::output::{FindingAction, FindingEdge, NextStep, ReportCommand, ReportSummary};
|
|
514
|
-
|
|
515
|
-
#[test]
|
|
516
|
-
fn renders_browser_ready_report_with_escaped_evidence() {
|
|
517
|
-
let report = JsonReport {
|
|
518
|
-
schema_version: "dart-decimate.report.v1".to_owned(),
|
|
519
|
-
kind: "combined".to_owned(),
|
|
520
|
-
tool: "dart-decimate".to_owned(),
|
|
521
|
-
command: ReportCommand::Check,
|
|
522
|
-
verdict: Verdict::Fail,
|
|
523
|
-
summary: ReportSummary {
|
|
524
|
-
files: 3,
|
|
525
|
-
edges: 2,
|
|
526
|
-
findings: 1,
|
|
527
|
-
cycles: 1,
|
|
528
|
-
..ReportSummary::default()
|
|
529
|
-
},
|
|
530
|
-
findings: vec![Finding {
|
|
531
|
-
rule_id: "dart-decimate/circular-dependency".to_owned(),
|
|
532
|
-
fingerprint: Some("cycle:<unsafe>".to_owned()),
|
|
533
|
-
kind: FindingKind::CircularDependency,
|
|
534
|
-
severity: Severity::Error,
|
|
535
|
-
message: "Circular dependency spans 3 Dart files".to_owned(),
|
|
536
|
-
path: "lib/a.dart".to_owned(),
|
|
537
|
-
line: 1,
|
|
538
|
-
column: 0,
|
|
539
|
-
safe_to_delete: false,
|
|
540
|
-
files: vec![
|
|
541
|
-
"lib/a.dart".to_owned(),
|
|
542
|
-
"lib/b.dart".to_owned(),
|
|
543
|
-
"lib/c.dart".to_owned(),
|
|
544
|
-
],
|
|
545
|
-
edge: None,
|
|
546
|
-
actions: vec![
|
|
547
|
-
FindingAction::new(
|
|
548
|
-
"break-cycle",
|
|
549
|
-
"Move shared dependencies inward or invert one import edge",
|
|
550
|
-
false,
|
|
551
|
-
)
|
|
552
|
-
.with_dart_decimate_args([
|
|
553
|
-
"inspect",
|
|
554
|
-
"--format",
|
|
555
|
-
"json",
|
|
556
|
-
"--file",
|
|
557
|
-
"lib/a.dart",
|
|
558
|
-
]),
|
|
559
|
-
],
|
|
560
|
-
}],
|
|
561
|
-
clone_groups: Vec::new(),
|
|
562
|
-
complexity: Vec::new(),
|
|
563
|
-
file_scores: Vec::new(),
|
|
564
|
-
hotspots: Vec::new(),
|
|
565
|
-
refactoring_targets: Vec::new(),
|
|
566
|
-
threshold_overrides: Vec::new(),
|
|
567
|
-
feature_flags: Vec::new(),
|
|
568
|
-
security_candidates: Vec::new(),
|
|
569
|
-
attack_surface: Vec::new(),
|
|
570
|
-
runtime_coverage: None,
|
|
571
|
-
next_steps: Vec::new(),
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
let rendered = render_html_report(&report);
|
|
575
|
-
|
|
576
|
-
assert!(rendered.starts_with("<!doctype html>"));
|
|
577
|
-
assert!(rendered.contains("<h1>check report</h1>"));
|
|
578
|
-
assert!(rendered.contains("Architecture"));
|
|
579
|
-
assert!(rendered.contains("1 circular dependency"));
|
|
580
|
-
assert!(rendered.contains("Why"));
|
|
581
|
-
assert!(rendered.contains("cycle:<unsafe>"));
|
|
582
|
-
assert!(rendered.contains("lib/a.dart -> lib/b.dart -> lib/c.dart -> lib/a.dart"));
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
#[test]
|
|
586
|
-
fn escapes_control_characters_from_user_values() {
|
|
587
|
-
let report = JsonReport {
|
|
588
|
-
schema_version: "dart-decimate.report.v1".to_owned(),
|
|
589
|
-
kind: "combined".to_owned(),
|
|
590
|
-
tool: "dart-decimate".to_owned(),
|
|
591
|
-
command: ReportCommand::Check,
|
|
592
|
-
verdict: Verdict::Fail,
|
|
593
|
-
summary: ReportSummary {
|
|
594
|
-
files: 2,
|
|
595
|
-
edges: 1,
|
|
596
|
-
findings: 1,
|
|
597
|
-
cycles: 1,
|
|
598
|
-
..ReportSummary::default()
|
|
599
|
-
},
|
|
600
|
-
findings: vec![Finding {
|
|
601
|
-
rule_id: "dart-decimate/circular-dependency".to_owned(),
|
|
602
|
-
fingerprint: Some("cycle:\x1bunsafe".to_owned()),
|
|
603
|
-
kind: FindingKind::CircularDependency,
|
|
604
|
-
severity: Severity::Error,
|
|
605
|
-
message: "Circular dependency includes \x07bell".to_owned(),
|
|
606
|
-
path: "lib/\x1b[31mbad.dart".to_owned(),
|
|
607
|
-
line: 1,
|
|
608
|
-
column: 0,
|
|
609
|
-
safe_to_delete: false,
|
|
610
|
-
files: vec![
|
|
611
|
-
"lib/\x1b[31mbad.dart".to_owned(),
|
|
612
|
-
"lib/\x07bell.dart".to_owned(),
|
|
613
|
-
],
|
|
614
|
-
edge: Some(FindingEdge {
|
|
615
|
-
from: "lib/\x1b[31mbad.dart".to_owned(),
|
|
616
|
-
to: "lib/\x07bell.dart".to_owned(),
|
|
617
|
-
specifier: "package:app/\x1bbad.dart".to_owned(),
|
|
618
|
-
kind: "import".to_owned(),
|
|
619
|
-
}),
|
|
620
|
-
actions: vec![
|
|
621
|
-
FindingAction::new("inspect-control", "Inspect \x07bell", false)
|
|
622
|
-
.with_dart_decimate_args([
|
|
623
|
-
"inspect",
|
|
624
|
-
"--format",
|
|
625
|
-
"json",
|
|
626
|
-
"--file",
|
|
627
|
-
"lib/\x1b[31mbad.dart",
|
|
628
|
-
]),
|
|
629
|
-
],
|
|
630
|
-
}],
|
|
631
|
-
clone_groups: Vec::new(),
|
|
632
|
-
complexity: Vec::new(),
|
|
633
|
-
file_scores: Vec::new(),
|
|
634
|
-
hotspots: Vec::new(),
|
|
635
|
-
refactoring_targets: Vec::new(),
|
|
636
|
-
threshold_overrides: Vec::new(),
|
|
637
|
-
feature_flags: Vec::new(),
|
|
638
|
-
security_candidates: Vec::new(),
|
|
639
|
-
attack_surface: Vec::new(),
|
|
640
|
-
runtime_coverage: None,
|
|
641
|
-
next_steps: vec![NextStep {
|
|
642
|
-
id: "inspect-control".to_owned(),
|
|
643
|
-
command: "dart-decimate inspect --file lib/\x1b[31mbad.dart".to_owned(),
|
|
644
|
-
reason: "Review \x07bell evidence".to_owned(),
|
|
645
|
-
}],
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
let rendered = render_html_report(&report);
|
|
649
|
-
|
|
650
|
-
assert!(!rendered.contains('\x1b'));
|
|
651
|
-
assert!(!rendered.contains('\x07'));
|
|
652
|
-
assert!(rendered.contains("lib/[31mbad.dart"));
|
|
653
|
-
assert!(rendered.contains("bell"));
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
#[test]
|
|
657
|
-
fn renders_omitted_details_for_summary_only_failures() {
|
|
658
|
-
let mut report = JsonReport {
|
|
659
|
-
schema_version: "dart-decimate.report.v1".to_owned(),
|
|
660
|
-
kind: "combined".to_owned(),
|
|
661
|
-
tool: "dart-decimate".to_owned(),
|
|
662
|
-
command: ReportCommand::Security,
|
|
663
|
-
verdict: Verdict::Fail,
|
|
664
|
-
summary: ReportSummary {
|
|
665
|
-
files: 1,
|
|
666
|
-
findings: 2,
|
|
667
|
-
security_candidates: 2,
|
|
668
|
-
..ReportSummary::default()
|
|
669
|
-
},
|
|
670
|
-
findings: Vec::new(),
|
|
671
|
-
clone_groups: Vec::new(),
|
|
672
|
-
complexity: Vec::new(),
|
|
673
|
-
file_scores: Vec::new(),
|
|
674
|
-
hotspots: Vec::new(),
|
|
675
|
-
refactoring_targets: Vec::new(),
|
|
676
|
-
threshold_overrides: Vec::new(),
|
|
677
|
-
feature_flags: Vec::new(),
|
|
678
|
-
security_candidates: Vec::new(),
|
|
679
|
-
attack_surface: Vec::new(),
|
|
680
|
-
runtime_coverage: None,
|
|
681
|
-
next_steps: Vec::new(),
|
|
682
|
-
};
|
|
683
|
-
report.findings.clear();
|
|
684
|
-
|
|
685
|
-
let rendered = render_html_report(&report);
|
|
686
|
-
|
|
687
|
-
assert!(rendered.contains("<h1>security report</h1>"));
|
|
688
|
-
assert!(rendered.contains("2 findings were omitted from this summary output."));
|
|
689
|
-
assert!(!rendered.contains("No findings. The selected Dart graph checks passed."));
|
|
690
|
-
}
|
|
691
|
-
}
|
|
626
|
+
mod tests;
|