-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid TODOs in the codebase #1921
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ repos: | |
exclude_types: [svg] | ||
exclude: patches/.*\.patch | ||
- id: fix-byte-order-marker | ||
- id: forbid-submodules | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Found this one while looking for a pre-commit hook; seemed worth having |
||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
# Trailing whitespace breaks yaml files if you use a multiline string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# Fail if there are any TODOs in the codebase | ||
|
||
# Find the string 'TODO' in all files tracked by git, excluding | ||
# this file | ||
TODOS_FOUND=$(git grep --color=always -nw TODO -- ':!scripts/forbid-todo.sh' || true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decided to just grep all files rather than try to find lint rules for different languages, to make sure we cover everything |
||
|
||
if [ -n "$TODOS_FOUND" ]; then | ||
printf "\e[1;31mERROR: \e[0mTODOs found in codebase:\n" | ||
printf '%s\n' "$TODOS_FOUND" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added to test workflow rather than pre-commit because if someone has our pre-commit hooks installed locally, we don't want to forbid them from commiting a TODO; we just want to ensure it doesn't get merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could still commit skipping the pre-commit hook? i.e.
git commit --no-verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but I feel that fundamentally it's not a pre-commit requirement. It's a pre-merge requirement. Committing unfinished stuff is totally fine 🤷♂️