1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-07-01 16:32:54 +00:00

chore: add linter config and related code cleanup

This commit is contained in:
2024-12-04 14:36:59 +01:00
parent 83d4857ed3
commit b4e1113f3d
3 changed files with 41 additions and 20 deletions

View File

@ -42,6 +42,18 @@ lto = "thin"
strip = true
panic = "abort"
# Lints
[lints.clippy]
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"
[lints.rust]
unused_must_use = "deny"
# Packaging
[package.metadata.deb]
copyright = "Copyright (C) 2023-2024 the original author or authors"
extended-description = "Anwendung zum Anpassen einer OSC-Datei an einen Standort."

View File

@ -178,25 +178,33 @@ pub fn handle(command: SubCommand) -> Result<(), Box<dyn Error>> {
let mut strip = strip;
if interactive {
compact = Confirm::new()
.with_prompt("Kompakte Ausgabe, ohne Einrücken?")
.default(compact)
.interact()
.unwrap();
compact = matches!(
Confirm::new()
.with_prompt("Kompakte Ausgabe, ohne Einrücken?")
.default(compact)
.interact(),
Ok(true)
);
sorted = Confirm::new()
.with_prompt("Sortiere Kataloge und Formulare nach Name und Abhängigkeiten?")
.default(sorted)
.interact()
.unwrap();
sorted = matches!(
Confirm::new()
.with_prompt(
"Sortiere Kataloge und Formulare nach Name und Abhängigkeiten?"
)
.default(sorted)
.interact(),
Ok(true)
);
strip = Confirm::new()
.with_prompt(
"Entferne Einträge aus der Systembibliothek die nicht importiert werden?",
)
.default(strip)
.interact()
.unwrap();
strip = matches!(
Confirm::new()
.with_prompt(
"Entferne Einträge aus der Systembibliothek die nicht importiert werden?",
)
.default(strip)
.interact(),
Ok(true)
);
}
if fix {
@ -218,7 +226,9 @@ pub fn handle(command: SubCommand) -> Result<(), Box<dyn Error>> {
serializer.indent(' ', 2);
}
data.serialize(serializer).expect("Generated XML");
data.serialize(serializer).map_err(|_| {
FileError::Writing("Cannot serialize result".to_string(), String::new())
})?;
let output = &"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
.to_string()

View File

@ -123,8 +123,7 @@ where
}
_ => None,
})
.filter(Option::is_some)
.map(|item| format!(" - {}\n", item.unwrap()))
.filter_map(|item| item.map(|item| format!(" - {item}\n")))
.collect::<Vec<_>>()
.join("");