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/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -44,6 +44,21 @@ dependencies, duplicated code, complex functions, dependency hygiene,
|
|
|
44
44
|
architecture drift, Flutter graph issues, security candidates, and PR-risk
|
|
45
45
|
signals.
|
|
46
46
|
|
|
47
|
+
To open the same report in your browser:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx --yes dart-decimate html .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To review only files changed from another branch or ref:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx --yes dart-decimate html . --compare origin/main
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`--compare REF` aliases `--changed-since REF`. If the ref is not found,
|
|
60
|
+
Dart Decimate suggests similar local or remote branches.
|
|
61
|
+
|
|
47
62
|
For JSON output that agents and CI can parse:
|
|
48
63
|
|
|
49
64
|
```bash
|
|
@@ -76,7 +91,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
76
91
|
"dart-decimate": "dart-decimate json ."
|
|
77
92
|
},
|
|
78
93
|
"devDependencies": {
|
|
79
|
-
"dart-decimate": "^0.0.
|
|
94
|
+
"dart-decimate": "^0.0.9"
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
97
|
```
|
|
@@ -149,6 +164,10 @@ The `html` shortcut opens the report by default. On report commands, use
|
|
|
149
164
|
`--format html` to print static HTML or `--open` to write a private temporary
|
|
150
165
|
file and open it in the default browser.
|
|
151
166
|
|
|
167
|
+
Generated finding reports group issues by type in numbered, collapsible
|
|
168
|
+
sections. Search narrows visible findings, and type filters open the selected
|
|
169
|
+
group.
|
|
170
|
+
|
|
152
171
|
Human terminal reports strip control characters from user-derived paths and
|
|
153
172
|
messages; HTML reports escape user-derived content.
|
|
154
173
|
|
|
@@ -226,6 +245,8 @@ Duplication means the same Dart code appears in more than one place.
|
|
|
226
245
|
|
|
227
246
|
Dart Decimate finds exact and semantic clone groups. Each clone group gets a stable
|
|
228
247
|
fingerprint like `dup:abc12345`, so agents can trace it before touching code.
|
|
248
|
+
Clone windows must meet both line and token thresholds; sparse duplicated blocks
|
|
249
|
+
can span more than `--min-lines`, and `line_count` reports the actual match.
|
|
229
250
|
|
|
230
251
|
Useful commands:
|
|
231
252
|
|
|
@@ -558,49 +579,8 @@ dart-decimate schema --format json | jq .issue_types
|
|
|
558
579
|
|
|
559
580
|
Current issue types:
|
|
560
581
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
unused-export
|
|
564
|
-
unused-type
|
|
565
|
-
private-type-leak
|
|
566
|
-
unused-enum-member
|
|
567
|
-
unused-class-member
|
|
568
|
-
duplicate-export
|
|
569
|
-
route-collision
|
|
570
|
-
private-widget-class
|
|
571
|
-
widget-top-level-function-boundary
|
|
572
|
-
unused-widget-param
|
|
573
|
-
unrendered-widget
|
|
574
|
-
missing-context-mounted-after-await
|
|
575
|
-
missing-entry-point
|
|
576
|
-
circular-dependency
|
|
577
|
-
re-export-cycle
|
|
578
|
-
boundary-violation
|
|
579
|
-
boundary-coverage
|
|
580
|
-
boundary-call-violation
|
|
581
|
-
policy-violation
|
|
582
|
-
unresolved-dependency
|
|
583
|
-
part-of-violation
|
|
584
|
-
unused-dependency
|
|
585
|
-
unused-dev-dependency
|
|
586
|
-
test-only-dependency
|
|
587
|
-
unused-dependency-override
|
|
588
|
-
misconfigured-dependency-override
|
|
589
|
-
unlisted-dependency
|
|
590
|
-
private-src-import
|
|
591
|
-
code-duplication
|
|
592
|
-
high-cyclomatic-complexity
|
|
593
|
-
high-cognitive-complexity
|
|
594
|
-
high-complexity
|
|
595
|
-
coverage-gap
|
|
596
|
-
high-crap-score
|
|
597
|
-
health-hotspot
|
|
598
|
-
refactoring-target
|
|
599
|
-
feature-flag
|
|
600
|
-
security-candidate
|
|
601
|
-
stale-suppression
|
|
602
|
-
missing-suppression-reason
|
|
603
|
-
```
|
|
582
|
+
See [docs/issue-types.md](docs/issue-types.md). Prefer the schema command when
|
|
583
|
+
you need the installed binary's exact list.
|
|
604
584
|
|
|
605
585
|
## CI
|
|
606
586
|
|
|
@@ -636,7 +616,9 @@ This repository already runs:
|
|
|
636
616
|
- Rust format, clippy, and tests
|
|
637
617
|
- npm package checks
|
|
638
618
|
- version sync between `Cargo.toml` and `package.json`
|
|
639
|
-
- a
|
|
619
|
+
- a PR version-bump gate requiring both package files to increase to an
|
|
620
|
+
unpublished version
|
|
621
|
+
- release guards that reject reused npm versions or tags on different commits
|
|
640
622
|
- migration checks that block previous package, command, schema, and MCP names
|
|
641
623
|
- Dependabot and weekly dependency/security audits
|
|
642
624
|
|
|
@@ -680,6 +662,7 @@ cargo fmt --check
|
|
|
680
662
|
cargo clippy --all-targets -- -D warnings
|
|
681
663
|
cargo test --all-targets
|
|
682
664
|
npm run version:check
|
|
665
|
+
npm run version:bump:check -- origin/main
|
|
683
666
|
npm run release:check
|
|
684
667
|
npm run migration:check
|
|
685
668
|
npm run pack:check
|
|
@@ -689,19 +672,25 @@ This repository forbids `unsafe_code`.
|
|
|
689
672
|
|
|
690
673
|
## Release Flow
|
|
691
674
|
|
|
692
|
-
Current version: `0.0.
|
|
675
|
+
Current version: `0.0.9`.
|
|
693
676
|
|
|
694
|
-
After the first public release, changes should go through pull requests.
|
|
677
|
+
After the first public release, changes should go through pull requests. Every
|
|
678
|
+
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
|
679
|
+
branch and to an unpublished npm version.
|
|
695
680
|
|
|
696
681
|
To release a new version:
|
|
697
682
|
|
|
698
|
-
1. Update both `Cargo.toml` and `package.json
|
|
683
|
+
1. Update both `Cargo.toml` and `package.json` to the same unpublished version.
|
|
699
684
|
2. Open a PR.
|
|
700
685
|
3. Let CI pass.
|
|
701
686
|
4. Merge to `main`.
|
|
702
687
|
5. GitHub Actions publishes `dart-decimate` to npm, creates tag `vX.Y.Z`, and
|
|
703
688
|
creates the GitHub release.
|
|
704
689
|
|
|
690
|
+
Release reruns for the same commit may update GitHub release assets. If the npm
|
|
691
|
+
package already exists for that commit, the publish step is skipped; a reused tag
|
|
692
|
+
or npm version from another commit fails.
|
|
693
|
+
|
|
705
694
|
Local hooks block stale package names, mismatched versions, reused npm versions,
|
|
706
695
|
and direct pushes to `main`.
|
|
707
696
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dart-decimate",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Rust-native codebase intelligence for Dart and Flutter module graphs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"postinstall": "node npm/scripts/postinstall.js",
|
|
30
30
|
"version:check": "node scripts/check-version-sync.mjs",
|
|
31
|
+
"version:bump:check": "node scripts/check-pr-version-bump.mjs",
|
|
31
32
|
"release:check": "node scripts/check-release-version.mjs",
|
|
32
33
|
"migration:check": "node scripts/check-dart-decimate-migration.mjs",
|
|
33
34
|
"pack:check": "npm pack --dry-run",
|
package/src/config.rs
CHANGED
|
@@ -94,10 +94,11 @@ pub struct DuplicateConfig {
|
|
|
94
94
|
/// Detection mode.
|
|
95
95
|
#[serde(default)]
|
|
96
96
|
pub mode: Option<DuplicateMode>,
|
|
97
|
-
/// Minimum tokens per clone.
|
|
97
|
+
/// Minimum normalized tokens per clone window.
|
|
98
98
|
#[serde(default, alias = "minTokens")]
|
|
99
99
|
pub min_tokens: Option<usize>,
|
|
100
|
-
/// Minimum lines per clone
|
|
100
|
+
/// Minimum normalized lines per clone window; sparse windows may grow past
|
|
101
|
+
/// this to satisfy `min_tokens`.
|
|
101
102
|
#[serde(default, alias = "minLines")]
|
|
102
103
|
pub min_lines: Option<usize>,
|
|
103
104
|
/// Minimum clone instances per group.
|
package/src/dupes/tests.rs
CHANGED
|
@@ -75,6 +75,39 @@ fn filters_short_blocks_and_generated_files() -> Result<(), Box<dyn std::error::
|
|
|
75
75
|
Ok(())
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
#[test]
|
|
79
|
+
fn detects_sparse_duplicate_blocks_that_meet_default_tokens_as_a_whole()
|
|
80
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
81
|
+
let fixture = tempfile::tempdir()?;
|
|
82
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
83
|
+
let helper = " static String formatLabel({\n required String value,\n required String fallback,\n required bool useFallback,\n required String prefix,\n }) {\n if (useFallback) {\n return '$prefix ${fallback.trim()}';\n }\n\n final normalized = value.trim().toLowerCase();\n return '$prefix $normalized';\n }\n";
|
|
84
|
+
write(
|
|
85
|
+
&fixture,
|
|
86
|
+
"lib/a.dart",
|
|
87
|
+
&format!("class AFormatter {{\n{helper} int get aOnly => 1;\n}}\n"),
|
|
88
|
+
)?;
|
|
89
|
+
write(
|
|
90
|
+
&fixture,
|
|
91
|
+
"lib/b.dart",
|
|
92
|
+
&format!("class BFormatter {{\n{helper} int get bOnly => 2;\n}}\n"),
|
|
93
|
+
)?;
|
|
94
|
+
let project = scan_project(fixture.path())?;
|
|
95
|
+
|
|
96
|
+
let report = detect_duplicates(&project, &DuplicateOptions::default())?;
|
|
97
|
+
|
|
98
|
+
assert_eq!(report.clone_groups.len(), 1);
|
|
99
|
+
let clone = &report.clone_groups[0];
|
|
100
|
+
assert!(clone.line_count > DuplicateOptions::default().min_lines);
|
|
101
|
+
assert!(clone.token_count >= DuplicateOptions::default().min_tokens);
|
|
102
|
+
assert_eq!(clone.instances.len(), 2);
|
|
103
|
+
assert_eq!(clone.instances[0].path, fixture.path().join("lib/a.dart"));
|
|
104
|
+
assert_eq!(clone.instances[0].start_line, 2);
|
|
105
|
+
assert_eq!(clone.instances[1].path, fixture.path().join("lib/b.dart"));
|
|
106
|
+
assert_eq!(clone.instances[1].start_line, 2);
|
|
107
|
+
|
|
108
|
+
Ok(())
|
|
109
|
+
}
|
|
110
|
+
|
|
78
111
|
#[test]
|
|
79
112
|
fn trace_clone_matches_fingerprint_and_source_line() -> Result<(), Box<dyn std::error::Error>> {
|
|
80
113
|
let fixture = tempfile::tempdir()?;
|
package/src/dupes.rs
CHANGED
|
@@ -48,9 +48,10 @@ impl DuplicateMode {
|
|
|
48
48
|
pub struct DuplicateOptions {
|
|
49
49
|
/// Detection mode.
|
|
50
50
|
pub mode: DuplicateMode,
|
|
51
|
-
/// Minimum token count per clone.
|
|
51
|
+
/// Minimum normalized token count per clone window.
|
|
52
52
|
pub min_tokens: usize,
|
|
53
|
-
/// Minimum line count per clone
|
|
53
|
+
/// Minimum normalized line count per clone window; sparse windows may grow
|
|
54
|
+
/// past this to satisfy `min_tokens`.
|
|
54
55
|
pub min_lines: usize,
|
|
55
56
|
/// Minimum occurrences before a clone group is reported.
|
|
56
57
|
pub min_occurrences: usize,
|
|
@@ -211,9 +212,9 @@ pub struct CodeClone {
|
|
|
211
212
|
pub fingerprint: String,
|
|
212
213
|
/// Matching block instances.
|
|
213
214
|
pub instances: Vec<CodeCloneInstance>,
|
|
214
|
-
///
|
|
215
|
+
/// Normalized lines in the matched duplicated block.
|
|
215
216
|
pub line_count: usize,
|
|
216
|
-
///
|
|
217
|
+
/// Normalized tokens in the matched duplicated block.
|
|
217
218
|
pub token_count: usize,
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -256,9 +257,9 @@ pub struct CloneTraceReport {
|
|
|
256
257
|
pub struct TraceCloneGroup {
|
|
257
258
|
/// Stable clone fingerprint.
|
|
258
259
|
pub fingerprint: String,
|
|
259
|
-
///
|
|
260
|
+
/// Normalized lines in the matched duplicated block.
|
|
260
261
|
pub line_count: usize,
|
|
261
|
-
///
|
|
262
|
+
/// Normalized tokens in the matched duplicated block.
|
|
262
263
|
pub token_count: usize,
|
|
263
264
|
/// Matching block instances.
|
|
264
265
|
pub instances: Vec<TraceCloneInstance>,
|
|
@@ -299,10 +300,21 @@ struct CloneOccurrence {
|
|
|
299
300
|
end_line: usize,
|
|
300
301
|
column: usize,
|
|
301
302
|
parent: PathBuf,
|
|
303
|
+
line_count: usize,
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
307
|
+
struct CloneWindow {
|
|
308
|
+
start: usize,
|
|
309
|
+
end: usize,
|
|
310
|
+
token_count: usize,
|
|
302
311
|
}
|
|
303
312
|
|
|
304
313
|
/// Detect duplicated Dart code blocks.
|
|
305
314
|
///
|
|
315
|
+
/// Clone windows satisfy both `min_lines` and `min_tokens`; sparse duplicated
|
|
316
|
+
/// blocks can therefore span more than `min_lines`.
|
|
317
|
+
///
|
|
306
318
|
/// # Errors
|
|
307
319
|
///
|
|
308
320
|
/// Returns [`DuplicateCodeError`] if a scanned Dart file cannot be read.
|
|
@@ -328,11 +340,8 @@ pub fn detect_duplicates(
|
|
|
328
340
|
continue;
|
|
329
341
|
}
|
|
330
342
|
|
|
331
|
-
for
|
|
332
|
-
let
|
|
333
|
-
if token_count < options.min_tokens {
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
343
|
+
for clone_window in clone_windows(&lines, options) {
|
|
344
|
+
let window = &lines[clone_window.start..=clone_window.end];
|
|
336
345
|
let text = window
|
|
337
346
|
.iter()
|
|
338
347
|
.map(|line| line.text.as_str())
|
|
@@ -352,8 +361,9 @@ pub fn detect_duplicates(
|
|
|
352
361
|
start_line: first.line,
|
|
353
362
|
end_line: last.line,
|
|
354
363
|
column: first.column,
|
|
364
|
+
line_count: window.len(),
|
|
355
365
|
},
|
|
356
|
-
token_count,
|
|
366
|
+
clone_window.token_count,
|
|
357
367
|
));
|
|
358
368
|
}
|
|
359
369
|
}
|
|
@@ -474,6 +484,32 @@ fn ranges_overlap(
|
|
|
474
484
|
left_start <= right_end && right_start <= left_end
|
|
475
485
|
}
|
|
476
486
|
|
|
487
|
+
fn clone_windows(lines: &[lex::NormalizedLine], options: &DuplicateOptions) -> Vec<CloneWindow> {
|
|
488
|
+
let min_lines = options.min_lines.max(1);
|
|
489
|
+
let mut windows = Vec::new();
|
|
490
|
+
let mut end = 0;
|
|
491
|
+
let mut token_count = 0;
|
|
492
|
+
|
|
493
|
+
for start in 0..lines.len() {
|
|
494
|
+
while end < lines.len() && (end - start < min_lines || token_count < options.min_tokens) {
|
|
495
|
+
token_count += lines[end].token_count;
|
|
496
|
+
end += 1;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if end - start >= min_lines && token_count >= options.min_tokens {
|
|
500
|
+
windows.push(CloneWindow {
|
|
501
|
+
start,
|
|
502
|
+
end: end - 1,
|
|
503
|
+
token_count,
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
token_count -= lines[start].token_count;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
windows
|
|
511
|
+
}
|
|
512
|
+
|
|
477
513
|
fn duplicate_stats(
|
|
478
514
|
analyzed_lines: usize,
|
|
479
515
|
clone_groups: &[CodeClone],
|
|
@@ -513,6 +549,7 @@ fn clone_group_from_occurrences(
|
|
|
513
549
|
let mut seen = BTreeSet::<(PathBuf, usize, usize)>::new();
|
|
514
550
|
let mut instances = Vec::new();
|
|
515
551
|
let mut token_count = 0;
|
|
552
|
+
let mut line_count = 0;
|
|
516
553
|
let mut parents = BTreeSet::new();
|
|
517
554
|
|
|
518
555
|
for (occurrence, tokens) in occurrences {
|
|
@@ -525,6 +562,7 @@ fn clone_group_from_occurrences(
|
|
|
525
562
|
}
|
|
526
563
|
parents.insert(occurrence.parent);
|
|
527
564
|
token_count = token_count.max(tokens);
|
|
565
|
+
line_count = line_count.max(occurrence.line_count);
|
|
528
566
|
instances.push(CodeCloneInstance {
|
|
529
567
|
path: occurrence.path,
|
|
530
568
|
start_line: occurrence.start_line,
|
|
@@ -547,7 +585,7 @@ fn clone_group_from_occurrences(
|
|
|
547
585
|
Some(CodeClone {
|
|
548
586
|
fingerprint: fingerprint.to_owned(),
|
|
549
587
|
instances,
|
|
550
|
-
line_count
|
|
588
|
+
line_count,
|
|
551
589
|
token_count,
|
|
552
590
|
})
|
|
553
591
|
}
|
|
@@ -13,9 +13,9 @@ pub struct JsonCloneGroup {
|
|
|
13
13
|
pub fingerprint: String,
|
|
14
14
|
/// Matching clone instances.
|
|
15
15
|
pub instances: Vec<JsonCloneInstance>,
|
|
16
|
-
///
|
|
16
|
+
/// Normalized lines in the matched duplicated block.
|
|
17
17
|
pub line_count: usize,
|
|
18
|
-
///
|
|
18
|
+
/// Normalized tokens in the matched duplicated block.
|
|
19
19
|
pub token_count: usize,
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/// Report UI tokens, layout, and static progressive-enhancement behavior.
|
|
2
|
+
pub(super) fn render_style(html: &mut String) {
|
|
3
|
+
html.push_str(
|
|
4
|
+
r#"<style>
|
|
5
|
+
:root {
|
|
6
|
+
color-scheme: dark;
|
|
7
|
+
--bg: #090909;
|
|
8
|
+
--surface: #121212;
|
|
9
|
+
--surface-raised: #181818;
|
|
10
|
+
--line: #2d2d2f;
|
|
11
|
+
--line-strong: #3a3a3d;
|
|
12
|
+
--text: #f4f4f5;
|
|
13
|
+
--muted: #ababaf;
|
|
14
|
+
--accent: #8fdcff;
|
|
15
|
+
--focus: #c7f0ff;
|
|
16
|
+
--error: #ff6b6b;
|
|
17
|
+
--warn: #ffd166;
|
|
18
|
+
--pass: #64d98a;
|
|
19
|
+
}
|
|
20
|
+
* { box-sizing: border-box; }
|
|
21
|
+
[hidden] { display: none !important; }
|
|
22
|
+
body {
|
|
23
|
+
margin: 0;
|
|
24
|
+
background: var(--bg);
|
|
25
|
+
color: var(--text);
|
|
26
|
+
font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
27
|
+
}
|
|
28
|
+
main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 52px; }
|
|
29
|
+
h1, h2, h3, p { margin: 0; }
|
|
30
|
+
h1 { font-size: 2rem; letter-spacing: 0; line-height: 1.15; }
|
|
31
|
+
h2 { margin-top: 30px; font-size: 1.25rem; }
|
|
32
|
+
.topline { color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
|
|
33
|
+
.hero { border-bottom: 1px solid var(--line); padding-bottom: 22px; }
|
|
34
|
+
.verdict { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; }
|
|
35
|
+
.pass { color: var(--pass); }
|
|
36
|
+
.fail, .error { color: var(--error); }
|
|
37
|
+
.warning { color: var(--warn); }
|
|
38
|
+
.metrics, .groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 18px; margin-top: 22px; }
|
|
39
|
+
.metric { border-top: 1px solid var(--line); padding-top: 10px; }
|
|
40
|
+
.group, .step { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
|
|
41
|
+
.metric span, .group span, .label { color: var(--muted); display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
|
|
42
|
+
.metric strong { display: block; margin-top: 4px; font-size: 1.35rem; }
|
|
43
|
+
.group p { margin-top: 8px; color: var(--text); }
|
|
44
|
+
.finding-tools { display: grid; gap: 12px; margin-top: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
|
|
45
|
+
.finding-tools label, .filter-label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
|
|
46
|
+
.finding-tools input { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; padding: 8px 10px; }
|
|
47
|
+
.finding-tools input:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
|
|
48
|
+
.filter-set { display: grid; gap: 8px; }
|
|
49
|
+
.filter-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
50
|
+
.type-filter { min-height: 44px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; font: inherit; padding: 8px 10px; text-align: left; }
|
|
51
|
+
.type-filter:hover { border-color: var(--muted); }
|
|
52
|
+
.type-filter:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
|
53
|
+
.type-filter[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: #10232b; }
|
|
54
|
+
.finding-status, .empty-results { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
|
|
55
|
+
.finding-groups { display: grid; gap: 12px; margin-top: 14px; }
|
|
56
|
+
.finding-group { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
|
|
57
|
+
.finding-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; list-style: none; padding: 14px 16px; }
|
|
58
|
+
.finding-group > summary::-webkit-details-marker { display: none; }
|
|
59
|
+
.finding-group > summary:hover { background: var(--surface-raised); }
|
|
60
|
+
.finding-group > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
|
|
61
|
+
.finding-group[open] > summary { border-bottom: 1px solid var(--line); }
|
|
62
|
+
.summary-title { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; }
|
|
63
|
+
.summary-text { display: grid; gap: 3px; min-width: 0; }
|
|
64
|
+
.group-number { color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
65
|
+
.summary-title strong { font-size: 1rem; }
|
|
66
|
+
.summary-right { display: inline-flex; align-items: center; gap: 12px; }
|
|
67
|
+
.summary-meta { color: var(--muted); font-size: 13px; text-align: right; }
|
|
68
|
+
.chevron { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transform-origin: center; }
|
|
69
|
+
.finding-group[open] .chevron { transform: rotate(225deg); }
|
|
70
|
+
.findings { display: grid; gap: 12px; margin-top: 14px; }
|
|
71
|
+
.finding-group .findings { margin-top: 0; padding: 12px; }
|
|
72
|
+
.finding { background: var(--surface-raised); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
|
|
73
|
+
.finding header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
|
|
74
|
+
.finding h3 { font-size: 1rem; }
|
|
75
|
+
.rule, .location, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
76
|
+
.rule { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
|
|
77
|
+
.section { margin-top: 10px; }
|
|
78
|
+
.section p { margin-top: 3px; overflow-wrap: anywhere; }
|
|
79
|
+
.evidence { margin: 8px 0 0; padding-left: 18px; color: var(--text); }
|
|
80
|
+
.evidence li { margin: 3px 0; overflow-wrap: anywhere; }
|
|
81
|
+
.command { overflow-wrap: anywhere; color: var(--accent); }
|
|
82
|
+
a { color: var(--accent); text-decoration: none; }
|
|
83
|
+
a:hover { text-decoration: underline; }
|
|
84
|
+
@media (max-width: 720px) {
|
|
85
|
+
main { padding: 24px 16px 44px; }
|
|
86
|
+
h1 { font-size: 1.65rem; }
|
|
87
|
+
.finding-group > summary { align-items: flex-start; flex-direction: column; }
|
|
88
|
+
.summary-right { justify-content: space-between; width: 100%; }
|
|
89
|
+
.summary-meta { text-align: left; }
|
|
90
|
+
}
|
|
91
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
92
|
+
.finding-group > summary, .finding-tools input, .type-filter { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
|
|
93
|
+
.chevron { transition: transform .16s ease; }
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
96
|
+
"#,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub(super) fn render_interaction_script(html: &mut String) {
|
|
101
|
+
html.push_str(
|
|
102
|
+
r#"<script>
|
|
103
|
+
(() => {
|
|
104
|
+
const controls = document.querySelector("[data-finding-controls]");
|
|
105
|
+
if (!controls) return;
|
|
106
|
+
const searchInput = controls.querySelector("[data-finding-search]");
|
|
107
|
+
const filterButtons = Array.from(controls.querySelectorAll("[data-finding-filter]"));
|
|
108
|
+
const status = controls.querySelector("[data-finding-status]");
|
|
109
|
+
const emptyResults = document.querySelector("[data-empty-results]");
|
|
110
|
+
const groups = Array.from(document.querySelectorAll("[data-finding-group]"));
|
|
111
|
+
if (!searchInput || filterButtons.length === 0 || !status || groups.length === 0) return;
|
|
112
|
+
const totalFindings = Number(status.dataset.total || 0);
|
|
113
|
+
let selectedType = "";
|
|
114
|
+
|
|
115
|
+
const syncButtons = () => {
|
|
116
|
+
for (const button of filterButtons) {
|
|
117
|
+
button.setAttribute("aria-pressed", button.dataset.kind === selectedType ? "true" : "false");
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const update = () => {
|
|
122
|
+
const query = searchInput.value.trim().toLowerCase();
|
|
123
|
+
let visibleFindings = 0;
|
|
124
|
+
let visibleGroups = 0;
|
|
125
|
+
|
|
126
|
+
for (const group of groups) {
|
|
127
|
+
const typeMatches = !selectedType || group.dataset.kind === selectedType;
|
|
128
|
+
let groupMatches = 0;
|
|
129
|
+
const findings = Array.from(group.querySelectorAll("[data-finding]"));
|
|
130
|
+
|
|
131
|
+
for (const finding of findings) {
|
|
132
|
+
const textMatches = !query || finding.textContent.toLowerCase().includes(query);
|
|
133
|
+
const visible = typeMatches && textMatches;
|
|
134
|
+
finding.hidden = !visible;
|
|
135
|
+
if (visible) groupMatches += 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
group.hidden = groupMatches === 0;
|
|
139
|
+
if (groupMatches > 0) {
|
|
140
|
+
visibleGroups += 1;
|
|
141
|
+
visibleFindings += groupMatches;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
status.textContent = `Showing ${visibleFindings} of ${totalFindings} findings in ${visibleGroups} ${visibleGroups === 1 ? "type" : "types"}.`;
|
|
146
|
+
if (emptyResults) emptyResults.hidden = visibleFindings !== 0;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
searchInput.addEventListener("input", update);
|
|
150
|
+
for (const button of filterButtons) {
|
|
151
|
+
button.addEventListener("click", () => {
|
|
152
|
+
selectedType = button.dataset.kind || "";
|
|
153
|
+
syncButtons();
|
|
154
|
+
if (selectedType) {
|
|
155
|
+
for (const group of groups) group.open = group.dataset.kind === selectedType;
|
|
156
|
+
}
|
|
157
|
+
update();
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
})();
|
|
161
|
+
</script>
|
|
162
|
+
"#,
|
|
163
|
+
);
|
|
164
|
+
}
|