mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:37 +00:00
handle non-ruff files, update snapshots
This commit is contained in:
parent
8f909ea0bb
commit
6a652d2ff3
3 changed files with 52 additions and 45 deletions
|
@ -60,24 +60,30 @@ impl Serialize for SerializedMessages<'_> {
|
||||||
let mut fingerprints = HashSet::<u64>::with_capacity(self.diagnostics.len());
|
let mut fingerprints = HashSet::<u64>::with_capacity(self.diagnostics.len());
|
||||||
|
|
||||||
for diagnostic in self.diagnostics {
|
for diagnostic in self.diagnostics {
|
||||||
let span = diagnostic.expect_primary_span();
|
if let Some(span) = diagnostic.primary_span() {
|
||||||
let file = span.file();
|
let file = span.file();
|
||||||
let filename = diagnostic.expect_ruff_filename();
|
let filename = file.path(self.resolver);
|
||||||
|
|
||||||
let (start_location, end_location) = if self.resolver.is_notebook(file) {
|
let (start_location, end_location) = if self.resolver.is_notebook(file) {
|
||||||
// We can't give a reasonable location for the structured formats,
|
// We can't give a reasonable location for the structured formats,
|
||||||
// so we show one that's clearly a fallback
|
// so we show one that's clearly a fallback
|
||||||
Default::default()
|
Default::default()
|
||||||
} else {
|
} else {
|
||||||
|
let diagnostic_source = file.diagnostic_source(self.resolver);
|
||||||
|
let source_code = diagnostic_source.as_source_code();
|
||||||
|
span.range()
|
||||||
|
.map(|range| {
|
||||||
(
|
(
|
||||||
diagnostic.expect_ruff_start_location(),
|
source_code.line_column(range.start()),
|
||||||
diagnostic.expect_ruff_end_location(),
|
source_code.line_column(range.end()),
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = self.project_dir.as_ref().map_or_else(
|
let path = self.project_dir.as_ref().map_or_else(
|
||||||
|| file.relative_path(self.resolver).display().to_string(),
|
|| file.relative_path(self.resolver).display().to_string(),
|
||||||
|project_dir| relativize_path_to(&filename, project_dir),
|
|project_dir| relativize_path_to(filename, project_dir),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut message_fingerprint = fingerprint(diagnostic, &path, 0);
|
let mut message_fingerprint = fingerprint(diagnostic, &path, 0);
|
||||||
|
@ -110,6 +116,7 @@ impl Serialize for SerializedMessages<'_> {
|
||||||
|
|
||||||
s.serialize_element(&value)?;
|
s.serialize_element(&value)?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s.end()
|
s.end()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/message/gitlab.rs
|
source: crates/ruff_db/src/diagnostic/render/gitlab.rs
|
||||||
expression: redact_fingerprint(&content)
|
expression: env.render_diagnostics(&diagnostics)
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/message/gitlab.rs
|
source: crates/ruff_db/src/diagnostic/render/gitlab.rs
|
||||||
expression: redact_fingerprint(&content)
|
expression: env.render_diagnostics(&diagnostics)
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
{
|
{
|
Loading…
Add table
Add a link
Reference in a new issue