Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop due to rules D207 & W605 #3609

Merged
merged 3 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/ruff/src/autofix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ fn cmp_fix(rule1: Rule, rule2: Rule, fix1: &Fix, fix2: &Fix) -> std::cmp::Orderi
// Apply `EndsInPeriod` fixes before `NewLineAfterLastParagraph` fixes.
(Rule::EndsInPeriod, Rule::NewLineAfterLastParagraph) => std::cmp::Ordering::Less,
(Rule::NewLineAfterLastParagraph, Rule::EndsInPeriod) => std::cmp::Ordering::Greater,
// Apply `UnderIndentation` fixes before `InvalidEscapeSequence` fixes.
(Rule::UnderIndentation, Rule::InvalidEscapeSequence) => std::cmp::Ordering::Less,
(Rule::InvalidEscapeSequence, Rule::UnderIndentation) => std::cmp::Ordering::Greater,
vlindhol marked this conversation as resolved.
Show resolved Hide resolved
_ => std::cmp::Ordering::Equal,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ pub fn invalid_escape_sequence(
Range::new(location, end_location),
);
if autofix {
diagnostic.amend(Fix::insertion(r"\".to_string(), location));
diagnostic.amend(Fix::insertion(
r"\".to_string(),
Location::new(location.row(), location.column() + 1),
vlindhol marked this conversation as resolved.
Show resolved Hide resolved
));
}
diagnostics.push(diagnostic);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ expression: diagnostics
content: "\\"
location:
row: 2
column: 9
column: 10
end_location:
row: 2
column: 9
column: 10
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -37,10 +37,10 @@ expression: diagnostics
content: "\\"
location:
row: 6
column: 0
column: 1
end_location:
row: 6
column: 0
column: 1
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -57,10 +57,10 @@ expression: diagnostics
content: "\\"
location:
row: 11
column: 5
column: 6
end_location:
row: 11
column: 5
column: 6
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -77,9 +77,9 @@ expression: diagnostics
content: "\\"
location:
row: 18
column: 5
column: 6
end_location:
row: 18
column: 5
column: 6
parent: ~

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ expression: diagnostics
content: "\\"
location:
row: 2
column: 9
column: 10
end_location:
row: 2
column: 9
column: 10
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -37,10 +37,10 @@ expression: diagnostics
content: "\\"
location:
row: 6
column: 0
column: 1
end_location:
row: 6
column: 0
column: 1
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -57,10 +57,10 @@ expression: diagnostics
content: "\\"
location:
row: 11
column: 5
column: 6
end_location:
row: 11
column: 5
column: 6
parent: ~
- kind:
name: InvalidEscapeSequence
Expand All @@ -77,9 +77,9 @@ expression: diagnostics
content: "\\"
location:
row: 18
column: 5
column: 6
end_location:
row: 18
column: 5
column: 6
parent: ~