Skip to content

Commit 69c3289

Browse files
committed
Lintcheck: Include the crate name in the CI job summary
1 parent 83c8385 commit 69c3289

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

lintcheck/src/json.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::ClippyWarning;
99
#[derive(Deserialize, Serialize)]
1010
struct LintJson {
1111
lint: String,
12+
krate: String,
1213
file_name: String,
1314
byte_pos: (u32, u32),
1415
file_link: String,
@@ -19,6 +20,10 @@ impl LintJson {
1920
fn key(&self) -> impl Ord + '_ {
2021
(self.file_name.as_str(), self.byte_pos, self.lint.as_str())
2122
}
23+
24+
fn info_text(&self, action: &str) -> String {
25+
format!("{action} `{}` in `{}` at {}", self.lint, self.krate, self.file_link)
26+
}
2227
}
2328

2429
/// Creates the log file output for [`crate::config::OutputFormat::Json`]
@@ -30,6 +35,7 @@ pub(crate) fn output(clippy_warnings: Vec<ClippyWarning>) -> String {
3035
LintJson {
3136
file_name: span.file_name.clone(),
3237
byte_pos: (span.byte_start, span.byte_end),
38+
krate: warning.krate,
3339
file_link: warning.url,
3440
lint: warning.lint,
3541
rendered: warning.diag.rendered.unwrap(),
@@ -55,7 +61,7 @@ fn print_warnings(title: &str, warnings: &[LintJson]) {
5561
println!(r#"<h3 id="{title}">{title}</h3>"#);
5662
println!();
5763
for warning in warnings {
58-
println!("{title} `{}` at {}", warning.lint, warning.file_link);
64+
println!("{}", warning.info_text(title));
5965
println!();
6066
println!("```");
6167
println!("{}", warning.rendered.trim_end());
@@ -73,7 +79,7 @@ fn print_changed_diff(changed: &[(LintJson, LintJson)]) {
7379
println!(r#"<h3 id="changed">Changed</h3>"#);
7480
println!();
7581
for (old, new) in changed {
76-
println!("Changed `{}` at {}", new.lint, new.file_link);
82+
println!("{}", new.info_text("Changed"));
7783
println!();
7884
println!("```diff");
7985
for change in diff::lines(old.rendered.trim_end(), new.rendered.trim_end()) {

lintcheck/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ impl Crate {
189189
Ok(Message::CompilerMessage(message)) => ClippyWarning::new(
190190
normalize_diag(message.message, shared_target_dir.to_str().unwrap()),
191191
&self.base_url,
192+
&self.name,
192193
),
193194
_ => None,
194195
})

lintcheck/src/output.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ impl RustcIce {
5353
pub struct ClippyWarning {
5454
pub lint: String,
5555
pub diag: Diagnostic,
56+
pub krate: String,
5657
/// The URL that points to the file and line of the lint emission
5758
pub url: String,
5859
}
5960

6061
impl ClippyWarning {
61-
pub fn new(mut diag: Diagnostic, base_url: &str) -> Option<Self> {
62+
pub fn new(mut diag: Diagnostic, base_url: &str, krate: &str) -> Option<Self> {
6263
let lint = diag.code.clone()?.code;
6364
if !(lint.contains("clippy") || diag.message.contains("clippy"))
6465
|| diag.message.contains("could not read cargo metadata")
@@ -90,7 +91,12 @@ impl ClippyWarning {
9091
file.clone()
9192
};
9293

93-
Some(Self { lint, diag, url })
94+
Some(Self {
95+
lint,
96+
diag,
97+
url,
98+
krate: krate.to_string(),
99+
})
94100
}
95101

96102
pub fn span(&self) -> &DiagnosticSpan {

lintcheck/src/recursive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn process_stream(
7272
let messages = stderr
7373
.lines()
7474
.filter_map(|json_msg| serde_json::from_str::<Diagnostic>(json_msg).ok())
75-
.filter_map(|diag| ClippyWarning::new(diag, &base_url));
75+
.filter_map(|diag| ClippyWarning::new(diag, &base_url, &driver_info.package_name));
7676

7777
for message in messages {
7878
sender.send(message).unwrap();

0 commit comments

Comments
 (0)