scripts/check_style.sh: add exclude list support.

This commit is contained in:
Alexander Arlt 2020-12-18 18:47:13 -05:00
parent 158154bac3
commit d0e8ae3aa5

View File

@ -2,13 +2,19 @@
. scripts/report_errors.sh . scripts/report_errors.sh
EXCLUDE_FILES=(
"libsolutil/picosha2.h"
"test/libsolutil/UTF8.cpp"
)
EXCLUDE_FILES_JOINED=$(printf "%s\|" "${EXCLUDE_FILES[@]}")
EXCLUDE_FILES_JOINED=${EXCLUDE_FILES_JOINED%??}
( (
REPO_ROOT="$(dirname "$0")"/.. REPO_ROOT="$(dirname "$0")"/..
cd $REPO_ROOT cd $REPO_ROOT
WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" |
grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE" | grep -v "test/libsolidity/ASTJSON\|test/libsolidity/ASTRecoveryTests\|test/compilationTests/zeppelin/LICENSE\|${EXCLUDE_FILES_JOINED}"
grep -v -E "test/libsolidity/syntaxTests/comments/unicode_direction_override_1.sol"
) )
if [[ "$WHITESPACE" != "" ]] if [[ "$WHITESPACE" != "" ]]
@ -20,11 +26,10 @@ fi
function preparedGrep() function preparedGrep()
{ {
git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "picosha2.h" git grep -nIE "$1" -- '*.h' '*.cpp' | grep -v "${EXCLUDE_FILES_JOINED}"
return $? return $?
} }
FORMATERROR=$( FORMATERROR=$(
( (
preparedGrep "#include \"" | egrep -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters preparedGrep "#include \"" | egrep -v -e "license.h" -e "BuildInfo.h" # Use include with <> characters