diff --git a/README.md b/README.md index a64fe4b..4b79c42 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # forgejo-todo-checker -Checks your source files for TODO and FIXME comments, where they don't have an open issue number. +Checks your source files for TODO and FIXME comments, failing your build where they don't have an open issue number. -A ForgeJo Action. +- [A ForgeJo Action](https://forgejo.org/docs/next/user/actions/). (Inspired by https://woodpecker-ci.org/plugins/TODO-Checker) @@ -32,7 +32,7 @@ jobs: ## Comments Format -This Action only pays attention to comments in a particular format. e.g: +This Action looks for comments in the following formats: ``` // TODO: (#19) This is the comment @@ -61,13 +61,19 @@ The output will be similar to the following if there are any errors: ``` Forgejo TODO Checker! -Repo: kemitix/my-projext + +Repo: kemitix/my-project Prefix: (#|//)\s*(TODO|FIXME) Issues: \(#?(?P\d+)\) + - Issue number missing: src/main.rs#38: // TODO: implement this cool feature and get rich! -- Closed/Invalid Issue: (19) README.md#12: + +>> 1 error in src/main.rs + +- Closed/Invalid Issue: (19) src/model/line.rs#12: // TODO: (#19) This is the comment + >> 1 error in src/model/line.rs Error: Invalid or closed TODO/FIXMEs found diff --git a/src/init.rs b/src/init.rs index 3e7e027..85a1cbb 100644 --- a/src/init.rs +++ b/src/init.rs @@ -21,9 +21,11 @@ pub fn init_config(printer: &impl Printer, net: Network) -> Result { .maybe_auth_token(std::env::var("REPO_TOKEN").ok()) .build(); + printer.println(""); printer.println(format!("Repo: {}", config.repo())); printer.println(format!("Prefix: {}", config.prefix_pattern())); printer.println(format!("Issues: {}", config.issue_pattern())); + printer.println(""); Ok(config) } diff --git a/src/scanner.rs b/src/scanner.rs index 085f53b..44aa1b9 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -81,7 +81,10 @@ impl FileScanner for DefaultFileScanner { _ => {} }); if errors > 0 { - printer.println(format!(">> {errors} errors in {}", file.to_string_lossy())); + printer.println(format!( + ">> {errors} errors in {}\n", + relative_path.to_string_lossy() + )); } Ok(errors) diff --git a/src/tests/scanner.rs b/src/tests/scanner.rs index 1c70974..b73bec2 100644 --- a/src/tests/scanner.rs +++ b/src/tests/scanner.rs @@ -46,7 +46,7 @@ fn find_markers_in_dir() -> anyhow::Result<()> { "- 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() + format!(">> 3 errors in {}\n", file_with_invalids.strip_prefix(fs.base())?.to_string_lossy()).as_str() ] ); assert_eq!(errors, 3);