Add optional pre-commit hook for code formatting #5178
1 issue
find-bugs: Found 1 issue (1 high)
High
`set -e` combined with piped grep causes hook to silently pass on dotnet format errors - `.githooks/pre-commit:8-9`
The script uses set -e but the formatting check uses a pipeline dotnet format ... | grep -q "formatted". If dotnet format fails for any reason (e.g., restore issues, tool not installed, invalid args), grep won't find "formatted" and the if branch is skipped, causing the hook to print '✅ Code formatting looks good!' and exit 0. This means real formatting violations or tool failures can be silently bypassed, defeating the purpose of the pre-commit hook and allowing unformatted code to be committed.
Duration: 26.6s · Tokens: 37.6k in / 1.2k out · Cost: $0.36 (+merge: $0.00)
Annotations
Check failure on line 9 in .githooks/pre-commit
sentry-warden / warden: find-bugs
`set -e` combined with piped grep causes hook to silently pass on dotnet format errors
The script uses `set -e` but the formatting check uses a pipeline `dotnet format ... | grep -q "formatted"`. If `dotnet format` fails for any reason (e.g., restore issues, tool not installed, invalid args), grep won't find "formatted" and the `if` branch is skipped, causing the hook to print '✅ Code formatting looks good!' and exit 0. This means real formatting violations or tool failures can be silently bypassed, defeating the purpose of the pre-commit hook and allowing unformatted code to be committed.