diff --git a/src/checks/mod.rs b/src/checks/mod.rs index a21f989..8e82eae 100644 --- a/src/checks/mod.rs +++ b/src/checks/mod.rs @@ -138,17 +138,18 @@ pub trait Fixable { } #[allow(unused_variables)] -pub fn check_file(file: &Path, password: &Option) -> Result, CheckNotice> { +#[allow(clippy::needless_pass_by_value)] +pub fn check_file(file: &Path, password: Option) -> Result, CheckNotice> { match file.extension() { Some(ex) => match ex.to_str() { #[cfg(feature = "unzip-osb")] - Some("osb") => match password { - Some(password) => osb::check_file(file, password.as_str()), - None => { - use deob::deobfuscate; - osb::check_file(file, deobfuscate(env!("OSB_KEY").trim()).as_str()) - } - }, + Some("osb") => { + use deob::deobfuscate; + osb::check_file( + file, + &password.unwrap_or_else(|| deobfuscate(env!("OSB_KEY").trim())), + ) + } Some("osc") => osc::check_file(file), _ => Err(CheckNotice::Error { description: "Keine prüfbare Datei".to_string(), diff --git a/src/commands.rs b/src/commands.rs index bc4d338..1ac1168 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -289,7 +289,7 @@ pub fn handle(command: SubCommand) -> Result<(), Box> { if list { print(); } else { - match check_file(Path::new(file.unwrap_or_default().as_str()), &password) { + match check_file(Path::new(file.unwrap_or_default().as_str()), password) { Ok(notices) => { println!( "Es wurden {} Probleme gefunden\n",