refactor: Code-Qualität und Usability verbessern

- Ungenutzte Dependencies entfernt (itertools, thiserror)
- 560 Build-Artefakte (target/) aus Git-Tracking entfernt
- NO_COLOR Umgebungsvariable unterstützen (https://no-color.org/)
- if let Ok/Err durch idiomatisches match ersetzt
- Fehlermeldung bei Aufruf ohne Pfade hinzugefügt
- Sequence::default() zu Sequence::standard() umbenannt
  um Verwechslung mit dem Rust Default-Trait zu vermeiden

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-13 04:26:47 +01:00
commit de9bb4fd03
563 changed files with 26 additions and 1600 deletions

View file

@ -26,15 +26,13 @@ emojis = "0.6.1"
regex = "1.10.3" regex = "1.10.3"
dirs = "5.0.1" dirs = "5.0.1"
# Neue empfohlene Abhängigkeiten # Weitere Abhängigkeiten
anyhow = "1.0.80" # Verbesserte Fehlerbehandlung anyhow = "1.0.80" # Verbesserte Fehlerbehandlung
thiserror = "1.0.57" # Typisierte Fehler
once_cell = "1.19.0" # Lazy-Initialisierung für statische Werte once_cell = "1.19.0" # Lazy-Initialisierung für statische Werte
rayon = "1.9.0" # Parallelverarbeitung rayon = "1.9.0" # Parallelverarbeitung
indicatif = "0.17.7" # Fortschrittsbalken indicatif = "0.17.7" # Fortschrittsbalken
env_logger = "0.11.2" # Logging-Framework env_logger = "0.11.2" # Logging-Framework
log = "0.4.21" # Logging-Abstraktionen log = "0.4.21" # Logging-Abstraktionen
itertools = "0.12.1" # Erweiterte Iterator-Funktionalität
colored = "2.1" # Farbige Terminal-Ausgabe colored = "2.1" # Farbige Terminal-Ausgabe
[dev-dependencies] [dev-dependencies]

View file

@ -42,9 +42,11 @@ struct RenameOperation {
new_path: PathBuf, new_path: PathBuf,
} }
/// Prüft ob farbige Ausgabe aktiviert sein soll /// Prüft ob farbige Ausgabe aktiviert sein soll.
/// Respektiert --no-color Flag, NO_COLOR Umgebungsvariable (https://no-color.org/)
/// und ob stdout ein Terminal ist.
fn should_use_color(no_color_flag: bool) -> bool { fn should_use_color(no_color_flag: bool) -> bool {
!no_color_flag && std::io::stdout().is_terminal() !no_color_flag && std::env::var_os("NO_COLOR").is_none() && std::io::stdout().is_terminal()
} }
/// Startpunkt des Programms /// Startpunkt des Programms
@ -75,7 +77,7 @@ fn main() -> Result<()> {
) )
})? })?
} else { } else {
Sequence::default() Sequence::standard()
}; };
if args.verbose { if args.verbose {
@ -116,6 +118,12 @@ fn main() -> Result<()> {
} }
} }
// Prüfe ob Pfade angegeben wurden
if args.paths.is_empty() {
eprintln!("Keine Pfade angegeben. Nutze 'ntu --help' für Hilfe.");
std::process::exit(1);
}
// Für alle angegebenen Pfade // Für alle angegebenen Pfade
for path in &args.paths { for path in &args.paths {
// Alle Einträge sammeln, damit zuerst die tiefsten umbenannt werden // Alle Einträge sammeln, damit zuerst die tiefsten umbenannt werden
@ -140,13 +148,12 @@ fn main() -> Result<()> {
.into_iter() .into_iter()
.filter_entry(|e| !is_excluded(e, &exclude_patterns)) .filter_entry(|e| !is_excluded(e, &exclude_patterns))
{ {
if let Ok(entry) = entry_result { match entry_result {
entries.push(entry); Ok(entry) => entries.push(entry),
} else if let Err(e) = entry_result { Err(e) => error!(
error!(
"{}", "{}",
format!("Fehler beim Durchlaufen von {}: {}", path.display(), e).red() format!("Fehler beim Durchlaufen von {}: {}", path.display(), e).red()
); ),
} }
} }

View file

@ -83,8 +83,8 @@ impl Sequence {
Self::all().into_iter().find(|s| s.name == name) Self::all().into_iter().find(|s| s.name == name)
} }
/// Gibt die Default-Sequence zurück /// Gibt die Standard-Sequence zurück
pub fn default() -> Sequence { pub fn standard() -> Sequence {
Self::find("default").unwrap() Self::find("default").unwrap()
} }
} }
@ -406,7 +406,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_basic() { fn test_clean_filename_basic() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// Spaces should become underscores // Spaces should become underscores
assert_eq!( assert_eq!(
@ -430,7 +430,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_hidden_files() { fn test_clean_filename_hidden_files() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// Hidden files should keep their leading dot // Hidden files should keep their leading dot
assert_eq!( assert_eq!(
@ -460,7 +460,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_umlauts() { fn test_clean_filename_umlauts() {
let config = make_test_config(); let config = make_test_config();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// German umlauts // German umlauts
assert_eq!( assert_eq!(
@ -482,7 +482,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_extensions() { fn test_clean_filename_extensions() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// Single extension // Single extension
assert_eq!( assert_eq!(
@ -543,7 +543,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_special_identifiers() { fn test_clean_filename_special_identifiers() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// C++ should be preserved // C++ should be preserved
assert_eq!( assert_eq!(
@ -561,7 +561,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_no_change_needed() { fn test_clean_filename_no_change_needed() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// Already clean filenames should return None // Already clean filenames should return None
assert_eq!( assert_eq!(
@ -578,7 +578,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_empty_after_cleaning() { fn test_clean_filename_empty_after_cleaning() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// File with only special chars should become "unnamed" // File with only special chars should become "unnamed"
assert_eq!( assert_eq!(
@ -590,7 +590,7 @@ mod tests {
#[test] #[test]
fn test_clean_filename_apostrophe() { fn test_clean_filename_apostrophe() {
let config = Config::default(); let config = Config::default();
let sequence = Sequence::default(); let sequence = Sequence::standard();
// Apostrophes should be removed (not replaced with underscore) // Apostrophes should be removed (not replaced with underscore)
assert_eq!( assert_eq!(

View file

@ -1 +0,0 @@
{"rustc_fingerprint":4740973386762217857,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/dschlueter/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.90.0 (1159e78c4 2025-09-14)\nbinary: rustc\ncommit-hash: 1159e78c4747b02ef996e55082b704c09b970588\ncommit-date: 2025-09-14\nhost: x86_64-unknown-linux-gnu\nrelease: 1.90.0\nLLVM version: 20.1.8\n","stderr":""},"11857020428658561806":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/dschlueter/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}

View file

@ -1,3 +0,0 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

View file

@ -1 +0,0 @@
{"rustc":2484451964687019519,"features":"[]","declared_features":"[]","target":6121981589821494128,"profile":3878794443245516162,"path":10602529704205407992,"deps":[[496936660758387454,"walkdir",false,16653160629585727827],[781203651122893512,"itertools",false,4856790396137166786],[2253645963862362999,"glob",false,17901889553727651475],[2751633865096478575,"once_cell",false,404175244902379717],[4861353637455856501,"emojis",false,7812852181959777352],[5957121993870933949,"indicatif",false,6846573194333882574],[6903225003750382070,"env_logger",false,12129958749168747241],[8121005825001993377,"toml",false,14529174445398999363],[8444115378192700076,"anyhow",false,15790217775176775280],[9300925758419628329,"log",false,7601692817919657737],[9722518470958012960,"clap",false,6017947166156778644],[11266840602298992523,"thiserror",false,2303909277957177506],[11641382387439738731,"regex",false,1153832817102413080],[11892580040701647366,"serde",false,16170242140613763432],[16233166307772572446,"unicode_segmentation",false,13473434130131659026],[17775862536196513609,"rayon",false,4741632797656246936],[17902303992486982172,"dirs",false,15255450532072959597]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/NameToUnix-52eb14cd7f851fcf/dep-bin-NameToUnix"}}],"rustflags":[],"metadata":11238891150943416482,"config":2202906307356721367,"compile_kind":0}

View file

@ -1 +0,0 @@
This file has an mtime of when this was started.

View file

@ -1 +0,0 @@
This file has an mtime of when this was started.

View file

@ -1 +0,0 @@
{"rustc":2484451964687019519,"features":"[\"perf-literal\", \"std\"]","declared_features":"[\"default\", \"logging\", \"perf-literal\", \"std\"]","target":9771195463141993919,"profile":11260102936901317155,"path":16307491102300075524,"deps":[[554324495028472449,"memchr",false,217317700187571089]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/aho-corasick-17f8b4266e41b6ce/dep-lib-aho_corasick"}}],"rustflags":[],"metadata":13904389431191498124,"config":2202906307356721367,"compile_kind":0}

View file

@ -1 +0,0 @@
This file has an mtime of when this was started.

View file

@ -1 +0,0 @@
16e4bdea9a608b73

View file

@ -1 +0,0 @@
{"rustc":2484451964687019519,"features":"[\"auto\", \"default\", \"wincon\"]","declared_features":"[\"auto\", \"default\", \"test\", \"wincon\"]","target":1736373845211751465,"profile":5847708262638652504,"path":15382520749374289969,"deps":[[821897733253474908,"anstyle",false,18094389414750515593],[6726333832837302156,"anstyle_query",false,6517661958451464783],[8720183142424604966,"utf8parse",false,18444629462088036825],[9119385831240683871,"is_terminal_polyfill",false,15365458187358078183],[16168342247272166835,"anstyle_parse",false,11337828736863921905],[17599588001959536047,"colorchoice",false,1614739890724786504]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/anstream-c3c9a361c5ec1896/dep-lib-anstream"}}],"rustflags":[],"metadata":7500874485387469444,"config":2202906307356721367,"compile_kind":0}

View file

@ -1 +0,0 @@
This file has an mtime of when this was started.

Some files were not shown because too many files have changed in this diff Show more