Skip to content

Commit

Permalink
Merge pull request #7510 from rolandwalker/more_whitespace_lint
Browse files Browse the repository at this point in the history
devscript: detect more whitespace irregularities
  • Loading branch information
rolandwalker committed Nov 22, 2014
2 parents fae1c96 + e0a3f8d commit 1e5b0c4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions developer/bin/irregular_cask_whitespace
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,29 @@ _irregular_cask_whitespace () {
cd "$directory" || die "Could not cd to '$directory'"

printf "# No trailing newline at EOF\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{[^\n]\z}s' -- ./*.rb
perl -C32 -0777 -ne 'print " $ARGV\n" if m{[^\n]\z}s' -- ./*.rb

printf "\n# Extra trailing newline at EOF\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n{2}\z}s' -- ./*.rb
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n{2}\z}s' -- ./*.rb

printf "\n# Final 'end' indented\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{ end\s+\z}s' -- ./*.rb
perl -C32 -0777 -ne 'print " $ARGV\n" if m{ end\s+\z}s' -- ./*.rb

printf "\n# Extra newline before final end\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n\nend\s+\z}s' -- ./*.rb

printf "\n# Extra newline before header\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n\ncask\s+:v\d\S*\s+=>}s' -- ./*.rb

printf "\n# Extra newline after header\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{(?:\A|\n)cask\s+:v\d\S*\s+=>[^\n]+\n\n\s*(\S+)}s and $1 ne "if"' -- ./*.rb

printf "\n# No empty line before uninstall\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n[^\n]+\n +uninstall }s' -- ./*.rb

# todo?
# printf "\n# No empty line before caveats\n"
# perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n[^\n]+\n +caveats }s' -- ./*.rb

printf "\n# Extra interior newlines\n"
perl -C32 -0777 -ne 'print " $ARGV\n" if m{\n{3,}}s' -- ./*.rb
Expand Down

0 comments on commit 1e5b0c4

Please sign in to comment.