Skip to main content

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:

  1. Removes consecutive blank lines - Maximum of 1 blank line allowed between code sections
  2. Removes trailing whitespace - Strips whitespace from the end of all lines
  3. Removes blank lines before final closing brace - Ensures files end cleanly with }
  4. 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 .java files
  • Files are modified in-place
  • Always review changes with git diff before committing
Discussion

Share feedback or follow-up questions for this page directly through GitHub.