Skip to content

Commit

Permalink
Implement reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed May 25, 2023
1 parent 5d86c44 commit d2329bb
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions crates/ruff/src/rules/flake8_todos/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,26 +421,19 @@ fn static_errors(
TextSize::new(0)
};

let post_author = &post_tag[usize::from(author_end)..].to_owned();
let mut post_author_chars = post_author.trim_start().chars().peekable();

let Some(char) = post_author_chars.next() else {
// TD-004
diagnostics.push(Diagnostic::new(MissingTodoColon, tag.range));
// TD-005
diagnostics.push(Diagnostic::new(MissingTodoDescription, tag.range));
return;
};

if char == ':' {
match post_author_chars.peek() {
Some(' ') => (),
// TD-007
Some(_) => diagnostics.push(Diagnostic::new(MissingSpaceAfterTodoColon, tag.range)),
None => diagnostics.push(Diagnostic::new(MissingTodoDescription, tag.range)),
let after_author = &post_tag[usize::from(author_end)..];
if let Some(after_colon) = after_author.strip_prefix(':') {
if after_colon.is_empty() {
diagnostics.push(Diagnostic::new(MissingTodoDescription, tag.range));
} else if !after_colon.starts_with(char::is_whitespace) {
diagnostics.push(Diagnostic::new(MissingSpaceAfterTodoColon, tag.range));
}
} else {
diagnostics.push(Diagnostic::new(MissingTodoColon, tag.range));

if after_author.is_empty() {
diagnostics.push(Diagnostic::new(MissingTodoDescription, tag.range));
}
}
}

Expand Down

0 comments on commit d2329bb

Please sign in to comment.