mirror of https://github.com/astral-sh/ruff
[`flake8-simplify`] Stabilize detection of Yoda conditions for "constant" collections (`SIM300`) (#12050)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
This commit is contained in:
parent
4029a25ebd
commit
04c8597b8a
|
|
@ -9,7 +9,6 @@ mod tests {
|
||||||
use test_case::test_case;
|
use test_case::test_case;
|
||||||
|
|
||||||
use crate::registry::Rule;
|
use crate::registry::Rule;
|
||||||
use crate::settings::types::PreviewMode;
|
|
||||||
use crate::test::test_path;
|
use crate::test::test_path;
|
||||||
use crate::{assert_messages, settings};
|
use crate::{assert_messages, settings};
|
||||||
|
|
||||||
|
|
@ -55,22 +54,4 @@ mod tests {
|
||||||
assert_messages!(snapshot, diagnostics);
|
assert_messages!(snapshot, diagnostics);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test_case(Rule::YodaConditions, Path::new("SIM300.py"))]
|
|
||||||
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
|
|
||||||
let snapshot = format!(
|
|
||||||
"preview__{}_{}",
|
|
||||||
rule_code.noqa_code(),
|
|
||||||
path.to_string_lossy()
|
|
||||||
);
|
|
||||||
let diagnostics = test_path(
|
|
||||||
Path::new("flake8_simplify").join(path).as_path(),
|
|
||||||
&settings::LinterSettings {
|
|
||||||
preview: PreviewMode::Enabled,
|
|
||||||
..settings::LinterSettings::for_rule(rule_code)
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
assert_messages!(snapshot, diagnostics);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ use crate::cst::helpers::or_space;
|
||||||
use crate::cst::matchers::{match_comparison, transform_expression};
|
use crate::cst::matchers::{match_comparison, transform_expression};
|
||||||
use crate::fix::edits::pad;
|
use crate::fix::edits::pad;
|
||||||
use crate::fix::snippet::SourceCodeSnippet;
|
use crate::fix::snippet::SourceCodeSnippet;
|
||||||
use crate::settings::types::PreviewMode;
|
|
||||||
|
|
||||||
/// ## What it does
|
/// ## What it does
|
||||||
/// Checks for conditions that position a constant on the left-hand side of the
|
/// Checks for conditions that position a constant on the left-hand side of the
|
||||||
|
|
@ -58,26 +57,15 @@ impl Violation for YodaConditions {
|
||||||
|
|
||||||
#[derive_message_formats]
|
#[derive_message_formats]
|
||||||
fn message(&self) -> String {
|
fn message(&self) -> String {
|
||||||
let YodaConditions { suggestion } = self;
|
format!("Yoda condition detected")
|
||||||
if let Some(suggestion) = suggestion
|
|
||||||
.as_ref()
|
|
||||||
.and_then(SourceCodeSnippet::full_display)
|
|
||||||
{
|
|
||||||
format!("Yoda conditions are discouraged, use `{suggestion}` instead")
|
|
||||||
} else {
|
|
||||||
format!("Yoda conditions are discouraged")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fix_title(&self) -> Option<String> {
|
fn fix_title(&self) -> Option<String> {
|
||||||
let YodaConditions { suggestion } = self;
|
let YodaConditions { suggestion } = self;
|
||||||
suggestion.as_ref().map(|suggestion| {
|
suggestion
|
||||||
if let Some(suggestion) = suggestion.full_display() {
|
.as_ref()
|
||||||
format!("Replace Yoda condition with `{suggestion}`")
|
.and_then(|suggestion| suggestion.full_display())
|
||||||
} else {
|
.map(|suggestion| format!("Rewrite as `{suggestion}`"))
|
||||||
format!("Replace Yoda condition")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,9 +82,9 @@ enum ConstantLikelihood {
|
||||||
Definitely = 2,
|
Definitely = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstantLikelihood {
|
impl From<&Expr> for ConstantLikelihood {
|
||||||
/// Determine the [`ConstantLikelihood`] of an expression.
|
/// Determine the [`ConstantLikelihood`] of an expression.
|
||||||
fn from_expression(expr: &Expr, preview: PreviewMode) -> Self {
|
fn from(expr: &Expr) -> Self {
|
||||||
match expr {
|
match expr {
|
||||||
_ if expr.is_literal_expr() => ConstantLikelihood::Definitely,
|
_ if expr.is_literal_expr() => ConstantLikelihood::Definitely,
|
||||||
Expr::Attribute(ast::ExprAttribute { attr, .. }) => {
|
Expr::Attribute(ast::ExprAttribute { attr, .. }) => {
|
||||||
|
|
@ -105,15 +93,15 @@ impl ConstantLikelihood {
|
||||||
Expr::Name(ast::ExprName { id, .. }) => ConstantLikelihood::from_identifier(id),
|
Expr::Name(ast::ExprName { id, .. }) => ConstantLikelihood::from_identifier(id),
|
||||||
Expr::Tuple(ast::ExprTuple { elts, .. }) => elts
|
Expr::Tuple(ast::ExprTuple { elts, .. }) => elts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|expr| ConstantLikelihood::from_expression(expr, preview))
|
.map(ConstantLikelihood::from)
|
||||||
.min()
|
.min()
|
||||||
.unwrap_or(ConstantLikelihood::Definitely),
|
.unwrap_or(ConstantLikelihood::Definitely),
|
||||||
Expr::List(ast::ExprList { elts, .. }) if preview.is_enabled() => elts
|
Expr::List(ast::ExprList { elts, .. }) => elts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|expr| ConstantLikelihood::from_expression(expr, preview))
|
.map(ConstantLikelihood::from)
|
||||||
.min()
|
.min()
|
||||||
.unwrap_or(ConstantLikelihood::Definitely),
|
.unwrap_or(ConstantLikelihood::Definitely),
|
||||||
Expr::Dict(ast::ExprDict { items, .. }) if preview.is_enabled() => {
|
Expr::Dict(ast::ExprDict { items, .. }) => {
|
||||||
if items.is_empty() {
|
if items.is_empty() {
|
||||||
ConstantLikelihood::Definitely
|
ConstantLikelihood::Definitely
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -121,18 +109,20 @@ impl ConstantLikelihood {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::BinOp(ast::ExprBinOp { left, right, .. }) => cmp::min(
|
Expr::BinOp(ast::ExprBinOp { left, right, .. }) => cmp::min(
|
||||||
ConstantLikelihood::from_expression(left, preview),
|
ConstantLikelihood::from(&**left),
|
||||||
ConstantLikelihood::from_expression(right, preview),
|
ConstantLikelihood::from(&**right),
|
||||||
),
|
),
|
||||||
Expr::UnaryOp(ast::ExprUnaryOp {
|
Expr::UnaryOp(ast::ExprUnaryOp {
|
||||||
op: UnaryOp::UAdd | UnaryOp::USub | UnaryOp::Invert,
|
op: UnaryOp::UAdd | UnaryOp::USub | UnaryOp::Invert,
|
||||||
operand,
|
operand,
|
||||||
range: _,
|
range: _,
|
||||||
}) => ConstantLikelihood::from_expression(operand, preview),
|
}) => ConstantLikelihood::from(&**operand),
|
||||||
_ => ConstantLikelihood::Unlikely,
|
_ => ConstantLikelihood::Unlikely,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ConstantLikelihood {
|
||||||
/// Determine the [`ConstantLikelihood`] of an identifier.
|
/// Determine the [`ConstantLikelihood`] of an identifier.
|
||||||
fn from_identifier(identifier: &str) -> Self {
|
fn from_identifier(identifier: &str) -> Self {
|
||||||
if str::is_cased_uppercase(identifier) {
|
if str::is_cased_uppercase(identifier) {
|
||||||
|
|
@ -230,9 +220,7 @@ pub(crate) fn yoda_conditions(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ConstantLikelihood::from_expression(left, checker.settings.preview)
|
if ConstantLikelihood::from(left) <= ConstantLikelihood::from(right) {
|
||||||
<= ConstantLikelihood::from_expression(right, checker.settings.preview)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs
|
||||||
---
|
---
|
||||||
SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead
|
SIM300.py:2:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
1 | # Errors
|
1 | # Errors
|
||||||
2 | "yoda" == compare # SIM300
|
2 | "yoda" == compare # SIM300
|
||||||
|
|
@ -9,7 +9,7 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
||||||
3 | 42 == age # SIM300
|
3 | 42 == age # SIM300
|
||||||
4 | ("a", "b") == compare # SIM300
|
4 | ("a", "b") == compare # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `compare == "yoda"`
|
= help: Rewrite as `compare == "yoda"`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
1 1 | # Errors
|
1 1 | # Errors
|
||||||
|
|
@ -19,7 +19,7 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
||||||
4 4 | ("a", "b") == compare # SIM300
|
4 4 | ("a", "b") == compare # SIM300
|
||||||
5 5 | "yoda" <= compare # SIM300
|
5 5 | "yoda" <= compare # SIM300
|
||||||
|
|
||||||
SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead
|
SIM300.py:3:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
1 | # Errors
|
1 | # Errors
|
||||||
2 | "yoda" == compare # SIM300
|
2 | "yoda" == compare # SIM300
|
||||||
|
|
@ -28,7 +28,7 @@ SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` inste
|
||||||
4 | ("a", "b") == compare # SIM300
|
4 | ("a", "b") == compare # SIM300
|
||||||
5 | "yoda" <= compare # SIM300
|
5 | "yoda" <= compare # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age == 42`
|
= help: Rewrite as `age == 42`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
1 1 | # Errors
|
1 1 | # Errors
|
||||||
|
|
@ -39,7 +39,7 @@ SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` inste
|
||||||
5 5 | "yoda" <= compare # SIM300
|
5 5 | "yoda" <= compare # SIM300
|
||||||
6 6 | "yoda" < compare # SIM300
|
6 6 | "yoda" < compare # SIM300
|
||||||
|
|
||||||
SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead
|
SIM300.py:4:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
2 | "yoda" == compare # SIM300
|
2 | "yoda" == compare # SIM300
|
||||||
3 | 42 == age # SIM300
|
3 | 42 == age # SIM300
|
||||||
|
|
@ -48,7 +48,7 @@ SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a",
|
||||||
5 | "yoda" <= compare # SIM300
|
5 | "yoda" <= compare # SIM300
|
||||||
6 | "yoda" < compare # SIM300
|
6 | "yoda" < compare # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `compare == ("a", "b")`
|
= help: Rewrite as `compare == ("a", "b")`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
1 1 | # Errors
|
1 1 | # Errors
|
||||||
|
|
@ -60,7 +60,7 @@ SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a",
|
||||||
6 6 | "yoda" < compare # SIM300
|
6 6 | "yoda" < compare # SIM300
|
||||||
7 7 | 42 > age # SIM300
|
7 7 | 42 > age # SIM300
|
||||||
|
|
||||||
SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead
|
SIM300.py:5:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
3 | 42 == age # SIM300
|
3 | 42 == age # SIM300
|
||||||
4 | ("a", "b") == compare # SIM300
|
4 | ("a", "b") == compare # SIM300
|
||||||
|
|
@ -69,7 +69,7 @@ SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda
|
||||||
6 | "yoda" < compare # SIM300
|
6 | "yoda" < compare # SIM300
|
||||||
7 | 42 > age # SIM300
|
7 | 42 > age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `compare >= "yoda"`
|
= help: Rewrite as `compare >= "yoda"`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
2 2 | "yoda" == compare # SIM300
|
2 2 | "yoda" == compare # SIM300
|
||||||
|
|
@ -81,7 +81,7 @@ SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda
|
||||||
7 7 | 42 > age # SIM300
|
7 7 | 42 > age # SIM300
|
||||||
8 8 | -42 > age # SIM300
|
8 8 | -42 > age # SIM300
|
||||||
|
|
||||||
SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead
|
SIM300.py:6:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
4 | ("a", "b") == compare # SIM300
|
4 | ("a", "b") == compare # SIM300
|
||||||
5 | "yoda" <= compare # SIM300
|
5 | "yoda" <= compare # SIM300
|
||||||
|
|
@ -90,7 +90,7 @@ SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"
|
||||||
7 | 42 > age # SIM300
|
7 | 42 > age # SIM300
|
||||||
8 | -42 > age # SIM300
|
8 | -42 > age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `compare > "yoda"`
|
= help: Rewrite as `compare > "yoda"`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
3 3 | 42 == age # SIM300
|
3 3 | 42 == age # SIM300
|
||||||
|
|
@ -102,7 +102,7 @@ SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"
|
||||||
8 8 | -42 > age # SIM300
|
8 8 | -42 > age # SIM300
|
||||||
9 9 | +42 > age # SIM300
|
9 9 | +42 > age # SIM300
|
||||||
|
|
||||||
SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead
|
SIM300.py:7:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
5 | "yoda" <= compare # SIM300
|
5 | "yoda" <= compare # SIM300
|
||||||
6 | "yoda" < compare # SIM300
|
6 | "yoda" < compare # SIM300
|
||||||
|
|
@ -111,7 +111,7 @@ SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instea
|
||||||
8 | -42 > age # SIM300
|
8 | -42 > age # SIM300
|
||||||
9 | +42 > age # SIM300
|
9 | +42 > age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age < 42`
|
= help: Rewrite as `age < 42`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
4 4 | ("a", "b") == compare # SIM300
|
4 4 | ("a", "b") == compare # SIM300
|
||||||
|
|
@ -123,7 +123,7 @@ SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instea
|
||||||
9 9 | +42 > age # SIM300
|
9 9 | +42 > age # SIM300
|
||||||
10 10 | YODA == age # SIM300
|
10 10 | YODA == age # SIM300
|
||||||
|
|
||||||
SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead
|
SIM300.py:8:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
6 | "yoda" < compare # SIM300
|
6 | "yoda" < compare # SIM300
|
||||||
7 | 42 > age # SIM300
|
7 | 42 > age # SIM300
|
||||||
|
|
@ -132,7 +132,7 @@ SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` inste
|
||||||
9 | +42 > age # SIM300
|
9 | +42 > age # SIM300
|
||||||
10 | YODA == age # SIM300
|
10 | YODA == age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age < -42`
|
= help: Rewrite as `age < -42`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
5 5 | "yoda" <= compare # SIM300
|
5 5 | "yoda" <= compare # SIM300
|
||||||
|
|
@ -144,7 +144,7 @@ SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` inste
|
||||||
10 10 | YODA == age # SIM300
|
10 10 | YODA == age # SIM300
|
||||||
11 11 | YODA > age # SIM300
|
11 11 | YODA > age # SIM300
|
||||||
|
|
||||||
SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead
|
SIM300.py:9:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
7 | 42 > age # SIM300
|
7 | 42 > age # SIM300
|
||||||
8 | -42 > age # SIM300
|
8 | -42 > age # SIM300
|
||||||
|
|
@ -153,7 +153,7 @@ SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` inste
|
||||||
10 | YODA == age # SIM300
|
10 | YODA == age # SIM300
|
||||||
11 | YODA > age # SIM300
|
11 | YODA > age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age < +42`
|
= help: Rewrite as `age < +42`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
6 6 | "yoda" < compare # SIM300
|
6 6 | "yoda" < compare # SIM300
|
||||||
|
|
@ -165,7 +165,7 @@ SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` inste
|
||||||
11 11 | YODA > age # SIM300
|
11 11 | YODA > age # SIM300
|
||||||
12 12 | YODA >= age # SIM300
|
12 12 | YODA >= age # SIM300
|
||||||
|
|
||||||
SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead
|
SIM300.py:10:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
8 | -42 > age # SIM300
|
8 | -42 > age # SIM300
|
||||||
9 | +42 > age # SIM300
|
9 | +42 > age # SIM300
|
||||||
|
|
@ -174,7 +174,7 @@ SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` in
|
||||||
11 | YODA > age # SIM300
|
11 | YODA > age # SIM300
|
||||||
12 | YODA >= age # SIM300
|
12 | YODA >= age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age == YODA`
|
= help: Rewrite as `age == YODA`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
7 7 | 42 > age # SIM300
|
7 7 | 42 > age # SIM300
|
||||||
|
|
@ -186,7 +186,7 @@ SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` in
|
||||||
12 12 | YODA >= age # SIM300
|
12 12 | YODA >= age # SIM300
|
||||||
13 13 | JediOrder.YODA == age # SIM300
|
13 13 | JediOrder.YODA == age # SIM300
|
||||||
|
|
||||||
SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead
|
SIM300.py:11:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
9 | +42 > age # SIM300
|
9 | +42 > age # SIM300
|
||||||
10 | YODA == age # SIM300
|
10 | YODA == age # SIM300
|
||||||
|
|
@ -195,7 +195,7 @@ SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` ins
|
||||||
12 | YODA >= age # SIM300
|
12 | YODA >= age # SIM300
|
||||||
13 | JediOrder.YODA == age # SIM300
|
13 | JediOrder.YODA == age # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age < YODA`
|
= help: Rewrite as `age < YODA`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
8 8 | -42 > age # SIM300
|
8 8 | -42 > age # SIM300
|
||||||
|
|
@ -207,7 +207,7 @@ SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` ins
|
||||||
13 13 | JediOrder.YODA == age # SIM300
|
13 13 | JediOrder.YODA == age # SIM300
|
||||||
14 14 | 0 < (number - 100) # SIM300
|
14 14 | 0 < (number - 100) # SIM300
|
||||||
|
|
||||||
SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead
|
SIM300.py:12:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
10 | YODA == age # SIM300
|
10 | YODA == age # SIM300
|
||||||
11 | YODA > age # SIM300
|
11 | YODA > age # SIM300
|
||||||
|
|
@ -216,7 +216,7 @@ SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` in
|
||||||
13 | JediOrder.YODA == age # SIM300
|
13 | JediOrder.YODA == age # SIM300
|
||||||
14 | 0 < (number - 100) # SIM300
|
14 | 0 < (number - 100) # SIM300
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age <= YODA`
|
= help: Rewrite as `age <= YODA`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
9 9 | +42 > age # SIM300
|
9 9 | +42 > age # SIM300
|
||||||
|
|
@ -228,7 +228,7 @@ SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` in
|
||||||
14 14 | 0 < (number - 100) # SIM300
|
14 14 | 0 < (number - 100) # SIM300
|
||||||
15 15 | B<A[0][0]or B
|
15 15 | B<A[0][0]or B
|
||||||
|
|
||||||
SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead
|
SIM300.py:13:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
11 | YODA > age # SIM300
|
11 | YODA > age # SIM300
|
||||||
12 | YODA >= age # SIM300
|
12 | YODA >= age # SIM300
|
||||||
|
|
@ -237,7 +237,7 @@ SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrde
|
||||||
14 | 0 < (number - 100) # SIM300
|
14 | 0 < (number - 100) # SIM300
|
||||||
15 | B<A[0][0]or B
|
15 | B<A[0][0]or B
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `age == JediOrder.YODA`
|
= help: Rewrite as `age == JediOrder.YODA`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
10 10 | YODA == age # SIM300
|
10 10 | YODA == age # SIM300
|
||||||
|
|
@ -249,7 +249,7 @@ SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrde
|
||||||
15 15 | B<A[0][0]or B
|
15 15 | B<A[0][0]or B
|
||||||
16 16 | B or(B)<A[0][0]
|
16 16 | B or(B)<A[0][0]
|
||||||
|
|
||||||
SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100) > 0` instead
|
SIM300.py:14:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
12 | YODA >= age # SIM300
|
12 | YODA >= age # SIM300
|
||||||
13 | JediOrder.YODA == age # SIM300
|
13 | JediOrder.YODA == age # SIM300
|
||||||
|
|
@ -258,7 +258,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100)
|
||||||
15 | B<A[0][0]or B
|
15 | B<A[0][0]or B
|
||||||
16 | B or(B)<A[0][0]
|
16 | B or(B)<A[0][0]
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `(number - 100) > 0`
|
= help: Rewrite as `(number - 100) > 0`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
11 11 | YODA > age # SIM300
|
11 11 | YODA > age # SIM300
|
||||||
|
|
@ -270,7 +270,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100)
|
||||||
16 16 | B or(B)<A[0][0]
|
16 16 | B or(B)<A[0][0]
|
||||||
17 17 |
|
17 17 |
|
||||||
|
|
||||||
SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` instead
|
SIM300.py:15:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
13 | JediOrder.YODA == age # SIM300
|
13 | JediOrder.YODA == age # SIM300
|
||||||
14 | 0 < (number - 100) # SIM300
|
14 | 0 < (number - 100) # SIM300
|
||||||
|
|
@ -278,7 +278,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` in
|
||||||
| ^^^^^^^^^ SIM300
|
| ^^^^^^^^^ SIM300
|
||||||
16 | B or(B)<A[0][0]
|
16 | B or(B)<A[0][0]
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `A[0][0] > B`
|
= help: Rewrite as `A[0][0] > B`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
12 12 | YODA >= age # SIM300
|
12 12 | YODA >= age # SIM300
|
||||||
|
|
@ -290,7 +290,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > B` in
|
||||||
17 17 |
|
17 17 |
|
||||||
18 18 | # Errors in preview
|
18 18 | # Errors in preview
|
||||||
|
|
||||||
SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)` instead
|
SIM300.py:16:5: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
14 | 0 < (number - 100) # SIM300
|
14 | 0 < (number - 100) # SIM300
|
||||||
15 | B<A[0][0]or B
|
15 | B<A[0][0]or B
|
||||||
|
|
@ -299,7 +299,7 @@ SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)`
|
||||||
17 |
|
17 |
|
||||||
18 | # Errors in preview
|
18 | # Errors in preview
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `A[0][0] > (B)`
|
= help: Rewrite as `A[0][0] > (B)`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
13 13 | JediOrder.YODA == age # SIM300
|
13 13 | JediOrder.YODA == age # SIM300
|
||||||
|
|
@ -311,44 +311,42 @@ SIM300.py:16:5: SIM300 [*] Yoda conditions are discouraged, use `A[0][0] > (B)`
|
||||||
18 18 | # Errors in preview
|
18 18 | # Errors in preview
|
||||||
19 19 | ['upper'] == UPPER_LIST
|
19 19 | ['upper'] == UPPER_LIST
|
||||||
|
|
||||||
SIM300.py:23:1: SIM300 [*] Yoda conditions are discouraged, use `['upper'] == UPPER_LIST` instead
|
SIM300.py:19:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
22 | # Errors in stable
|
18 | # Errors in preview
|
||||||
23 | UPPER_LIST == ['upper']
|
19 | ['upper'] == UPPER_LIST
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
| ^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||||
24 | DummyHandler.CONFIG == {}
|
20 | {} == DummyHandler.CONFIG
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `['upper'] == UPPER_LIST`
|
= help: Rewrite as `UPPER_LIST == ['upper']`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ 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
|
20 20 | {} == DummyHandler.CONFIG
|
||||||
21 21 |
|
21 21 |
|
||||||
22 22 | # Errors in stable
|
22 22 | # Errors in stable
|
||||||
23 |-UPPER_LIST == ['upper']
|
|
||||||
23 |+['upper'] == UPPER_LIST
|
|
||||||
24 24 | DummyHandler.CONFIG == {}
|
|
||||||
25 25 |
|
|
||||||
26 26 | # OK
|
|
||||||
|
|
||||||
SIM300.py:24:1: SIM300 [*] Yoda conditions are discouraged, use `{} == DummyHandler.CONFIG` instead
|
SIM300.py:20:1: SIM300 [*] Yoda condition detected
|
||||||
|
|
|
|
||||||
22 | # Errors in stable
|
18 | # Errors in preview
|
||||||
23 | UPPER_LIST == ['upper']
|
19 | ['upper'] == UPPER_LIST
|
||||||
24 | DummyHandler.CONFIG == {}
|
20 | {} == DummyHandler.CONFIG
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300
|
||||||
25 |
|
21 |
|
||||||
26 | # OK
|
22 | # Errors in stable
|
||||||
|
|
|
|
||||||
= help: Replace Yoda condition with `{} == DummyHandler.CONFIG`
|
= help: Rewrite as `DummyHandler.CONFIG == {}`
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
|
17 17 |
|
||||||
|
18 18 | # Errors in preview
|
||||||
|
19 19 | ['upper'] == UPPER_LIST
|
||||||
|
20 |-{} == DummyHandler.CONFIG
|
||||||
|
20 |+DummyHandler.CONFIG == {}
|
||||||
21 21 |
|
21 21 |
|
||||||
22 22 | # Errors in stable
|
22 22 | # Errors in stable
|
||||||
23 23 | UPPER_LIST == ['upper']
|
23 23 | UPPER_LIST == ['upper']
|
||||||
24 |-DummyHandler.CONFIG == {}
|
|
||||||
24 |+{} == DummyHandler.CONFIG
|
|
||||||
25 25 |
|
|
||||||
26 26 | # OK
|
|
||||||
27 27 | compare == "yoda"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,354 +0,0 @@
|
||||||
---
|
|
||||||
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