mirror of https://github.com/astral-sh/ruff
moved lists and dicts to preview
This commit is contained in:
parent
935b77ec80
commit
7879f9e921
|
|
@ -1,6 +1,5 @@
|
|||
# Errors
|
||||
"yoda" == compare # SIM300
|
||||
"yoda" == compare # SIM300
|
||||
42 == age # SIM300
|
||||
("a", "b") == compare # SIM300
|
||||
"yoda" <= compare # SIM300
|
||||
|
|
@ -15,8 +14,14 @@ JediOrder.YODA == age # SIM300
|
|||
0 < (number - 100) # SIM300
|
||||
B<A[0][0]or B
|
||||
B or(B)<A[0][0]
|
||||
['upper'] == UPPER_LIST
|
||||
{} == DummyHandler.CONFIG
|
||||
|
||||
# Errors in preview
|
||||
['upper'] == UPPER_LIST
|
||||
{} == DummyHandler.CONFIG
|
||||
|
||||
# Errors in stable
|
||||
UPPER_LIST == ['upper']
|
||||
DummyHandler.CONFIG == {}
|
||||
|
||||
# OK
|
||||
compare == "yoda"
|
||||
|
|
@ -32,8 +37,7 @@ age <= YODA
|
|||
YODA == YODA
|
||||
age == JediOrder.YODA
|
||||
(number - 100) > 0
|
||||
UPPER_LIST == ['upper']
|
||||
DummyHandler.CONFIG == {}
|
||||
{"thats": "acceptable"} == DummyHandler.CONFIG
|
||||
SECONDS_IN_DAY == 60 * 60 * 24
|
||||
SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60)
|
||||
SECONDS_IN_DAY == 60 * 60 * 24 # Error in 0.1.8
|
||||
SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # Error in 0.1.8
|
||||
{"non-empty-dict": "is-ok"} == DummyHandler.CONFIG
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test_case(Rule::InDictKeys, Path::new("SIM118.py"))]
|
||||
#[test_case(Rule::YodaConditions, Path::new("SIM300.py"))]
|
||||
#[test_case(Rule::IfElseBlockInsteadOfDictGet, Path::new("SIM401.py"))]
|
||||
#[test_case(Rule::DictGetWithNoneDefault, Path::new("SIM910.py"))]
|
||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
|
|
|
|||
|
|
@ -92,43 +92,51 @@ enum ConstantLikelihood {
|
|||
/// The expression is a constant for certain (e.g., `42` or `"foo"`).
|
||||
Definitely = 2,
|
||||
}
|
||||
fn how_likely_constant_str(s: &str) -> ConstantLikelihood {
|
||||
if str::is_cased_uppercase(s) {
|
||||
ConstantLikelihood::Probably
|
||||
} else {
|
||||
ConstantLikelihood::Unlikely
|
||||
}
|
||||
}
|
||||
|
||||
/// Return [`Expr`] [`ConstantLikelihood`] level depending on simple heuristics.
|
||||
fn how_likely_constant(expr: &Expr) -> ConstantLikelihood {
|
||||
if expr.is_literal_expr() {
|
||||
return ConstantLikelihood::Definitely;
|
||||
}
|
||||
match expr {
|
||||
Expr::Attribute(ast::ExprAttribute { attr, .. }) => how_likely_constant_str(attr),
|
||||
Expr::Name(ast::ExprName { id, .. }) => how_likely_constant_str(id),
|
||||
Expr::Tuple(ast::ExprTuple { elts, .. }) | Expr::List(ast::ExprList { elts, .. }) => elts
|
||||
.iter()
|
||||
.map(how_likely_constant)
|
||||
.min()
|
||||
.unwrap_or(ConstantLikelihood::Definitely),
|
||||
Expr::Dict(ast::ExprDict { values: vs, .. }) => {
|
||||
if vs.is_empty() {
|
||||
ConstantLikelihood::Definitely
|
||||
} else {
|
||||
ConstantLikelihood::Probably
|
||||
impl ConstantLikelihood {
|
||||
fn from_expression(expr: &Expr, is_preview_enabled: bool) -> Self {
|
||||
match expr {
|
||||
_ if expr.is_literal_expr() => ConstantLikelihood::Definitely,
|
||||
Expr::Attribute(ast::ExprAttribute { attr, .. }) => {
|
||||
ConstantLikelihood::from_identifier(attr)
|
||||
}
|
||||
Expr::Name(ast::ExprName { id, .. }) => ConstantLikelihood::from_identifier(id),
|
||||
Expr::Tuple(ast::ExprTuple { elts, .. }) => elts
|
||||
.iter()
|
||||
.map(|x| ConstantLikelihood::from_expression(x, is_preview_enabled))
|
||||
.min()
|
||||
.unwrap_or(ConstantLikelihood::Definitely),
|
||||
Expr::List(ast::ExprList { elts, .. }) if is_preview_enabled => elts
|
||||
.iter()
|
||||
.map(|x| ConstantLikelihood::from_expression(x, is_preview_enabled))
|
||||
.min()
|
||||
.unwrap_or(ConstantLikelihood::Definitely),
|
||||
Expr::Dict(ast::ExprDict { values: vs, .. }) if is_preview_enabled => {
|
||||
if vs.is_empty() {
|
||||
ConstantLikelihood::Definitely
|
||||
} else {
|
||||
ConstantLikelihood::Probably
|
||||
}
|
||||
}
|
||||
Expr::BinOp(ast::ExprBinOp { left, right, .. }) => cmp::min(
|
||||
ConstantLikelihood::from_expression(left, is_preview_enabled),
|
||||
ConstantLikelihood::from_expression(right, is_preview_enabled),
|
||||
),
|
||||
Expr::UnaryOp(ast::ExprUnaryOp {
|
||||
op: UnaryOp::UAdd | UnaryOp::USub | UnaryOp::Invert,
|
||||
operand,
|
||||
range: _,
|
||||
}) => ConstantLikelihood::from_expression(operand, is_preview_enabled),
|
||||
_ => ConstantLikelihood::Unlikely,
|
||||
}
|
||||
Expr::BinOp(ast::ExprBinOp { left, right, .. }) => {
|
||||
cmp::min(how_likely_constant(left), how_likely_constant(right))
|
||||
}
|
||||
|
||||
fn from_identifier(identifier: &str) -> Self {
|
||||
if str::is_cased_uppercase(identifier) {
|
||||
ConstantLikelihood::Probably
|
||||
} else {
|
||||
ConstantLikelihood::Unlikely
|
||||
}
|
||||
Expr::UnaryOp(ast::ExprUnaryOp {
|
||||
op: UnaryOp::UAdd | UnaryOp::USub | UnaryOp::Invert,
|
||||
operand,
|
||||
range: _,
|
||||
}) => how_likely_constant(operand),
|
||||
_ => ConstantLikelihood::Unlikely,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +227,9 @@ pub(crate) fn yoda_conditions(
|
|||
return;
|
||||
}
|
||||
|
||||
if how_likely_constant(left) <= how_likely_constant(right) {
|
||||
if ConstantLikelihood::from_expression(left, checker.settings.preview.is_enabled())
|
||||
<= ConstantLikelihood::from_expression(right, checker.settings.preview.is_enabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
|||
1 | # Errors
|
||||
2 | "yoda" == compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^ SIM300
|
||||
3 | "yoda" == compare # SIM300
|
||||
4 | 42 == age # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare == "yoda"`
|
||||
|
||||
|
|
@ -15,363 +15,340 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
|||
1 1 | # Errors
|
||||
2 |-"yoda" == compare # SIM300
|
||||
2 |+compare == "yoda" # SIM300
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
|
||||
SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead
|
||||
SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead
|
||||
|
|
||||
1 | # Errors
|
||||
2 | "yoda" == compare # SIM300
|
||||
3 | "yoda" == compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^ SIM300
|
||||
4 | 42 == age # SIM300
|
||||
5 | ("a", "b") == compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare == "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 |-"yoda" == compare # SIM300
|
||||
3 |+compare == "yoda" # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
|
||||
SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead
|
||||
|
|
||||
2 | "yoda" == compare # SIM300
|
||||
3 | "yoda" == compare # SIM300
|
||||
4 | 42 == age # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
5 | ("a", "b") == compare # SIM300
|
||||
6 | "yoda" <= compare # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age == 42`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 |-42 == age # SIM300
|
||||
4 |+age == 42 # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
3 |-42 == age # SIM300
|
||||
3 |+age == 42 # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
|
||||
SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead
|
||||
SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead
|
||||
|
|
||||
3 | "yoda" == compare # SIM300
|
||||
4 | 42 == age # SIM300
|
||||
5 | ("a", "b") == compare # SIM300
|
||||
2 | "yoda" == compare # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
6 | "yoda" <= compare # SIM300
|
||||
7 | "yoda" < compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare == ("a", "b")`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
5 |-("a", "b") == compare # SIM300
|
||||
5 |+compare == ("a", "b") # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 |-("a", "b") == compare # SIM300
|
||||
4 |+compare == ("a", "b") # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
|
||||
SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead
|
||||
SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead
|
||||
|
|
||||
4 | 42 == age # SIM300
|
||||
5 | ("a", "b") == compare # SIM300
|
||||
6 | "yoda" <= compare # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^ SIM300
|
||||
7 | "yoda" < compare # SIM300
|
||||
8 | 42 > age # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare >= "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 |-"yoda" <= compare # SIM300
|
||||
6 |+compare >= "yoda" # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 |-"yoda" <= compare # SIM300
|
||||
5 |+compare >= "yoda" # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
|
||||
SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead
|
||||
SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead
|
||||
|
|
||||
5 | ("a", "b") == compare # SIM300
|
||||
6 | "yoda" <= compare # SIM300
|
||||
7 | "yoda" < compare # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^ SIM300
|
||||
8 | 42 > age # SIM300
|
||||
9 | -42 > age # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare > "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 |-"yoda" < compare # SIM300
|
||||
7 |+compare > "yoda" # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 |-"yoda" < compare # SIM300
|
||||
6 |+compare > "yoda" # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
|
||||
SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead
|
||||
|
|
||||
6 | "yoda" <= compare # SIM300
|
||||
7 | "yoda" < compare # SIM300
|
||||
8 | 42 > age # SIM300
|
||||
| ^^^^^^^^ SIM300
|
||||
9 | -42 > age # SIM300
|
||||
10 | +42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < 42`
|
||||
SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead
|
||||
|
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
| ^^^^^^^^ SIM300
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < 42`
|
||||
|
||||
ℹ Safe fix
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 |-42 > age # SIM300
|
||||
8 |+age < 42 # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 |-42 > age # SIM300
|
||||
7 |+age < 42 # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
|
||||
SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead
|
||||
SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead
|
||||
|
|
||||
7 | "yoda" < compare # SIM300
|
||||
8 | 42 > age # SIM300
|
||||
9 | -42 > age # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
10 | +42 > age # SIM300
|
||||
11 | YODA == age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < -42`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
9 |--42 > age # SIM300
|
||||
9 |+age < -42 # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 |--42 > age # SIM300
|
||||
8 |+age < -42 # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
|
||||
SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead
|
||||
SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead
|
||||
|
|
||||
8 | 42 > age # SIM300
|
||||
9 | -42 > age # SIM300
|
||||
10 | +42 > age # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
11 | YODA == age # SIM300
|
||||
12 | YODA > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < +42`
|
||||
|
||||
ℹ Safe fix
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
10 |-+42 > age # SIM300
|
||||
10 |+age < +42 # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 |-+42 > age # SIM300
|
||||
9 |+age < +42 # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
|
||||
SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead
|
||||
SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead
|
||||
|
|
||||
9 | -42 > age # SIM300
|
||||
10 | +42 > age # SIM300
|
||||
11 | YODA == age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
12 | YODA > age # SIM300
|
||||
13 | YODA >= age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age == YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
11 |-YODA == age # SIM300
|
||||
11 |+age == YODA # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 |-YODA == age # SIM300
|
||||
10 |+age == YODA # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
|
||||
SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead
|
||||
SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead
|
||||
|
|
||||
10 | +42 > age # SIM300
|
||||
11 | YODA == age # SIM300
|
||||
12 | YODA > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
| ^^^^^^^^^^ SIM300
|
||||
13 | YODA >= age # SIM300
|
||||
14 | JediOrder.YODA == age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
12 |-YODA > age # SIM300
|
||||
12 |+age < YODA # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 |-YODA > age # SIM300
|
||||
11 |+age < YODA # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
|
||||
SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead
|
||||
SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead
|
||||
|
|
||||
11 | YODA == age # SIM300
|
||||
12 | YODA > age # SIM300
|
||||
13 | YODA >= age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
14 | JediOrder.YODA == age # SIM300
|
||||
15 | 0 < (number - 100) # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age <= YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
13 |-YODA >= age # SIM300
|
||||
13 |+age <= YODA # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
16 16 | B<A[0][0]or B
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 |-YODA >= age # SIM300
|
||||
12 |+age <= YODA # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
|
||||
SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead
|
||||
SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead
|
||||
|
|
||||
12 | YODA > age # SIM300
|
||||
13 | YODA >= age # SIM300
|
||||
14 | JediOrder.YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
15 | 0 < (number - 100) # SIM300
|
||||
16 | B<A[0][0]or B
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
|
|
||||
= help: Replace Yoda condition with `age == JediOrder.YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 |-JediOrder.YODA == age # SIM300
|
||||
14 |+age == JediOrder.YODA # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
16 16 | B<A[0][0]or B
|
||||
17 17 | B or(B)<A[0][0]
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 |-JediOrder.YODA == age # SIM300
|
||||
13 |+age == JediOrder.YODA # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
|
||||
SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) > 0` instead
|
||||
SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) > 0` instead
|
||||
|
|
||||
13 | YODA >= age # SIM300
|
||||
14 | JediOrder.YODA == age # SIM300
|
||||
15 | 0 < (number - 100) # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^ SIM300
|
||||
16 | B<A[0][0]or B
|
||||
17 | B or(B)<A[0][0]
|
||||
15 | B<A[0][0]or B
|
||||
16 | B or(B)<A[0][0]
|
||||
|
|
||||
= help: Replace Yoda condition with `(number - 100) > 0`
|
||||
|
||||
ℹ Safe fix
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 |-0 < (number - 100) # SIM300
|
||||
15 |+(number - 100) > 0 # SIM300
|
||||
16 16 | B<A[0][0]or B
|
||||
17 17 | B or(B)<A[0][0]
|
||||
18 18 | ['upper'] == UPPER_LIST
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 |-0 < (number - 100) # SIM300
|
||||
14 |+(number - 100) > 0 # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
17 17 |
|
||||
|
||||
SIM300.py:16:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` instead
|
||||
SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` instead
|
||||
|
|
||||
14 | JediOrder.YODA == age # SIM300
|
||||
15 | 0 < (number - 100) # SIM300
|
||||
16 | B<A[0][0]or B
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
| ^^^^^^^^^ SIM300
|
||||
17 | B or(B)<A[0][0]
|
||||
18 | ['upper'] == UPPER_LIST
|
||||
16 | B or(B)<A[0][0]
|
||||
|
|
||||
= help: Replace Yoda condition with `A[0][0] > B`
|
||||
|
||||
ℹ Safe fix
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
16 |-B<A[0][0]or B
|
||||
16 |+A[0][0] > B or B
|
||||
17 17 | B or(B)<A[0][0]
|
||||
18 18 | ['upper'] == UPPER_LIST
|
||||
19 19 | {} == DummyHandler.CONFIG
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 |-B<A[0][0]or B
|
||||
15 |+A[0][0] > B or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
|
||||
SIM300.py:17:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` instead
|
||||
SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` instead
|
||||
|
|
||||
15 | 0 < (number - 100) # SIM300
|
||||
16 | B<A[0][0]or B
|
||||
17 | B or(B)<A[0][0]
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
16 | B or(B)<A[0][0]
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
18 | ['upper'] == UPPER_LIST
|
||||
19 | {} == DummyHandler.CONFIG
|
||||
17 |
|
||||
18 | # Errors in preview
|
||||
|
|
||||
= help: Replace Yoda condition with `A[0][0] > (B)`
|
||||
|
||||
ℹ Safe fix
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
16 16 | B<A[0][0]or B
|
||||
17 |-B or(B)<A[0][0]
|
||||
17 |+B or A[0][0] > (B)
|
||||
18 18 | ['upper'] == UPPER_LIST
|
||||
19 19 | {} == DummyHandler.CONFIG
|
||||
20 20 |
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 |-B or(B)<A[0][0]
|
||||
16 |+B or A[0][0] > (B)
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
19 19 | ['upper'] == UPPER_LIST
|
||||
|
||||
SIM300.py:18:1: SIM300 [*] Yoda conditions are discouraged, use `UPPER_LIST == ['upper']` instead
|
||||
SIM300.py:23:1: SIM300 [*] Yoda conditions are discouraged, use `['upper'] == UPPER_LIST` instead
|
||||
|
|
||||
16 | B<A[0][0]or B
|
||||
17 | B or(B)<A[0][0]
|
||||
18 | ['upper'] == UPPER_LIST
|
||||
22 | # Errors in stable
|
||||
23 | UPPER_LIST == ['upper']
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
19 | {} == DummyHandler.CONFIG
|
||||
24 | DummyHandler.CONFIG == {}
|
||||
|
|
||||
= help: Replace Yoda condition with `UPPER_LIST == ['upper']`
|
||||
= help: Replace Yoda condition with `['upper'] == UPPER_LIST`
|
||||
|
||||
ℹ Safe fix
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
16 16 | B<A[0][0]or B
|
||||
17 17 | B or(B)<A[0][0]
|
||||
18 |-['upper'] == UPPER_LIST
|
||||
18 |+UPPER_LIST == ['upper']
|
||||
19 19 | {} == DummyHandler.CONFIG
|
||||
20 20 |
|
||||
21 21 | # OK
|
||||
20 20 | {} == DummyHandler.CONFIG
|
||||
21 21 |
|
||||
22 22 | # Errors in stable
|
||||
23 |-UPPER_LIST == ['upper']
|
||||
23 |+['upper'] == UPPER_LIST
|
||||
24 24 | DummyHandler.CONFIG == {}
|
||||
25 25 |
|
||||
26 26 | # OK
|
||||
|
||||
SIM300.py:19:1: SIM300 [*] Yoda conditions are discouraged, use `DummyHandler.CONFIG == {}` instead
|
||||
SIM300.py:24:1: SIM300 [*] Yoda conditions are discouraged, use `{} == DummyHandler.CONFIG` instead
|
||||
|
|
||||
17 | B or(B)<A[0][0]
|
||||
18 | ['upper'] == UPPER_LIST
|
||||
19 | {} == DummyHandler.CONFIG
|
||||
22 | # Errors in stable
|
||||
23 | UPPER_LIST == ['upper']
|
||||
24 | DummyHandler.CONFIG == {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
20 |
|
||||
21 | # OK
|
||||
25 |
|
||||
26 | # OK
|
||||
|
|
||||
= help: Replace Yoda condition with `DummyHandler.CONFIG == {}`
|
||||
= help: Replace Yoda condition with `{} == DummyHandler.CONFIG`
|
||||
|
||||
ℹ Safe fix
|
||||
16 16 | B<A[0][0]or B
|
||||
17 17 | B or(B)<A[0][0]
|
||||
18 18 | ['upper'] == UPPER_LIST
|
||||
19 |-{} == DummyHandler.CONFIG
|
||||
19 |+DummyHandler.CONFIG == {}
|
||||
20 20 |
|
||||
21 21 | # OK
|
||||
22 22 | compare == "yoda"
|
||||
21 21 |
|
||||
22 22 | # Errors in stable
|
||||
23 23 | UPPER_LIST == ['upper']
|
||||
24 |-DummyHandler.CONFIG == {}
|
||||
24 |+{} == DummyHandler.CONFIG
|
||||
25 25 |
|
||||
26 26 | # OK
|
||||
27 27 | compare == "yoda"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,354 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
|
||||
---
|
||||
SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead
|
||||
|
|
||||
1 | # Errors
|
||||
2 | "yoda" == compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^ SIM300
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare == "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 |-"yoda" == compare # SIM300
|
||||
2 |+compare == "yoda" # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
|
||||
SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead
|
||||
|
|
||||
1 | # Errors
|
||||
2 | "yoda" == compare # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age == 42`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 |-42 == age # SIM300
|
||||
3 |+age == 42 # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
|
||||
SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead
|
||||
|
|
||||
2 | "yoda" == compare # SIM300
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare == ("a", "b")`
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 |-("a", "b") == compare # SIM300
|
||||
4 |+compare == ("a", "b") # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
|
||||
SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead
|
||||
|
|
||||
3 | 42 == age # SIM300
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^ SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare >= "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 |-"yoda" <= compare # SIM300
|
||||
5 |+compare >= "yoda" # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
|
||||
SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead
|
||||
|
|
||||
4 | ("a", "b") == compare # SIM300
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
| ^^^^^^^^^^^^^^^^ SIM300
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `compare > "yoda"`
|
||||
|
||||
ℹ Safe fix
|
||||
3 3 | 42 == age # SIM300
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 |-"yoda" < compare # SIM300
|
||||
6 |+compare > "yoda" # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
|
||||
SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead
|
||||
|
|
||||
5 | "yoda" <= compare # SIM300
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
| ^^^^^^^^ SIM300
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < 42`
|
||||
|
||||
ℹ Safe fix
|
||||
4 4 | ("a", "b") == compare # SIM300
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 |-42 > age # SIM300
|
||||
7 |+age < 42 # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
|
||||
SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead
|
||||
|
|
||||
6 | "yoda" < compare # SIM300
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < -42`
|
||||
|
||||
ℹ Safe fix
|
||||
5 5 | "yoda" <= compare # SIM300
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 |--42 > age # SIM300
|
||||
8 |+age < -42 # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
|
||||
SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead
|
||||
|
|
||||
7 | 42 > age # SIM300
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
| ^^^^^^^^^ SIM300
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < +42`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 | "yoda" < compare # SIM300
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 |-+42 > age # SIM300
|
||||
9 |+age < +42 # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
|
||||
SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead
|
||||
|
|
||||
8 | -42 > age # SIM300
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age == YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
7 7 | 42 > age # SIM300
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 |-YODA == age # SIM300
|
||||
10 |+age == YODA # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
|
||||
SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead
|
||||
|
|
||||
9 | +42 > age # SIM300
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
| ^^^^^^^^^^ SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age < YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
8 8 | -42 > age # SIM300
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 |-YODA > age # SIM300
|
||||
11 |+age < YODA # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
|
||||
SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead
|
||||
|
|
||||
10 | YODA == age # SIM300
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
|
|
||||
= help: Replace Yoda condition with `age <= YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
9 9 | +42 > age # SIM300
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 |-YODA >= age # SIM300
|
||||
12 |+age <= YODA # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
|
||||
SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead
|
||||
|
|
||||
11 | YODA > age # SIM300
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
|
|
||||
= help: Replace Yoda condition with `age == JediOrder.YODA`
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 | YODA == age # SIM300
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 |-JediOrder.YODA == age # SIM300
|
||||
13 |+age == JediOrder.YODA # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
|
||||
SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) > 0` instead
|
||||
|
|
||||
12 | YODA >= age # SIM300
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
| ^^^^^^^^^^^^^^^^^^ SIM300
|
||||
15 | B<A[0][0]or B
|
||||
16 | B or(B)<A[0][0]
|
||||
|
|
||||
= help: Replace Yoda condition with `(number - 100) > 0`
|
||||
|
||||
ℹ Safe fix
|
||||
11 11 | YODA > age # SIM300
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 |-0 < (number - 100) # SIM300
|
||||
14 |+(number - 100) > 0 # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
17 17 |
|
||||
|
||||
SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` instead
|
||||
|
|
||||
13 | JediOrder.YODA == age # SIM300
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
| ^^^^^^^^^ SIM300
|
||||
16 | B or(B)<A[0][0]
|
||||
|
|
||||
= help: Replace Yoda condition with `A[0][0] > B`
|
||||
|
||||
ℹ Safe fix
|
||||
12 12 | YODA >= age # SIM300
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 |-B<A[0][0]or B
|
||||
15 |+A[0][0] > B or B
|
||||
16 16 | B or(B)<A[0][0]
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
|
||||
SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` instead
|
||||
|
|
||||
14 | 0 < (number - 100) # SIM300
|
||||
15 | B<A[0][0]or B
|
||||
16 | B or(B)<A[0][0]
|
||||
| ^^^^^^^^^^^ SIM300
|
||||
17 |
|
||||
18 | # Errors in preview
|
||||
|
|
||||
= help: Replace Yoda condition with `A[0][0] > (B)`
|
||||
|
||||
ℹ Safe fix
|
||||
13 13 | JediOrder.YODA == age # SIM300
|
||||
14 14 | 0 < (number - 100) # SIM300
|
||||
15 15 | B<A[0][0]or B
|
||||
16 |-B or(B)<A[0][0]
|
||||
16 |+B or A[0][0] > (B)
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
19 19 | ['upper'] == UPPER_LIST
|
||||
|
||||
SIM300.py:19:1: SIM300 [*] Yoda conditions are discouraged, use `UPPER_LIST == ['upper']` instead
|
||||
|
|
||||
18 | # Errors in preview
|
||||
19 | ['upper'] == UPPER_LIST
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
20 | {} == DummyHandler.CONFIG
|
||||
|
|
||||
= help: Replace Yoda condition with `UPPER_LIST == ['upper']`
|
||||
|
||||
ℹ Safe fix
|
||||
16 16 | B or(B)<A[0][0]
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
19 |-['upper'] == UPPER_LIST
|
||||
19 |+UPPER_LIST == ['upper']
|
||||
20 20 | {} == DummyHandler.CONFIG
|
||||
21 21 |
|
||||
22 22 | # Errors in stable
|
||||
|
||||
SIM300.py:20:1: SIM300 [*] Yoda conditions are discouraged, use `DummyHandler.CONFIG == {}` instead
|
||||
|
|
||||
18 | # Errors in preview
|
||||
19 | ['upper'] == UPPER_LIST
|
||||
20 | {} == DummyHandler.CONFIG
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||
21 |
|
||||
22 | # Errors in stable
|
||||
|
|
||||
= help: Replace Yoda condition with `DummyHandler.CONFIG == {}`
|
||||
|
||||
ℹ Safe fix
|
||||
17 17 |
|
||||
18 18 | # Errors in preview
|
||||
19 19 | ['upper'] == UPPER_LIST
|
||||
20 |-{} == DummyHandler.CONFIG
|
||||
20 |+DummyHandler.CONFIG == {}
|
||||
21 21 |
|
||||
22 22 | # Errors in stable
|
||||
23 23 | UPPER_LIST == ['upper']
|
||||
|
||||
|
||||
Loading…
Reference in New Issue