Skip to main content

max / makeover

makeover: adopt universal clippy/lint baseline; warnings to zero Add the shared pedantic + unreachable_pub baseline. This is a color-space math crate, so it carries a crate-level allow for many_single_char_names (r/g/b/l/m/s channel names) and unreadable_literal (the published OKLab/ sRGB matrix constants, already kept at spec precision under excessive_precision). Three let-else conversions in the theme loader. clippy --all-targets clean, cargo fmt clean, 40 tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-07-23 13:22 UTC
Commit: d3f779ebb9d8b35f2294da4659dac34fd74488cd
Parent: 01141dd
2 files changed, +56 insertions, -26 deletions
M Cargo.toml +32
@@ -13,3 +13,35 @@ include_dir = "0.7"
13 13
14 14 [dev-dependencies]
15 15 tempfile = "3"
16 +
17 + [lints.rust]
18 + unused = "warn"
19 + unreachable_pub = "warn"
20 +
21 + [lints.clippy]
22 + pedantic = { level = "warn", priority = -1 }
23 + # Allow-list tuned from a measured breakdown across server/multithreaded/pter
24 + # (2026-07-22). These are the high-churn / low-signal pedantic lints; everything
25 + # else in `pedantic` stays a warning. Keep this block identical across repos.
26 + module_name_repetitions = "allow"
27 + # Doc lints — no docs-completeness push underway.
28 + missing_errors_doc = "allow"
29 + missing_panics_doc = "allow"
30 + doc_markdown = "allow"
31 + # Numeric casts — endemic and mostly intentional in size/byte math.
32 + cast_possible_truncation = "allow"
33 + cast_sign_loss = "allow"
34 + cast_precision_loss = "allow"
35 + cast_possible_wrap = "allow"
36 + cast_lossless = "allow"
37 + # Subjective structure/style nags — high churn, low signal.
38 + must_use_candidate = "allow"
39 + too_many_lines = "allow"
40 + struct_excessive_bools = "allow"
41 + similar_names = "allow"
42 + items_after_statements = "allow"
43 + single_match_else = "allow"
44 + # Frequent false-positives in TUI/router-heavy code — added from the buckets breakdown.
45 + match_same_arms = "allow"
46 + unnecessary_wraps = "allow"
47 + type_complexity = "allow"
M src/lib.rs +24 -26
@@ -34,6 +34,10 @@
34 34 //! four = "#ebcb8b"; five = "#b48ead"; six = "#88c0d0"
35 35 //! ```
36 36
37 + // Color-space math: single-letter channel names (r/g/b/l/m/s) and the published
38 + // high-precision OKLab/sRGB matrix constants are the domain vocabulary here.
39 + #![allow(clippy::many_single_char_names, clippy::unreadable_literal)]
40 +
37 41 use serde::Serialize;
38 42 use std::collections::{BTreeMap, HashMap};
39 43 use std::path::{Path, PathBuf};
@@ -554,7 +558,7 @@ pub fn validate_theme_id(id: &str) -> Result<(), String> {
554 558 .chars()
555 559 .all(|c| c.is_alphanumeric() || c == '-' || c == '_')
556 560 {
557 - return Err(format!("Invalid theme ID: {}", id));
561 + return Err(format!("Invalid theme ID: {id}"));
558 562 }
559 563 Ok(())
560 564 }
@@ -591,7 +595,7 @@ pub fn extract_colors(table: &toml::Table) -> HashMap<String, String> {
591 595 if let Some(sect) = table.get(*section).and_then(|s| s.as_table()) {
592 596 for (key, val) in sect {
593 597 if let Some(color) = val.as_str() {
594 - colors.insert(format!("{}.{}", section, key), color.to_string());
598 + colors.insert(format!("{section}.{key}"), color.to_string());
595 599 }
596 600 }
597 601 }
@@ -607,15 +611,13 @@ pub fn list_themes_from_dirs(dirs: &[(PathBuf, bool)]) -> Vec<ThemeMeta> {
607 611 let mut seen: HashMap<String, ThemeMeta> = HashMap::new();
608 612
609 613 for (dir, is_custom) in dirs {
610 - let entries = match std::fs::read_dir(dir) {
611 - Ok(e) => e,
612 - Err(_) => continue,
614 + let Ok(entries) = std::fs::read_dir(dir) else {
615 + continue;
613 616 };
614 617
615 618 for entry in entries {
616 - let entry = match entry {
617 - Ok(e) => e,
618 - Err(_) => continue,
619 + let Ok(entry) = entry else {
620 + continue;
619 621 };
620 622 let path = entry.path();
621 623 if path.extension().and_then(|e| e.to_str()) != Some("toml") {
@@ -628,9 +630,8 @@ pub fn list_themes_from_dirs(dirs: &[(PathBuf, bool)]) -> Vec<ThemeMeta> {
628 630 .unwrap_or_default()
629 631 .to_string();
630 632
631 - let content = match std::fs::read_to_string(&path) {
632 - Ok(c) => c,
633 - Err(_) => continue,
633 + let Ok(content) = std::fs::read_to_string(&path) else {
634 + continue;
634 635 };
635 636 let table: toml::Table = match content.parse() {
636 637 Ok(t) => t,
@@ -651,7 +652,7 @@ pub fn list_themes_from_dirs(dirs: &[(PathBuf, bool)]) -> Vec<ThemeMeta> {
651 652 /// Checks directories in reverse order so the highest-priority directory wins.
652 653 /// Returns `(path, is_custom)` or `None` if not found.
653 654 pub fn find_theme_path(dirs: &[(PathBuf, bool)], id: &str) -> Option<(PathBuf, bool)> {
654 - let filename = format!("{}.toml", id);
655 + let filename = format!("{id}.toml");
655 656
656 657 for (dir, is_custom) in dirs.iter().rev() {
657 658 let path = dir.join(&filename);
@@ -669,7 +670,7 @@ pub fn parse_theme_str(id: &str, content: &str, is_custom: bool) -> Result<Theme
669 670 validate_theme_id(id)?;
670 671 let table: toml::Table = content
671 672 .parse()
672 - .map_err(|e| format!("Failed to parse theme '{}': {}", id, e))?;
673 + .map_err(|e| format!("Failed to parse theme '{id}': {e}"))?;
673 674 let meta = parse_meta(id, &table, is_custom);
674 675 let colors = extract_colors(&table);
675 676 Ok(ThemeColors { meta, colors })
@@ -680,7 +681,7 @@ pub fn load_theme(dirs: &[(PathBuf, bool)], id: &str) -> Result<ThemeColors, Str
680 681 validate_theme_id(id)?;
681 682
682 683 let (path, is_custom) =
683 - find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{}' not found", id))?;
684 + find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{id}' not found"))?;
684 685
685 686 let content = std::fs::read_to_string(&path)
686 687 .map_err(|e| format!("Failed to read {}: {}", path.display(), e))?;
@@ -708,9 +709,7 @@ pub fn import_theme(source_path: &Path, custom_dir: &Path) -> Result<ThemeMeta,
708 709 let content = std::fs::read_to_string(source_path)
709 710 .map_err(|e| format!("Failed to read {}: {}", source_path.display(), e))?;
710 711
711 - let table: toml::Table = content
712 - .parse()
713 - .map_err(|e| format!("Invalid TOML: {}", e))?;
712 + let table: toml::Table = content.parse().map_err(|e| format!("Invalid TOML: {e}"))?;
714 713
715 714 let has_colors = COLOR_SECTIONS
716 715 .iter()
@@ -732,8 +731,8 @@ pub fn import_theme(source_path: &Path, custom_dir: &Path) -> Result<ThemeMeta,
732 731 std::fs::create_dir_all(custom_dir)
733 732 .map_err(|e| format!("Failed to create {}: {}", custom_dir.display(), e))?;
734 733
735 - let dest = custom_dir.join(format!("{}.toml", id));
736 - std::fs::copy(source_path, &dest).map_err(|e| format!("Failed to copy theme: {}", e))?;
734 + let dest = custom_dir.join(format!("{id}.toml"));
735 + std::fs::copy(source_path, &dest).map_err(|e| format!("Failed to copy theme: {e}"))?;
737 736
738 737 Ok(parse_meta(&id, &table, true))
739 738 }
@@ -745,9 +744,9 @@ pub fn import_theme(source_path: &Path, custom_dir: &Path) -> Result<ThemeMeta,
745 744 pub fn delete_theme(custom_dir: &Path, id: &str) -> Result<(), String> {
746 745 validate_theme_id(id)?;
747 746
748 - let path = custom_dir.join(format!("{}.toml", id));
747 + let path = custom_dir.join(format!("{id}.toml"));
749 748 if !path.is_file() {
750 - return Err(format!("Custom theme '{}' not found", id));
749 + return Err(format!("Custom theme '{id}' not found"));
751 750 }
752 751
753 752 std::fs::remove_file(&path).map_err(|e| format!("Failed to delete {}: {}", path.display(), e))
@@ -775,7 +774,7 @@ fn color_at(table: &toml::Table, section: &str, key: &str) -> Option<String> {
775 774 .and_then(|s| s.as_table())
776 775 .and_then(|s| s.get(key))
777 776 .and_then(|v| v.as_str())
778 - .map(|s| s.to_string())
777 + .map(std::string::ToString::to_string)
779 778 }
780 779
781 780 /// Load just the preview swatches for a theme — for UI thumbnails.
@@ -783,7 +782,7 @@ pub fn load_theme_preview(dirs: &[(PathBuf, bool)], id: &str) -> Result<ThemePre
783 782 validate_theme_id(id)?;
784 783
785 784 let (path, is_custom) =
786 - find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{}' not found", id))?;
785 + find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{id}' not found"))?;
787 786
788 787 let content = std::fs::read_to_string(&path)
789 788 .map_err(|e| format!("Failed to read {}: {}", path.display(), e))?;
@@ -805,10 +804,9 @@ pub fn load_theme_preview(dirs: &[(PathBuf, bool)], id: &str) -> Result<ThemePre
805 804 pub fn export_theme(dirs: &[(PathBuf, bool)], id: &str, dest_path: &Path) -> Result<(), String> {
806 805 validate_theme_id(id)?;
807 806
808 - let (source, _) =
809 - find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{}' not found", id))?;
807 + let (source, _) = find_theme_path(dirs, id).ok_or_else(|| format!("Theme '{id}' not found"))?;
810 808
811 - std::fs::copy(&source, dest_path).map_err(|e| format!("Failed to export theme: {}", e))?;
809 + std::fs::copy(&source, dest_path).map_err(|e| format!("Failed to export theme: {e}"))?;
812 810
813 811 Ok(())
814 812 }