mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:47 +00:00
many-to-one 1/9: Rename Rule::code to Rule::noqa_code
Post this commit series several codes can be mapped to a single rule, this commit therefore renames Rule::code to Rule::noqa_code, which is the code that --add-noqa will add to ignore a rule.
This commit is contained in:
parent
502ce80c91
commit
d451c7a506
36 changed files with 66 additions and 62 deletions
|
@ -67,7 +67,7 @@ impl Serialize for SerializeRuleAsCode<'_> {
|
|||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_str(self.0.code())
|
||||
serializer.serialize_str(self.0.noqa_code())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ impl Printer {
|
|||
message.kind.body()
|
||||
));
|
||||
let mut case = TestCase::new(
|
||||
format!("org.ruff.{}", message.kind.rule().code()),
|
||||
format!("org.ruff.{}", message.kind.rule().noqa_code()),
|
||||
status,
|
||||
);
|
||||
let file_path = Path::new(filename);
|
||||
|
@ -313,14 +313,14 @@ impl Printer {
|
|||
":",
|
||||
message.location.column(),
|
||||
":",
|
||||
message.kind.rule().code(),
|
||||
message.kind.rule().noqa_code(),
|
||||
message.kind.body(),
|
||||
);
|
||||
writeln!(
|
||||
stdout,
|
||||
"::error title=Ruff \
|
||||
({}),file={},line={},col={},endLine={},endColumn={}::{}",
|
||||
message.kind.rule().code(),
|
||||
message.kind.rule().noqa_code(),
|
||||
message.filename,
|
||||
message.location.row(),
|
||||
message.location.column(),
|
||||
|
@ -341,9 +341,9 @@ impl Printer {
|
|||
.iter()
|
||||
.map(|message| {
|
||||
json!({
|
||||
"description": format!("({}) {}", message.kind.rule().code(), message.kind.body()),
|
||||
"description": format!("({}) {}", message.kind.rule().noqa_code(), message.kind.body()),
|
||||
"severity": "major",
|
||||
"fingerprint": message.kind.rule().code(),
|
||||
"fingerprint": message.kind.rule().noqa_code(),
|
||||
"location": {
|
||||
"path": message.filename,
|
||||
"lines": {
|
||||
|
@ -366,7 +366,7 @@ impl Printer {
|
|||
"{}:{}: [{}] {}",
|
||||
relativize_path(Path::new(&message.filename)),
|
||||
message.location.row(),
|
||||
message.kind.rule().code(),
|
||||
message.kind.rule().noqa_code(),
|
||||
message.kind.body(),
|
||||
);
|
||||
writeln!(stdout, "{label}")?;
|
||||
|
@ -394,7 +394,7 @@ impl Printer {
|
|||
let statistics = violations
|
||||
.iter()
|
||||
.map(|rule| ExpandedStatistics {
|
||||
code: rule.code(),
|
||||
code: rule.noqa_code(),
|
||||
count: diagnostics
|
||||
.messages
|
||||
.iter()
|
||||
|
@ -538,7 +538,7 @@ impl Display for CodeAndBody<'_> {
|
|||
write!(
|
||||
f,
|
||||
"{code} {autofix}{body}",
|
||||
code = self.0.kind.rule().code().red().bold(),
|
||||
code = self.0.kind.rule().noqa_code().red().bold(),
|
||||
autofix = format_args!("[{}] ", "*".cyan()),
|
||||
body = self.0.kind.body(),
|
||||
)
|
||||
|
@ -546,7 +546,7 @@ impl Display for CodeAndBody<'_> {
|
|||
write!(
|
||||
f,
|
||||
"{code} {body}",
|
||||
code = self.0.kind.rule().code().red().bold(),
|
||||
code = self.0.kind.rule().noqa_code().red().bold(),
|
||||
body = self.0.kind.body(),
|
||||
)
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ fn print_message<T: Write>(
|
|||
source: &source.contents,
|
||||
line_start: message.location.row(),
|
||||
annotations: vec![SourceAnnotation {
|
||||
label: message.kind.rule().code(),
|
||||
label: message.kind.rule().noqa_code(),
|
||||
annotation_type: AnnotationType::Error,
|
||||
range: source.range,
|
||||
}],
|
||||
|
@ -656,7 +656,7 @@ fn print_fixed<T: Write>(stdout: &mut T, fixed: &FxHashMap<String, FixTable>) ->
|
|||
writeln!(
|
||||
stdout,
|
||||
" {count:>num_digits$} × {} ({})",
|
||||
rule.code().red().bold(),
|
||||
rule.noqa_code().red().bold(),
|
||||
rule.as_ref(),
|
||||
)?;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ fn print_grouped_message<T: Write>(
|
|||
source: &source.contents,
|
||||
line_start: message.location.row(),
|
||||
annotations: vec![SourceAnnotation {
|
||||
label: message.kind.rule().code(),
|
||||
label: message.kind.rule().noqa_code(),
|
||||
annotation_type: AnnotationType::Error,
|
||||
range: source.range,
|
||||
}],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue