When I program, I usually jot down TODO comments to remember things I want to try out or fix before finishing a feature. However, I sometimes forget about them, especially in larger projects or when working on features that take some time. Today’s quick tip helped me remember to address the TODO comments in my code before merging a feature branch.
I usually create a ticker in GitHub’s issue tracker for everything that’s not immediate or relevant to the feature I’m working on. That way, I know that there’s still something I want to do but haven’t done when there are TODO comments in my code, and I would like to prevent myself from accidentally merging unfinished code.
Creating a Workflow on GitHub Actions
On the actions tab, use the button to create a new action. Give it a meaningful name (e.g., check-for-todos.yml). This creates a new file in the “.github/workflows” folder or your project root and opens the file in a text editor. Add this to the file:
name: Check for TODO and FIXME Comments
on:
push:
pull_request:
branches: [ "dev", "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Perform Check
uses: actions/checkout@v4
- run: |
if grep --exclude="*.md" --exclude-dir={.git,.github,.mvn,.idea,doc,resources} -rE "TODO|FIXME"; then
exit 204
else
echo "All good"
fi
The job runs on any push or pull request event on the branches “main” and “dev” (i.e., not on the feature branches themselves). It uses Ubuntu and runs a simple grep command to check whether any project files (excluding markdown and the given folders) contain a TODO or FIXME string. If the script finds such a file, it exits with a status code of 204 and prints a list of affected files:
Figure 1: This example illustrates how the pipeline fails when TODO comments are present in the code.
This approach is quite versatile, and I also use it to enforce various other constraints one might forget about. Another example is the use of BigDecimal conversions. In this project, we have a dedicated helper for that which applies some additional rules, so developers must only use that one and not Java’s BigDecimal.valueOf() function:
name: No BigDecimal Conversions Outside of Helper
on:
push:
pull_request:
branches: [ "dev", "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Perform Check
uses: actions/checkout@v4
- run: |
if grep --exclude="Arithmetics.java" --exclude-dir={.git,.github,target} -rE "BigDecimal.valueOf"; then
exit 205
else
echo "All good"
fi
Obviously, this job excludes the helper class (Arithmetics.java) itself.
Adding a Status Badge to the ReadMe File
Finally, as with all other GitHub CI workflows, you can add a status badge to your project’s ReadMe file (or embed it on your website, etc.) to proudly show off that your code conforms to the project guidelines. Just add this line for every badge you want to add:

Just make sure to replace REPO_OWNER with the repository owner, REPO_NAME with the repository name, ACTION_NAME with the previously created YAML file’s name, and ALT_TEXT with a short description.