Created
October 8, 2019 17:10
-
-
Save jaytaylor/9d0846167376027ca0c6e0a2d0cf61b6 to your computer and use it in GitHub Desktop.
Perl-based Java codebase aesthetics format scrubber.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o pipefail | |
set -o nounset | |
for f in $(find . -name '*.java'); do | |
perl \ | |
-0 \ | |
-i \ | |
-pe 's/((\) \{|try \{|class .* \{)\n|\n\n)\n+/\1/g;' \ | |
-pe 's/(import +[^;]*;)\n\n+(import [^;]*;\n)\n*/\1\n\2/g;' \ | |
-pe 's/(import +static [^;]*;)\n(import ([^s]|s[^t]|st[^a]|sta[^t]|stat[^i]|stati[^c]|static[^ ])[^;]*;)/\1\n\n\2/g;' \ | |
-pe 's/(import ([^s]|s[^t]|st[^a]|sta[^t]|stat[^i]|stati[^c]|static[^ ])[^;]*;)\n(import +static [^;]*;)/\1\n\n\3/g;' \ | |
"${f}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
n.b. see also https://github.com/jaytaylor/google-java-format/releases, specifically https://github.com/jaytaylor/google-java-format/releases/download/1.8.1/google-java-format-1.8.1-all-deps.jar.