Trailing Space Removal
GitAuto strips trailing whitespace from every line of generated code before committing. The model inconsistently adds trailing spaces, and leaving them in triggers linting warnings and creates unnecessary diff noise in code review.
Why This Exists
Trailing whitespace is invisible but causes real problems. Most linters flag it as a warning or error. Code reviewers see extra changes in diffs that are just whitespace. Pre-commit hooks in many repositories reject commits with trailing spaces. The model adds trailing spaces unpredictably, sometimes on blank lines within code blocks, sometimes at the end of comments. Manually fixing these wastes agent iterations on something that should never be an issue.
Why Models Add Trailing Spaces
Models generate tokens one at a time, and a space token is always a high-probability prediction after most code tokens. Whether a space falls before or after a newline is a subtle distinction that rarely affects correctness, so the model has weak incentive to get it right. Benchmarks strip whitespace before comparison, so trailing spaces are invisible during evaluation. Models receive no training signal to avoid them.
How It Works
Before writing any file to the repository, GitAuto runs a simple pass over every line, stripping any trailing spaces and tabs. This is applied universally to all generated code regardless of language. The operation is fast (single regex per line) and has no risk of changing code behavior since trailing whitespace is never semantically meaningful.
Related Features
- Final Newline - Ensures files end with exactly one newline
- Import Sorting - Another pre-commit formatting correction
Need Help?
Have questions or suggestions? We're here to help you get the most out of GitAuto.
Contact us with your questions or feedback!