mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +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
|
@ -22,17 +22,17 @@ struct Explanation<'a> {
|
|||
|
||||
/// Explain a `Rule` to the user.
|
||||
pub fn rule(rule: &Rule, format: HelpFormat) -> Result<()> {
|
||||
let (linter, _) = Linter::parse_code(rule.code()).unwrap();
|
||||
let (linter, _) = Linter::parse_code(rule.noqa_code()).unwrap();
|
||||
let mut stdout = BufWriter::new(io::stdout().lock());
|
||||
let mut output = String::new();
|
||||
|
||||
match format {
|
||||
HelpFormat::Text | HelpFormat::Pretty => {
|
||||
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.code()));
|
||||
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.noqa_code()));
|
||||
output.push('\n');
|
||||
output.push('\n');
|
||||
|
||||
let (linter, _) = Linter::parse_code(rule.code()).unwrap();
|
||||
let (linter, _) = Linter::parse_code(rule.noqa_code()).unwrap();
|
||||
output.push_str(&format!("Derived from the **{}** linter.", linter.name()));
|
||||
output.push('\n');
|
||||
output.push('\n');
|
||||
|
@ -58,7 +58,7 @@ pub fn rule(rule: &Rule, format: HelpFormat) -> Result<()> {
|
|||
}
|
||||
HelpFormat::Json => {
|
||||
output.push_str(&serde_json::to_string_pretty(&Explanation {
|
||||
code: rule.code(),
|
||||
code: rule.noqa_code(),
|
||||
linter: linter.name(),
|
||||
summary: rule.message_formats()[0],
|
||||
})?);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue