forgejo-todo-checker/README.md

92 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2024-09-17 15:35:36 +01:00
# forgejo-todo-checker
2024-09-22 09:07:16 +01:00
Checks your source files for TODO and FIXME comments, failing your build where they don't have an open issue number.
2024-09-17 15:35:04 +01:00
2024-09-22 09:07:16 +01:00
- [A ForgeJo Action](https://forgejo.org/docs/next/user/actions/).
2024-09-20 17:15:16 +01:00
(Inspired by https://woodpecker-ci.org/plugins/TODO-Checker)
## LATEST version
See [Releases](https://git.kemitix.net/kemitix/forgejo-todo-checker/releases) for the latest version. Replace `${LATEST}` in the examples below with the tag version (include any leading `v`).
## code.forgejo.org Mirror
Main development takes place on [git.kemitix.net](https://git.kemitix.net/kemitix/forgejo-todo-checker).
There is a mirror on code.forgejo.org as [kemitix/todo-checker](https://code.forgejo.org/kemitix/todo-checker).
This mirror allows you to refer to the action as simply `kemitix/todo-checker@${LATEST}`.
## Usage
```yaml
jobs:
tests:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check TODOs
# Original:
# uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@${LATEST}
# Codeberg mirror:
uses: kemitix/todo-checker@${LATEST}
```
2024-09-20 17:15:16 +01:00
## Comments Format
2024-09-22 09:07:16 +01:00
This Action looks for comments in the following formats:
2024-09-20 17:15:16 +01:00
```
// TODO: (#19) This is the comment
// FIXME (#29) This is the other comment
# TODO (#19) This is the comment
# FIXME: (#29) This is the other comment
```
These are all considered valid comments. Pick the format that fits your language or file best.
Comments are found by matching them against this regular expression: `(#|//)\s*(TODO|FIXME):?`
2024-09-20 17:15:16 +01:00
i.e.: be a comment by starting with either '#' or '//', then the word `TODO` or `FIXME` in all caps, with or without a trailing '`:`'.
2024-09-20 17:15:16 +01:00
Once we have a line with such a comment we look for the Issue Number with: `\(#?(?P<ISSUE_NUMBER>\d+)\)`
i.e.: a number in '`()`', with or without a leading '`#`' (inside the braces) immediately after the '`TODO`' or '`FIXME`'.
2024-09-20 17:15:16 +01:00
The `ISSUE_NUMBER` must correspond to an **OPEN** Issue in the repo that the Action is running against.
If the issue has been closed or can't be found then the comment is marked as an error and the Check with fail.
## Example Output
2024-09-20 17:15:16 +01:00
The output will be similar to the following if there are any errors:
```
Forgejo TODO Checker!
2024-09-22 09:07:16 +01:00
Repo : kemitix/my-project
Regex: (#|//)\s*(TODO|FIXME):?\s*\(#?(?P<ISSUE_NUMBER>\d+)\)
2024-09-22 09:07:16 +01:00
- Issue number missing: src/main.rs#38:
2024-09-20 17:15:16 +01:00
// TODO: implement this cool feature and get rich!
2024-09-22 09:07:16 +01:00
>> 1 error in src/main.rs
- Closed/Invalid Issue: (19) src/model/line.rs#12:
2024-09-20 17:15:16 +01:00
// TODO: (#19) This is the comment
2024-09-22 09:07:16 +01:00
>> 1 error in src/model/line.rs
2024-09-20 17:15:16 +01:00
Error: Invalid or closed TODO/FIXMEs found
```
The first error is because there is no issue number associated with the TODO comment.
The second error is because the issue has already been closed.
## License
`forgejo-todo-checker` is released under the MIT License.