Skip to content

Commit

Permalink
Remove unused case
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Apr 1, 2024
1 parent 8e8c181 commit 2a6b782
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions crates/ruff_linter/src/fix/edits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub(crate) fn delete_comment(range: TextRange, locator: &Locator) -> Edit {
}
// Ex) `x = 1 # noqa`
else if range.end() + trailing_space_len == line_range.end() {
// Replace `x = 1 # noqa` with `x = 1`.
Edit::deletion(range.start() - leading_space_len, line_range.end())
}
// Ex) `x = 1 # noqa # type: ignore`
Expand All @@ -93,21 +94,16 @@ pub(crate) fn delete_comment(range: TextRange, locator: &Locator) -> Edit {
))
.starts_with('#')
{
// Replace `# noqa # type: ignore` with `# type: ignore`.
Edit::deletion(range.start(), range.end() + trailing_space_len)
}
// Ex) `x = 1 # noqa here`
else {
if suffix.is_empty() {
// if there's no comment after the deleted noqa, delete the entire range
let full_line_end = locator.full_line_end(line_range.end());
Edit::deletion(line_range.start() - leading_space_len, full_line_end)
} else {
// if there is something after the deleted noqa, keep it in a comment
Edit::range_replacement(
"# ".to_string(),
TextRange::new(range.start(), range.end() + trailing_space_len),
)
}
// Replace `# noqa here` with `# here`.
Edit::range_replacement(
"# ".to_string(),
TextRange::new(range.start(), range.end() + trailing_space_len),
)
}
}

Expand Down

0 comments on commit 2a6b782

Please sign in to comment.