mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
refactor: Rename RuleOrigin to Linter
"origin" was accurate since ruff rules are currently always modeled after one origin (except the Ruff-specific rules). Since we however want to introduce a many-to-many mapping between codes and rules, the term "origin" no longer makes much sense. Rules usually don't have multiple origins but one linter implements a rule first and then others implement it later (often inspired from another linter). But we don't actually care much about where a rule originates from when mapping multiple rule codes to one rule implementation, so renaming RuleOrigin to Linter is less confusing with the many-to-many system.
This commit is contained in:
parent
babe1eb7be
commit
7fc42f8f85
12 changed files with 95 additions and 95 deletions
|
@ -285,7 +285,7 @@ pub fn show_files(
|
|||
#[derive(Serialize)]
|
||||
struct Explanation<'a> {
|
||||
code: &'a str,
|
||||
origin: &'a str,
|
||||
linter: &'a str,
|
||||
summary: &'a str,
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ pub fn explain(rule: &Rule, format: SerializationFormat) -> Result<()> {
|
|||
"{}",
|
||||
serde_json::to_string_pretty(&Explanation {
|
||||
code: rule.code(),
|
||||
origin: rule.origin().name(),
|
||||
linter: rule.origin().name(),
|
||||
summary: rule.message_formats()[0],
|
||||
})?
|
||||
);
|
||||
|
|
|
@ -13,7 +13,7 @@ use assert_cmd::Command;
|
|||
use itertools::Itertools;
|
||||
use log::info;
|
||||
use ruff::logging::{set_up_logging, LogLevel};
|
||||
use ruff::registry::RuleOrigin;
|
||||
use ruff::registry::Linter;
|
||||
use strum::IntoEnumIterator;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
|
@ -175,12 +175,12 @@ fn test_ruff_black_compatibility() -> Result<()> {
|
|||
.filter_map(Result::ok)
|
||||
.collect();
|
||||
|
||||
let codes = RuleOrigin::iter()
|
||||
let codes = Linter::iter()
|
||||
// Exclude ruff codes, specifically RUF100, because it causes differences that are not a
|
||||
// problem. Ruff would add a `# noqa: W292` after the first run, black introduces a
|
||||
// newline, and ruff removes the `# noqa: W292` again.
|
||||
.filter(|origin| *origin != RuleOrigin::Ruff)
|
||||
.map(|origin| origin.prefixes().as_list(","))
|
||||
.filter(|linter| *linter != Linter::Ruff)
|
||||
.map(|linter| linter.prefixes().as_list(","))
|
||||
.join(",");
|
||||
let ruff_args = [
|
||||
"-",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue