From 7879f9e921c3a67f1b89c290e591bb01799b5479 Mon Sep 17 00:00:00 2001 From: asafamr-mm Date: Sun, 17 Dec 2023 10:21:39 +0200 Subject: [PATCH] moved lists and dicts to preview --- .../test/fixtures/flake8_simplify/SIM300.py | 20 +- .../src/rules/flake8_simplify/mod.rs | 1 + .../flake8_simplify/rules/yoda_conditions.rs | 78 +-- ...ke8_simplify__tests__SIM300_SIM300.py.snap | 505 +++++++++--------- ...ify__tests__preview__SIM300_SIM300.py.snap | 354 ++++++++++++ 5 files changed, 652 insertions(+), 306 deletions(-) create mode 100644 crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM300_SIM300.py.snap diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py index d97692d7931c5..fbb460fa3b7b9 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py @@ -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 @@ 0 < (number - 100) # SIM300 B 0 -UPPER_LIST == ['upper'] -DummyHandler.CONFIG == {} -{"thats": "acceptable"} == DummyHandler.CONFIG -SECONDS_IN_DAY == 60 * 60 * 24 -SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) \ No newline at end of file +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 + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs index e23eeaa4973b3..c472b56c0d079 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs @@ -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<()> { diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs index 12b613b742172..bc89b58f05ea1 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs @@ -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; } diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 0cf18103230e2..75f859f078eec 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -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 - -SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead +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 | -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 - -SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead +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 | -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 - -SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead +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 | -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 - -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` +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 -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 - -SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead +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 | - 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 - -SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead +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 | - 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 - -SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead +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 | - 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 - -SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead +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 | -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 - -SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead +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 | -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 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 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 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 0` instead +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 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 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 B` instead +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 B` instead | -14 | JediOrder.YODA == age # SIM300 -15 | 0 < (number - 100) # SIM300 -16 | B B` ℹ Safe fix -13 13 | YODA >= age # SIM300 -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 |-B B or B -17 17 | B or(B) (B)` instead +12 12 | YODA >= age # SIM300 +13 13 | JediOrder.YODA == age # SIM300 +14 14 | 0 < (number - 100) # SIM300 +15 |-B B or B +16 16 | B or(B) (B)` instead | -15 | 0 < (number - 100) # SIM300 -16 | B (B)` ℹ Safe fix -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 16 | B (B) -18 18 | ['upper'] == UPPER_LIST -19 19 | {} == DummyHandler.CONFIG -20 20 | - -SIM300.py:18:1: SIM300 [*] Yoda conditions are discouraged, use `UPPER_LIST == ['upper']` instead +13 13 | JediOrder.YODA == age # SIM300 +14 14 | 0 < (number - 100) # SIM300 +15 15 | B (B) +17 17 | +18 18 | # Errors in preview +19 19 | ['upper'] == UPPER_LIST + +SIM300.py:23:1: SIM300 [*] Yoda conditions are discouraged, use `['upper'] == UPPER_LIST` instead | -16 | B 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 age # SIM300 +12 | YODA >= age # SIM300 +13 | JediOrder.YODA == age # SIM300 + | ^^^^^^^^^^^^^^^^^^^^^ SIM300 +14 | 0 < (number - 100) # SIM300 +15 | B 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 0` instead + | +12 | YODA >= age # SIM300 +13 | JediOrder.YODA == age # SIM300 +14 | 0 < (number - 100) # SIM300 + | ^^^^^^^^^^^^^^^^^^ SIM300 +15 | B 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 B` instead + | +13 | JediOrder.YODA == age # SIM300 +14 | 0 < (number - 100) # SIM300 +15 | B B` + +ℹ Safe fix +12 12 | YODA >= age # SIM300 +13 13 | JediOrder.YODA == age # SIM300 +14 14 | 0 < (number - 100) # SIM300 +15 |-B B or B +16 16 | B or(B) (B)` instead + | +14 | 0 < (number - 100) # SIM300 +15 | B (B)` + +ℹ Safe fix +13 13 | JediOrder.YODA == age # SIM300 +14 14 | 0 < (number - 100) # SIM300 +15 15 | B (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)