feat: Improve error messageso
All checks were successful
Test / test (push) Successful in 9s

Closes kemitix/forgejo-todo-checker#6
This commit is contained in:
Paul Campbell 2024-09-21 19:15:18 +01:00
parent 9b2da13ed4
commit 7e82cf2946
3 changed files with 7 additions and 7 deletions

View file

@ -51,9 +51,9 @@ Forgejo TODO Checker!
Repo: kemitix/my-projext
Prefix: (#|//)\s*(TODO|FIXME)
Issues: ( |)(\(|\(#)(?P<ISSUE_NUMBER>\d+)(\))
- Invalid: src/main.rs#38:
- Issue number missing: src/main.rs#38:
// TODO: implement this cool feature and get rich!
- Closed : (19) README.md#12:
- Closed/Invalid Issue: (19) README.md#12:
// TODO: (#19) This is the comment
Error: Invalid or closed TODO/FIXMEs found

View file

@ -21,8 +21,8 @@ impl Marker {
impl std::fmt::Display for Marker {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Invalid(line) => write!(f, "- Invalid: {}", line),
Self::Closed(line, issue) => write!(f, "- Closed : ({issue}) {line}"),
Self::Invalid(line) => write!(f, "- Issue number missing: {}", line),
Self::Closed(line, issue) => write!(f, "- Closed/Invalid Issue: ({issue}) {line}"),
Self::Valid(_, _) | Self::Unmarked => Ok(()), // tarpaulin uncovered okay
}
}

View file

@ -43,9 +43,9 @@ fn find_markers_in_dir() -> anyhow::Result<()> {
assert_eq!(
printer.messages.take(),
vec![
"- Invalid: file_with_invalids.txt#3:\n It contains a todo comment: // TODO: this is it\n",
"- Invalid: file_with_invalids.txt#5:\n It also contains a fix-me comment: // FIXME: and this is it\n",
"- Closed : (3) file_with_invalids.txt#9:\n We also have a todo comment: // TODO: (#3) and it has an issue number, but it is closed\n",
"- Issue number missing: file_with_invalids.txt#3:\n It contains a todo comment: // TODO: this is it\n",
"- Issue number missing: file_with_invalids.txt#5:\n It also contains a fix-me comment: // FIXME: and this is it\n",
"- Closed/Invalid Issue: (3) file_with_invalids.txt#9:\n We also have a todo comment: // TODO: (#3) and it has an issue number, but it is closed\n",
format!(">> 3 errors in {}", file_with_invalids.to_string_lossy()).as_str()
]
);