mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 04:48:07 +00:00
Allow the if_not_else Clippy lint
Specifically, the [`if_not_else`] lint will sometimes flag code to change the order of `if` and `else` bodies if this would allow a `!` to be removed. While perhaps tasteful in some cases, there are many cases in my experience where this bows to other competing concerns that impact readability. (Such as the relative sizes of the `if` and `else` bodies, or perhaps an ordering that just makes the code flow in a more natural way.) [`if_not_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#/if_not_else
This commit is contained in:
parent
61f906d8e7
commit
25853e2377
5 changed files with 8 additions and 4 deletions
|
|
@ -79,7 +79,6 @@ impl Violation for FastApiUnusedPathParameter {
|
|||
function_name,
|
||||
is_positional,
|
||||
} = self;
|
||||
#[expect(clippy::if_not_else)]
|
||||
if !is_positional {
|
||||
format!(
|
||||
"Parameter `{arg_name}` appears in route path, but not in `{function_name}` signature"
|
||||
|
|
|
|||
|
|
@ -141,7 +141,6 @@ impl Violation for InvalidFirstArgumentNameForClassMethod {
|
|||
#[derive_message_formats]
|
||||
// The first string below is what shows up in the documentation
|
||||
// in the rule table, and it is the more common case.
|
||||
#[expect(clippy::if_not_else)]
|
||||
fn message(&self) -> String {
|
||||
if !self.is_new {
|
||||
"First argument of a class method should be named `cls`".to_string()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ impl Violation for UselessImportAlias {
|
|||
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
#[expect(clippy::if_not_else)]
|
||||
if !self.required_import_conflict {
|
||||
"Import alias does not rename original package".to_string()
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue