Skip to content

Commit

Permalink
Clear clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Apr 9, 2023
1 parent ea63dc8 commit 73d4c59
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/ruff/src/rules/flake8_todo/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ pub fn check_rules(tokens: &[LexResult]) -> Vec<Diagnostic> {
};

if get_captured_matches(comment).peek().is_some() {
diagnostics.extend(get_tag_regex_errors(comment, start, end));
diagnostics.extend(get_tag_regex_errors(comment, *start, *end));
}
}

diagnostics
}

fn get_captured_matches(text: &String) -> Peekable<CaptureMatches> {
fn get_captured_matches(text: &str) -> Peekable<CaptureMatches> {
TODO_REGEX.captures_iter(text).peekable()
}

fn get_tag_regex_errors(text: &String, start: &Location, end: &Location) -> Vec<Diagnostic> {
fn get_tag_regex_errors(text: &str, start: Location, end: Location) -> Vec<Diagnostic> {
let mut diagnostics: Vec<Diagnostic> = vec![];

for capture in TODO_REGEX.captures_iter(text) {
Expand All @@ -134,7 +134,7 @@ fn get_tag_regex_errors(text: &String, start: &Location, end: &Location) -> Vec<
InvalidTODOTag {
tag: String::from(tag),
},
Range::new(*start, *end),
Range::new(start, end),
));

// TODO: T006 check can go here
Expand All @@ -143,9 +143,9 @@ fn get_tag_regex_errors(text: &String, start: &Location, end: &Location) -> Vec<
// Note: This initially looks bad from a speed perspective, but is O(1) given that we
// know that there will only ever be 1 `capture` (due to regex anchors) and constant
// capture groups.
for capture_group_index in 2..NUM_CAPTURE_GROUPS + 1 {
for capture_group_index in 2..=NUM_CAPTURE_GROUPS {
if capture.get(capture_group_index).is_none() {
let range = Range::new(*start, *end);
let range = Range::new(start, end);
diagnostics.push(match capture_group_index {
2usize => Diagnostic::new(TODOMissingAuthor, range),
3usize => Diagnostic::new(TODOMissingColon, range),
Expand Down

0 comments on commit 73d4c59

Please sign in to comment.