Use expression span for yoda-conditions fixes (#3276)
This commit is contained in:
@@ -11,6 +11,7 @@ YODA > age # SIM300
|
||||
YODA >= age # SIM300
|
||||
JediOrder.YODA == age # SIM300
|
||||
0 < (number - 100) # SIM300
|
||||
SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300
|
||||
|
||||
# OK
|
||||
compare == "yoda"
|
||||
|
||||
@@ -160,8 +160,8 @@ pub fn yoda_conditions(
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
diagnostic.amend(Fix::replacement(
|
||||
suggestion,
|
||||
left.location,
|
||||
right.end_location.unwrap(),
|
||||
expr.location,
|
||||
expr.end_location.unwrap(),
|
||||
));
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
||||
@@ -216,6 +216,24 @@ expression: diagnostics
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 17
|
||||
column: 18
|
||||
parent: ~
|
||||
- kind:
|
||||
YodaConditions:
|
||||
suggestion: (60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE
|
||||
location:
|
||||
row: 14
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 52
|
||||
fix:
|
||||
content: (60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE
|
||||
location:
|
||||
row: 14
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 52
|
||||
parent: ~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user