Skip to content

Commit 4ec9cb8

Browse files
committed
cargo dev crater: refactor to get a list of all ClippyWarnings
1 parent 6c5bf27 commit 4ec9cb8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

clippy_dev/src/crater.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl CrateSource {
106106
}
107107

108108
impl Crate {
109-
fn run_clippy_lints(&self, cargo_clippy_path: &PathBuf) -> Vec<String> {
109+
fn run_clippy_lints(&self, cargo_clippy_path: &PathBuf) -> Vec<ClippyWarning> {
110110
println!("Linting {} {}...", &self.name, &self.version);
111111
let cargo_clippy_path = std::fs::canonicalize(cargo_clippy_path).unwrap();
112112

@@ -136,11 +136,7 @@ impl Crate {
136136
.filter(|line| line.contains("clippy::"))
137137
.map(|json_msg| parse_json_message(json_msg, &self))
138138
.collect();
139-
140-
let mut output: Vec<String> = warnings.iter().map(|warning| warning.to_string()).collect();
141-
// sort messages alphabetically to avoid noise in the logs
142-
output.sort();
143-
output
139+
warnings
144140
}
145141
}
146142

@@ -219,17 +215,18 @@ pub fn run() {
219215
);
220216

221217
// download and extract the crates, then run clippy on them and collect clippys warnings
218+
// flatten into one big list of warnings
222219

223-
let clippy_lint_results: Vec<Vec<String>> = read_crates()
220+
let clippy_warnings: Vec<ClippyWarning> = read_crates()
224221
.into_iter()
225222
.map(|krate| krate.download_and_extract())
226223
.map(|krate| krate.run_clippy_lints(&cargo_clippy_path))
224+
.flatten()
227225
.collect();
228226

229-
let mut all_warnings: Vec<String> = clippy_lint_results.into_iter().flatten().collect();
230-
all_warnings.sort();
227+
let all_msgs: Vec<String> = clippy_warnings.iter().map(|warning| warning.to_string()).collect();
231228

232229
// save the text into mini-crater/logs.txt
233-
let text = all_warnings.join("");
230+
let text = all_msgs.join("");
234231
write("mini-crater/logs.txt", text).unwrap();
235232
}

0 commit comments

Comments
 (0)