Skip to content

Add optional pre-commit hook for code formatting verification

419f26e
Select commit
Loading
Failed to load commit list.
Open

Add optional pre-commit hook for code formatting #5178

Add optional pre-commit hook for code formatting verification
419f26e
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed May 1, 2026 in 29s

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

See this annotation in the file changed.

@sentry-warden 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.