// When a new lint is introduced, we can search the results for new warnings and check for false
// positives.
+#![cfg(feature = "crater")]
#![allow(clippy::filter_map)]
use crate::clippy_project_root;
cargo_clippy_path.display()
);
+ let clippy_ver = std::process::Command::new("target/debug/cargo-clippy")
+ .arg("--version")
+ .output()
+ .map(|o| String::from_utf8_lossy(&o.stdout).into_owned())
+ .expect("could not get clippy version!");
+
// download and extract the crates, then run clippy on them and collect clippys warnings
// flatten into one big list of warnings
+ let crates = read_crates();
+
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
- // only check a single
- read_crates()
+ // if we don't have the specified crated in the .toml, throw an error
+ if !crates.iter().any(|krate| krate.name == only_one_crate) {
+ eprintln!(
+ "ERROR: could not find crate '{}' in clippy_dev/crater_crates.toml",
+ only_one_crate
+ );
+ std::process::exit(1);
+ }
+
+ // only check a single crate that was passed via cmdline
+ crates
.into_iter()
.map(|krate| krate.download_and_extract())
.filter(|krate| krate.name == only_one_crate)
.flatten()
.collect()
} else {
- read_crates()
+ // check all crates (default)
+ crates
.into_iter()
.map(|krate| krate.download_and_extract())
.map(|krate| krate.run_clippy_lints(&cargo_clippy_path))
all_msgs.push(stats_formatted);
// save the text into mini-crater/logs.txt
- let text = all_msgs.join("");
+ let mut text = clippy_ver; // clippy version number on top
+ text.push_str(&format!("\n{}", all_msgs.join("")));
write("mini-crater/logs.txt", text).unwrap();
}