From c690471e66001ea1b64d3aac41707babe659d8b7 Mon Sep 17 00:00:00 2001 From: Jose Garcia Crosta Date: Mon, 25 Mar 2024 14:03:20 -0300 Subject: [PATCH] Fix clippy issues --- .../tests/integration_tests/detectors.rs | 12 ++++-------- .../integration_tests/detectors/configuration.rs | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/apps/cargo-scout-audit/tests/integration_tests/detectors.rs b/apps/cargo-scout-audit/tests/integration_tests/detectors.rs index b52914f9..7bc3a95c 100644 --- a/apps/cargo-scout-audit/tests/integration_tests/detectors.rs +++ b/apps/cargo-scout-audit/tests/integration_tests/detectors.rs @@ -45,7 +45,8 @@ fn test() { vec![false; integration_tests_to_run.as_ref().map_or(0, |v| v.len())]; // Get the configuration - let detectors_config = Configuration::build().expect(&"Failed to get the configuration".red()); + let detectors_config = Configuration::build() + .unwrap_or_else(|_| panic!("{}", "Failed to get the configuration".red().to_string())); // Run all integration tests for detector_config in detectors_config.detectors.iter() { @@ -65,15 +66,10 @@ fn test() { println!("\n{} {}", "Testing detector:".bright_cyan(), detector_name); for example in detector_config.testcases.iter() { if let Some(vulnerable_path) = &example.vulnerable_path { - execute_and_validate_testcase(&detector_name, lint_message, &vulnerable_path, true); + execute_and_validate_testcase(&detector_name, lint_message, vulnerable_path, true); } if let Some(remediated_path) = &example.remediated_path { - execute_and_validate_testcase( - &detector_name, - lint_message, - &remediated_path, - false, - ); + execute_and_validate_testcase(&detector_name, lint_message, remediated_path, false); } } } diff --git a/apps/cargo-scout-audit/tests/integration_tests/detectors/configuration.rs b/apps/cargo-scout-audit/tests/integration_tests/detectors/configuration.rs index 4190cd73..942d80f9 100644 --- a/apps/cargo-scout-audit/tests/integration_tests/detectors/configuration.rs +++ b/apps/cargo-scout-audit/tests/integration_tests/detectors/configuration.rs @@ -34,7 +34,6 @@ impl Configuration { .ok_or(anyhow!("Failed to find testcases path"))? .join("test-cases"); let testcases_paths: Vec = std::fs::read_dir(&testcases_root_path)? - .into_iter() .filter_map(|r| r.ok().map(|f| f.path())) .filter(|r| r.is_dir()) .collect(); @@ -47,7 +46,6 @@ impl Configuration { let detector_name = detector.to_string(); let testcases_root_path = testcases_root_path.join(detector_name); let testcases_paths: Vec = std::fs::read_dir(testcases_root_path)? - .into_iter() .filter_map(|r| r.ok().map(|f| f.path())) .filter(|r| r.is_dir()) .collect(); @@ -101,7 +99,7 @@ impl Configuration { .into_iter() .sorted() .zip(Detector::iter().map(|d| d.to_string()).sorted()) - .filter(|(p, d)| p.file_name().unwrap().to_string_lossy() != d.to_string()) + .filter(|(p, d)| p.file_name().unwrap().to_string_lossy() != *d) .count(); if count > 0 {