cleanup-whitespace.py
cleanup-whitespace.py is a Python script that cleans up common whitespace inconsistencies in Java files.
What It Does
The script performs the following cleanup operations:
- Removes consecutive blank lines - Maximum of 1 blank line allowed between code sections
- Removes trailing whitespace - Strips whitespace from the end of all lines
- Removes blank lines before final closing brace - Ensures files end cleanly with
} - Ensures proper file endings - Files end with
}with no trailing newline
Usage
Clean the entire Juneau codebase
cd /Users/james.bognar/git/juneau
python3 scripts/cleanup-whitespace.py
Clean a specific directory
python3 scripts/cleanup-whitespace.py juneau-core/juneau-marshall
When to Use
Use this script when:
- Preparing code for commit
- Fixing whitespace inconsistencies
- Ensuring consistent file formatting
Requirements
- Python 3.6 or higher
- No external Python dependencies (uses only standard library)
Notes
- The script only modifies
.javafiles - Files are modified in-place
- Always review changes with
git diffbefore committing
Share feedback or follow-up questions for this page directly through GitHub.