diff --git a/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs b/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs index 2d4753484ab13..e3415afc929d7 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/needless_else.rs @@ -11,7 +11,7 @@ use crate::checkers::ast::Checker; /// Checks for `else` clauses that only contains `pass` and `...` statements. /// /// ## Why is this bad? -/// Such a clause is unnecessary. +/// Such an else clause does nothing and can be removed. /// /// ## Example /// ```python @@ -36,7 +36,7 @@ impl AlwaysFixableViolation for NeedlessElse { } fn fix_title(&self) -> String { - "Remove clause".to_string() + "Remove `else` clause".to_string() } } @@ -80,7 +80,7 @@ pub(crate) fn needless_else(checker: &mut Checker, stmt: AnyNodeWithOrElse) { checker.diagnostics.push(diagnostic.with_fix(fix)); } -/// Whether `body` contains only `pass` or `...` statements. +/// Whether `body` contains only one `pass` or `...` statement. fn body_is_useless(body: &[Stmt]) -> bool { match body { [Stmt::Pass(_)] => true, diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_for.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_for.py.snap index 36e2ea1060d88..da5aca1aee3f6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_for.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_for.py.snap @@ -10,7 +10,7 @@ RUF047_for.py:4:1: RUF047 [*] Empty `else` clause 5 | | pass | |________^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 1 1 | for _ in range(0): @@ -30,7 +30,7 @@ RUF047_for.py:10:1: RUF047 [*] Empty `else` clause 11 | | ... | |_______^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 7 7 | @@ -51,7 +51,7 @@ RUF047_for.py:36:1: RUF047 [*] Empty `else` clause | |_______^ RUF047 38 | # too | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 33 33 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_if.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_if.py.snap index 6bb02deacf2e1..41ef4f97b2586 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_if.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_if.py.snap @@ -10,7 +10,7 @@ RUF047_if.py:3:1: RUF047 [*] Empty `else` clause 4 | | pass | |________^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 1 1 | if False: @@ -29,7 +29,7 @@ RUF047_if.py:9:1: RUF047 [*] Empty `else` clause 10 | | ... | |_______^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 6 6 | @@ -49,7 +49,7 @@ RUF047_if.py:17:1: RUF047 [*] Empty `else` clause 18 | | pass | |________^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 14 14 | treated() @@ -70,7 +70,7 @@ RUF047_if.py:41:1: RUF047 [*] Empty `else` clause | |_______^ RUF047 43 | # comment | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 38 38 | @@ -90,7 +90,7 @@ RUF047_if.py:52:1: RUF047 [*] Empty `else` clause 53 | 54 | if of_course: | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 49 49 | # this comment doesn't belong to the if @@ -110,7 +110,7 @@ RUF047_if.py:56:1: RUF047 [*] Empty `else` clause 57 | 58 | if of_course: | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 53 53 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_try.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_try.py.snap index a7a48f138ba0b..bf32be69eb4ac 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_try.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_try.py.snap @@ -10,7 +10,7 @@ RUF047_try.py:5:1: RUF047 [*] Empty `else` clause 6 | | pass | |________^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 2 2 | raise try_body_is_not_checked() @@ -30,7 +30,7 @@ RUF047_try.py:15:1: RUF047 [*] Empty `else` clause 16 | | ... | |_______^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 12 12 | belongs() @@ -52,7 +52,7 @@ RUF047_try.py:48:1: RUF047 [*] Empty `else` clause 50 | # This comment belongs to else 51 | finally: | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 45 45 | of_course() diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_while.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_while.py.snap index 97e8bed7eafa0..5c29e8e4d13e8 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_while.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF047_RUF047_while.py.snap @@ -10,7 +10,7 @@ RUF047_while.py:4:1: RUF047 [*] Empty `else` clause 5 | | pass | |________^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 1 1 | while True: @@ -30,7 +30,7 @@ RUF047_while.py:10:1: RUF047 [*] Empty `else` clause 11 | | ... | |_______^ RUF047 | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 7 7 | @@ -51,7 +51,7 @@ RUF047_while.py:35:1: RUF047 [*] Empty `else` clause | |_______^ RUF047 37 | # this comment belongs to the else | - = help: Remove clause + = help: Remove `else` clause ℹ Safe fix 32 32 |