-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sure all files get checked and all errors are outputted
- Loading branch information
woutersioen
committed
Apr 28, 2013
1 parent
5b9e9bd
commit e39c153
Showing
2 changed files
with
18 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,27 +10,30 @@ | |
# @version 1.0.0 | ||
# @author Wouter Sioen <[email protected]> | ||
|
||
# create empty errors array | ||
declare -a errors | ||
|
||
# fetch all changed php files and validate them | ||
files=$(git diff-index --name-only HEAD | grep -P '\.php$') | ||
for file in $files; do | ||
|
||
# first check if they are valid php files | ||
output=`php -l $file | grep 'PHP Parse error'` | ||
output=`php -l $file | grep 'Errors parsing'` | ||
|
||
# if it did contain errors, we have output | ||
if [ -n "$output" ]; then | ||
echo "$file contains php syntax errors" | ||
exit 1 | ||
errors=("${errors[@]}" "$output") | ||
fi | ||
|
||
# checks if the phpcs output contains '(0 errors, 0 warnings)' | ||
output=`phpcs -v --standard="$HOME/.phpcs/Fork" --report=full $file | grep '| ERROR |'` | ||
output=`phpcs --standard="$HOME/.phpcs/Fork" --report=full $file | grep '| ERROR |'` | ||
|
||
# if it did contain errors, we have output | ||
if [ -n "$output" ]; then | ||
echo "$file fails coding standards" | ||
echo $output | ||
exit 1 | ||
phpcs --standard="$HOME/.phpcs/Fork" --report=full $file | ||
errors=("${errors[@]}" "$output") | ||
fi | ||
done | ||
|
||
|
@@ -43,6 +46,11 @@ for file in $files; do | |
if [ -n "$output" ]; then | ||
echo "$file contains javascript syntax errors" | ||
echo $output | ||
exit 1 | ||
errors=("${errors[@]}" "$output") | ||
fi | ||
done | ||
done | ||
|
||
# if we have errors, exit with 1 | ||
if [ -n "errors" ]; then | ||
exit 1 | ||
fi |