Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Dec 2, 2024
1 parent 89e66fe commit 2d959f2
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ruff_macros::{derive_message_formats, ViolationMetadata};
use ruff_python_index::Indexer;
use ruff_python_trivia::CommentRanges;
use ruff_source_file::LineRanges;
use ruff_text_size::{Ranged, TextRange};
use ruff_text_size::TextRange;

use crate::Locator;

Expand Down Expand Up @@ -77,27 +77,18 @@ pub(crate) fn unnecessary_coding_comment(
[Some(CodingComment::UTF8(ranges))]
| [Some(CodingComment::UTF8(ranges)), None]
| [None, Some(CodingComment::UTF8(ranges))] => {
report(diagnostics, &ranges.line_range, &ranges.self_range);
report(diagnostics, ranges.line_range, ranges.self_range);
}

[Some(CodingComment::UTF8(ranges_1)), Some(CodingComment::UTF8(ranges_2))] => {
report(diagnostics, &ranges_1.line_range, &ranges_1.self_range);
report(diagnostics, &ranges_2.line_range, &ranges_2.self_range);
report(diagnostics, ranges_1.line_range, ranges_1.self_range);
report(diagnostics, ranges_2.line_range, ranges_2.self_range);
}

_ => {}
}
}

fn report(diagnostics: &mut Vec<Diagnostic>, line_range: &TextRange, comment_range: &TextRange) {
let edit = Edit::deletion(line_range.start(), line_range.end());
let fix = Fix::safe_edit(edit);

let diagnostic = Diagnostic::new(UTF8EncodingDeclaration, *comment_range);

diagnostics.push(diagnostic.with_fix(fix));
}

fn coding_comment(
locator: &Locator,
indexer: &Indexer,
Expand Down Expand Up @@ -149,3 +140,12 @@ fn coding_comment(
_ => Some(CodingComment::Other),
}
}

fn report(diagnostics: &mut Vec<Diagnostic>, line_range: TextRange, comment_range: TextRange) {
let edit = Edit::deletion(line_range.start(), line_range.end());
let fix = Fix::safe_edit(edit);

let diagnostic = Diagnostic::new(UTF8EncodingDeclaration, comment_range);

diagnostics.push(diagnostic.with_fix(fix));
}

0 comments on commit 2d959f2

Please sign in to comment.