diff --git a/crates/ruff/tests/integration_test.rs b/crates/ruff/tests/integration_test.rs index f9122e3b5e..4babbb3986 100644 --- a/crates/ruff/tests/integration_test.rs +++ b/crates/ruff/tests/integration_test.rs @@ -1489,6 +1489,8 @@ fn deprecated_direct() { #[test] fn deprecated_multiple_direct() { + // Multiple deprecated rules selected by exact code should be included + // but a warning should be displayed let mut cmd = RuffCheck::default() .args(["--select", "RUF920", "--select", "RUF921"]) .build(); @@ -1516,16 +1518,10 @@ fn deprecated_indirect() { // since it is not a "direct" selection let mut cmd = RuffCheck::default().args(["--select", "RUF92"]).build(); assert_cmd_snapshot!(cmd, @r" - success: false - exit_code: 1 + success: true + exit_code: 0 ----- stdout ----- - RUF920 Hey this is a deprecated test rule. - --> -:1:1 - - RUF921 Hey this is another deprecated test rule. - --> -:1:1 - - Found 2 errors. + All checks passed! ----- stderr ----- "); @@ -2155,16 +2151,10 @@ extend-safe-fixes = ["RUF9"] RUF903 Hey this is a stable test rule with a display only fix. --> -:1:1 - RUF920 Hey this is a deprecated test rule. - --> -:1:1 - - RUF921 Hey this is another deprecated test rule. - --> -:1:1 - RUF950 Hey this is a test rule that was redirected from another. --> -:1:1 - Found 7 errors. + Found 5 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). ----- stderr ----- diff --git a/crates/ruff_linter/src/rule_selector.rs b/crates/ruff_linter/src/rule_selector.rs index 74f069b976..399c881a34 100644 --- a/crates/ruff_linter/src/rule_selector.rs +++ b/crates/ruff_linter/src/rule_selector.rs @@ -214,10 +214,8 @@ impl RuleSelector { RuleGroup::Preview => { preview_enabled && (self.is_exact() || !preview_require_explicit) } - // Deprecated rules are excluded in preview mode and with 'All' option unless explicitly selected - RuleGroup::Deprecated => { - (!preview_enabled || self.is_exact()) && !matches!(self, RuleSelector::All) - } + // Deprecated rules are excluded by default unless explicitly selected + RuleGroup::Deprecated => !preview_enabled && self.is_exact(), // Removed rules are included if explicitly selected but will error downstream RuleGroup::Removed => self.is_exact(), } diff --git a/docs/versioning.md b/docs/versioning.md index 2740cf2b6e..6c6ad920ba 100644 --- a/docs/versioning.md +++ b/docs/versioning.md @@ -20,6 +20,7 @@ Ruff uses a custom versioning scheme that uses the **minor** version number for - Stable rules are added to the default set - Stable rules are removed from the default set - A safe fix for a rule is promoted to stable + - A rule is deprecated - Formatter: - The stable style changed - Language server: