duvis 0.1.6

Disk usage visualizer for both AI and humans
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
use serde::Serialize;
use std::fmt;

/// Whether a category is part of the always-shown core vocabulary or an
/// extended category that only surfaces in the legend / sidebar when at
/// least one entry of that category is actually present in the scan.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Tier {
    /// Universal categories. The color and label are reserved in the legend
    /// regardless of whether anything was matched, so the visual vocabulary
    /// stays stable across scans.
    Core,
    /// Niche categories that would be noise on a typical project tree but
    /// are valuable when present (e.g. a 5 GB `model_cache` block on an AI
    /// dev machine, or a 50 GB `vm_image` on a VM user's disk).
    Extended,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, clap::ValueEnum)]
#[serde(rename_all = "snake_case")]
#[clap(rename_all = "snake_case")]
pub enum Category {
    // ----- Core -----
    Cache,
    Build,
    Log,
    Media,
    Vcs,
    Ide,
    Other,
    // ----- Extended -----
    Archive,
    Installer,
    VmImage,
    ModelCache,
    Backup,
}

impl Category {
    pub fn label(&self) -> &'static str {
        match self {
            Category::Cache => "cache",
            Category::Build => "build",
            Category::Log => "log",
            Category::Media => "media",
            Category::Vcs => "vcs",
            Category::Ide => "ide",
            Category::Other => "other",
            Category::Archive => "archive",
            Category::Installer => "installer",
            Category::VmImage => "vm_image",
            Category::ModelCache => "model_cache",
            Category::Backup => "backup",
        }
    }

    pub fn tier(&self) -> Tier {
        match self {
            Category::Cache
            | Category::Build
            | Category::Log
            | Category::Media
            | Category::Vcs
            | Category::Ide
            | Category::Other => Tier::Core,
            Category::Archive
            | Category::Installer
            | Category::VmImage
            | Category::ModelCache
            | Category::Backup => Tier::Extended,
        }
    }
}

impl fmt::Display for Category {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.label())
    }
}

// ============================================================================
// Rule tables — shared between `classify_*` and `explain_*` so the truth lives
// in exactly one place.
// ============================================================================

/// AI model stores (re-downloadable; large enough to deserve their own
/// category on AI dev machines). Checked before the more generic Cache rules
/// so e.g. `.ollama` wins as ModelCache instead of being dragged into Cache.
const MODEL_CACHE_DIRS: &[&str] = &[".ollama", ".lmstudio", ".huggingface"];

/// OS-level backup stores (Apple Time Machine etc.).
const BACKUP_DIRS: &[&str] = &["time machine backups", "backups.backupdb"];

const CACHE_DIRS: &[&str] = &[
    "node_modules",
    ".cache",
    "__pycache__",
    ".npm",
    ".yarn",
    ".pnpm-store",
    "caches",
    ".gradle",
    ".nuget",
    ".pub-cache",
    "pods",
    ".cocoapods",
    ".cargo",
    "bower_components",
    ".tmp",
    "tmp",
    "temp",
    ".temp",
    ".trash",
    // Language version managers + tool installs (re-downloadable)
    ".rustup",
    ".pyenv",
    ".rbenv",
    ".nvm",
    ".volta",
    ".asdf",
    "mise",
    ".pipx",
    "pipx",
    ".poetry",
    ".composer",
    ".m2",
    ".ivy2",
    ".sbt",
    ".stack",
    ".cabal",
    ".deno",
    ".bun",
    // Container / VM bundles (re-buildable / re-downloadable)
    ".docker",
    "vm_bundles",
];

const BUILD_DIRS: &[&str] = &[
    "target",
    "dist",
    "build",
    "out",
    ".next",
    ".nuxt",
    ".output",
    ".turbo",
    ".angular",
    "_build",
    "cmake-build-debug",
    "cmake-build-release",
];

const LOG_DIRS: &[&str] = &["logs", "log", ".logs"];

const VCS_DIRS: &[&str] = &[".git", ".svn", ".hg", ".jj", ".bzr", "_darcs", ".fossil"];

const IDE_DIRS: &[&str] = &[
    ".idea",
    ".vscode",
    ".vscode-insiders",
    ".vscode-server",
    ".vs",
    ".eclipse",
    ".settings",
    ".cursor",
    ".cursor-server",
    ".windsurf",
    ".zed",
    ".fleet",
];

/// Special filenames matched by suffix (not extension). Currently OrbStack's
/// raw VM disk image, which is literally `data.img.raw` — matched by name so
/// every Sony α RAW photo isn't dragged into vm_image just for its `.raw` tail.
const VM_IMAGE_FILE_SUFFIXES: &[&str] = &["data.img.raw"];

const VM_IMAGE_EXTENSIONS: &[&str] = &[
    // `.iso` is OS install media most of the time, but it can also be a game
    // ROM dump. Bucketed here for now — both are large blobs the user knows
    // they put there.
    ".vdi", ".vmdk", ".qcow2", ".vhd", ".vhdx", ".iso",
];

const INSTALLER_EXTENSIONS: &[&str] = &[
    ".dmg",      // macOS disk image
    ".pkg",      // macOS installer package
    ".msi",      // Windows installer
    ".exe",      // Windows executable / installer
    ".deb",      // Debian package
    ".rpm",      // RedHat package
    ".appimage", // Linux AppImage
    ".snap",     // Linux Snap package
    ".flatpak",  // Linux Flatpak
    ".apk",      // Android package
];

/// Match the common "single-extension" tail. Multi-part extensions like
/// `.tar.gz` are still caught because they end in `.gz`.
const ARCHIVE_EXTENSIONS: &[&str] = &[
    ".zip", ".tar", ".tgz", ".tbz2", ".txz", ".gz", ".bz2", ".xz", ".7z", ".rar", ".zst",
];

const BACKUP_EXTENSIONS: &[&str] = &[".bak", ".backup", ".old"];

// `#[rustfmt::skip]` keeps the per-section grouping (Image / Video / Audio)
// readable. Without it rustfmt collapses the trailing `// Audio.` comment
// into the preceding video line, which makes the file harder to scan.
#[rustfmt::skip]
const MEDIA_EXTENSIONS: &[&str] = &[
    // Image (including camera RAW formats — `.raw` for generic exporters,
    // `.arw` Sony α, `.cr2` Canon, `.nef` Nikon, `.dng` Adobe DNG).
    // The literal `data.img.raw` OrbStack VM image is matched earlier in
    // `explain_file` and never reaches here, so reintroducing `.raw` to
    // media doesn't bring back the VM-image-as-media confusion.
    ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp", ".ico", ".tiff", ".heic", ".heif",
    ".psd", ".raw", ".arw", ".cr2", ".nef", ".dng",
    // Video.
    // `.ts` is intentionally excluded: while it's the MPEG transport-stream extension,
    // TypeScript files are vastly more common in real codebases and being miscategorized
    // as `media` is more harmful than missing the rare transport-stream file.
    ".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".webm", ".m4v", ".3gp",
    // Audio.
    ".mp3", ".wav", ".flac", ".aac", ".ogg", ".wma", ".m4a", ".opus", ".aiff",
];

// ============================================================================
// Classification with explanation
// ============================================================================

/// Why an entry was assigned a category. Surfaced via `--explain-category`
/// so anyone debugging "why is this `cache`?" can see the rule that fired
/// without reading the source.
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum ClassificationReason {
    /// Matched an exact directory-name rule (case-insensitive).
    DirNameExact { needle: &'static str },
    /// Directory name contains the substring "cache" (case-insensitive).
    /// Catches things like `GPUCache` and `Code Cache` that aren't worth
    /// listing individually.
    DirNameContainsCache,
    /// Matched a special filename suffix (e.g. `data.img.raw`). Distinct
    /// from a plain extension because the rule keys off more than the dot
    /// suffix.
    FileNameSuffix { needle: &'static str },
    /// Matched a file extension (e.g. `.log`, `.gz`).
    FileExtension { needle: &'static str },
    /// No rule matched; defaulted to `other`.
    Default,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct Classification {
    pub category: Category,
    pub reason: ClassificationReason,
}

impl ClassificationReason {
    /// Human-readable one-liner used in the text output of
    /// `--explain-category`. JSON output uses serde's tagged form instead.
    pub fn describe(&self) -> String {
        match self {
            ClassificationReason::DirNameExact { needle } => {
                format!("matched directory rule: {needle}")
            }
            ClassificationReason::DirNameContainsCache => {
                "directory name contains \"cache\"".to_string()
            }
            ClassificationReason::FileNameSuffix { needle } => {
                format!("matched filename suffix: {needle}")
            }
            ClassificationReason::FileExtension { needle } => {
                format!("matched file extension: {needle}")
            }
            ClassificationReason::Default => "no rule matched; defaulted to other".to_string(),
        }
    }
}

/// Same logic as [`classify_dir`] but also records *which* rule matched.
/// `classify_dir` is the thin wrapper used in the hot scanning path; this
/// is the one called by `--explain-category` for transparency.
pub fn explain_dir(name: &str) -> Classification {
    let lower = name.to_lowercase();

    // ----- Extended (checked first so they win over the more generic
    // Cache rules below; e.g. `.ollama` is more specifically a model
    // cache than just "a cache directory") -----
    if let Some(needle) = first_exact_match(&lower, MODEL_CACHE_DIRS) {
        return Classification {
            category: Category::ModelCache,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }
    if let Some(needle) = first_exact_match(&lower, BACKUP_DIRS) {
        return Classification {
            category: Category::Backup,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }

    // ----- Core -----
    if let Some(needle) = first_exact_match(&lower, CACHE_DIRS) {
        return Classification {
            category: Category::Cache,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }
    if lower.contains("cache") {
        return Classification {
            category: Category::Cache,
            reason: ClassificationReason::DirNameContainsCache,
        };
    }
    if let Some(needle) = first_exact_match(&lower, BUILD_DIRS) {
        return Classification {
            category: Category::Build,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }
    if let Some(needle) = first_exact_match(&lower, LOG_DIRS) {
        return Classification {
            category: Category::Log,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }
    if let Some(needle) = first_exact_match(&lower, VCS_DIRS) {
        return Classification {
            category: Category::Vcs,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }
    if let Some(needle) = first_exact_match(&lower, IDE_DIRS) {
        return Classification {
            category: Category::Ide,
            reason: ClassificationReason::DirNameExact { needle },
        };
    }

    Classification {
        category: Category::Other,
        reason: ClassificationReason::Default,
    }
}

/// Same logic as [`classify_file`] but also records *which* rule matched.
pub fn explain_file(name: &str) -> Classification {
    let lower = name.to_lowercase();

    if let Some(needle) = first_suffix_match(&lower, &[".log"]) {
        return Classification {
            category: Category::Log,
            reason: ClassificationReason::FileExtension { needle },
        };
    }

    // ----- Extended file types (checked before media so a `data.img.raw`
    // VM image isn't dragged into media just because of its `.raw` tail) -----
    if let Some(needle) = first_suffix_match(&lower, VM_IMAGE_FILE_SUFFIXES) {
        return Classification {
            category: Category::VmImage,
            reason: ClassificationReason::FileNameSuffix { needle },
        };
    }
    if let Some(needle) = first_suffix_match(&lower, VM_IMAGE_EXTENSIONS) {
        return Classification {
            category: Category::VmImage,
            reason: ClassificationReason::FileExtension { needle },
        };
    }
    if let Some(needle) = first_suffix_match(&lower, INSTALLER_EXTENSIONS) {
        return Classification {
            category: Category::Installer,
            reason: ClassificationReason::FileExtension { needle },
        };
    }
    if let Some(needle) = first_suffix_match(&lower, ARCHIVE_EXTENSIONS) {
        return Classification {
            category: Category::Archive,
            reason: ClassificationReason::FileExtension { needle },
        };
    }
    if let Some(needle) = first_suffix_match(&lower, BACKUP_EXTENSIONS) {
        return Classification {
            category: Category::Backup,
            reason: ClassificationReason::FileExtension { needle },
        };
    }
    if let Some(needle) = first_suffix_match(&lower, MEDIA_EXTENSIONS) {
        return Classification {
            category: Category::Media,
            reason: ClassificationReason::FileExtension { needle },
        };
    }

    Classification {
        category: Category::Other,
        reason: ClassificationReason::Default,
    }
}

fn first_exact_match(lower: &str, needles: &[&'static str]) -> Option<&'static str> {
    needles.iter().copied().find(|n| *n == lower)
}

fn first_suffix_match(lower: &str, needles: &[&'static str]) -> Option<&'static str> {
    needles.iter().copied().find(|n| lower.ends_with(*n))
}

/// Classify a directory by its name.
pub fn classify_dir(name: &str) -> Category {
    explain_dir(name).category
}

/// Classify a file by its name (extension or, for a few special cases,
/// full filename).
pub fn classify_file(name: &str) -> Category {
    explain_file(name).category
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn classifies_known_directories() {
        assert_eq!(classify_dir("node_modules"), Category::Cache);
        assert_eq!(classify_dir("__pycache__"), Category::Cache);
        assert_eq!(classify_dir("target"), Category::Build);
        assert_eq!(classify_dir("dist"), Category::Build);
        assert_eq!(classify_dir("logs"), Category::Log);
        assert_eq!(classify_dir(".git"), Category::Vcs);
        assert_eq!(classify_dir(".idea"), Category::Ide);
        assert_eq!(classify_dir("src"), Category::Other);
    }

    #[test]
    fn classifies_directory_names_case_insensitively() {
        assert_eq!(classify_dir("Node_Modules"), Category::Cache);
        assert_eq!(classify_dir(".GIT"), Category::Vcs);
    }

    #[test]
    fn classifies_language_toolchains_as_cache() {
        assert_eq!(classify_dir(".rustup"), Category::Cache);
        assert_eq!(classify_dir(".pyenv"), Category::Cache);
        assert_eq!(classify_dir(".nvm"), Category::Cache);
        assert_eq!(classify_dir("mise"), Category::Cache);
        assert_eq!(classify_dir("pipx"), Category::Cache);
        assert_eq!(classify_dir(".docker"), Category::Cache);
        assert_eq!(classify_dir("vm_bundles"), Category::Cache);
    }

    #[test]
    fn classifies_additional_ide_and_vcs() {
        assert_eq!(classify_dir(".vscode-insiders"), Category::Ide);
        assert_eq!(classify_dir(".cursor"), Category::Ide);
        assert_eq!(classify_dir(".zed"), Category::Ide);
        assert_eq!(classify_dir(".jj"), Category::Vcs);
    }

    #[test]
    fn partial_match_catches_cache_directories() {
        assert_eq!(classify_dir("GPUCache"), Category::Cache);
        assert_eq!(classify_dir("Code Cache"), Category::Cache);
    }

    #[test]
    fn classifies_files_by_extension() {
        assert_eq!(classify_file("debug.log"), Category::Log);
        assert_eq!(classify_file("photo.JPG"), Category::Media);
        assert_eq!(classify_file("video.mp4"), Category::Media);
        assert_eq!(classify_file("song.mp3"), Category::Media);
        assert_eq!(classify_file("main.rs"), Category::Other);
    }

    #[test]
    fn typescript_files_are_not_media() {
        // `.ts` is the MPEG transport-stream extension, but TypeScript is far
        // more common in modern codebases. Keep these classified as `other`
        // so we don't surprise users with `index.ts` showing up as `media`.
        assert_eq!(classify_file("index.ts"), Category::Other);
        assert_eq!(classify_file("App.tsx"), Category::Other);
        assert_eq!(classify_file("eleventy.config.ts"), Category::Other);
    }

    // ----- Extended categories ------------------------------------------------

    #[test]
    fn ai_model_stores_classify_as_model_cache() {
        // Beats the more generic Cache rules because ModelCache is checked first.
        assert_eq!(classify_dir(".ollama"), Category::ModelCache);
        assert_eq!(classify_dir(".lmstudio"), Category::ModelCache);
        assert_eq!(classify_dir(".huggingface"), Category::ModelCache);
    }

    #[test]
    fn time_machine_backup_directories_classify_as_backup() {
        assert_eq!(classify_dir("Time Machine Backups"), Category::Backup);
        assert_eq!(classify_dir("Backups.backupdb"), Category::Backup);
    }

    #[test]
    fn installer_files_classify_as_installer() {
        assert_eq!(classify_file("Codex.dmg"), Category::Installer);
        assert_eq!(classify_file("googlechrome.dmg"), Category::Installer);
        assert_eq!(classify_file("setup.exe"), Category::Installer);
        assert_eq!(classify_file("package.deb"), Category::Installer);
        assert_eq!(classify_file("MyApp.AppImage"), Category::Installer);
    }

    #[test]
    fn vm_images_classify_as_vm_image() {
        assert_eq!(classify_file("disk.vdi"), Category::VmImage);
        assert_eq!(classify_file("disk.vmdk"), Category::VmImage);
        assert_eq!(classify_file("disk.qcow2"), Category::VmImage);
        // OrbStack's macOS-side raw disk image — name match, not just `.raw`.
        assert_eq!(classify_file("data.img.raw"), Category::VmImage);
    }

    #[test]
    fn raw_photo_classifies_as_media() {
        // Sony α uses `.arw` natively, but third-party exporters and older
        // firmwares still emit generic `.raw` files; both belong with the
        // rest of the camera RAW formats (`.cr2`, `.nef`, `.dng`). The
        // OrbStack `data.img.raw` literal is matched earlier in
        // `explain_file` so it still wins as VmImage and never reaches the
        // media extension list.
        assert_eq!(classify_file("DSC0001.raw"), Category::Media);
        assert_eq!(classify_file("DSC0001.arw"), Category::Media);
        assert_eq!(classify_file("data.img.raw"), Category::VmImage);
    }

    #[test]
    fn archive_files_classify_as_archive() {
        assert_eq!(classify_file("snapshot.zip"), Category::Archive);
        assert_eq!(classify_file("source.tar.gz"), Category::Archive);
        assert_eq!(classify_file("source.tgz"), Category::Archive);
        assert_eq!(classify_file("blob.7z"), Category::Archive);
        assert_eq!(classify_file("data.zst"), Category::Archive);
    }

    #[test]
    fn backup_files_classify_as_backup() {
        assert_eq!(classify_file("config.bak"), Category::Backup);
        assert_eq!(classify_file("notes.old"), Category::Backup);
    }

    #[test]
    fn tier_split_matches_intent() {
        // Core categories.
        for c in [
            Category::Cache,
            Category::Build,
            Category::Log,
            Category::Media,
            Category::Vcs,
            Category::Ide,
            Category::Other,
        ] {
            assert_eq!(c.tier(), Tier::Core, "{c:?} should be Core");
        }
        // Extended categories.
        for c in [
            Category::Archive,
            Category::Installer,
            Category::VmImage,
            Category::ModelCache,
            Category::Backup,
        ] {
            assert_eq!(c.tier(), Tier::Extended, "{c:?} should be Extended");
        }
    }

    // ----- Explain ------------------------------------------------------------

    #[test]
    fn explain_dir_reports_exact_match_needle() {
        let c = explain_dir("node_modules");
        assert_eq!(c.category, Category::Cache);
        assert_eq!(
            c.reason,
            ClassificationReason::DirNameExact {
                needle: "node_modules"
            }
        );
    }

    #[test]
    fn explain_dir_reports_extended_winning_over_cache() {
        let c = explain_dir(".ollama");
        assert_eq!(c.category, Category::ModelCache);
        assert_eq!(
            c.reason,
            ClassificationReason::DirNameExact { needle: ".ollama" }
        );
    }

    #[test]
    fn explain_dir_reports_partial_cache_match() {
        let c = explain_dir("GPUCache");
        assert_eq!(c.category, Category::Cache);
        assert_eq!(c.reason, ClassificationReason::DirNameContainsCache);
    }

    #[test]
    fn explain_dir_reports_default_when_unmatched() {
        let c = explain_dir("src");
        assert_eq!(c.category, Category::Other);
        assert_eq!(c.reason, ClassificationReason::Default);
    }

    #[test]
    fn explain_file_reports_extension_needle() {
        let c = explain_file("debug.log");
        assert_eq!(c.category, Category::Log);
        assert_eq!(
            c.reason,
            ClassificationReason::FileExtension { needle: ".log" }
        );
        let c = explain_file("source.tar.gz");
        assert_eq!(c.category, Category::Archive);
        assert_eq!(
            c.reason,
            ClassificationReason::FileExtension { needle: ".gz" }
        );
    }

    #[test]
    fn explain_file_reports_filename_suffix_for_orbstack() {
        let c = explain_file("data.img.raw");
        assert_eq!(c.category, Category::VmImage);
        assert_eq!(
            c.reason,
            ClassificationReason::FileNameSuffix {
                needle: "data.img.raw"
            }
        );
    }

    #[test]
    fn explain_file_reports_default_when_unmatched() {
        let c = explain_file("main.rs");
        assert_eq!(c.category, Category::Other);
        assert_eq!(c.reason, ClassificationReason::Default);
    }
}