diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index d3bf374e04..f3a0b57a1a 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -48,11 +48,14 @@ # test the specified files/directories for standards conformance. # #------------------------------------------------------------------------------ + hookName="pre-commit" +headerSeparator="-----------------------------------" + die() { echo "$hookName hook failure" 1>&2 - echo '-----------------------------------' 1>&2 + echo $headerSeparator 1>&2 echo '' 1>&2 echo "$@" 1>&2 echo '' 1>&2 @@ -105,7 +108,7 @@ dieOnBadFiles() if [ -n "$badFiles" ] then echo "$hookName hook failure" 1>&2 - echo '-----------------------------------' 1>&2 + echo $headerSeparator 1>&2 echo "$@" 1>&2 echo '' 1>&2 echo "File(s):" 1>&2 @@ -267,6 +270,49 @@ checkLineLengthNonDirective() } +# +# check for non-standard code patterns +# +checkNonStandardCodePatterns() +{ + echo "$hookName: checking for non-standard code ..." 1>&2 + + scope=$(gitScope $@) + + badFiles=$( + for f in $fileList + do + # limit to *.[CH] files + case "$f" in + (*.[CH]) + # Directly report the incorrect markers + git grep -n --color \ + -e '> >' -e 'NULL' \ + $scope"$f" + ;; + esac + done + ) + + dieOnBadFiles "$(cat< > + + which instead should be: + + List> + + 2. The use of the 'NULL' macro should be replaced by 'nullptr' + +$headerSeparator +MESSAGE + )" +} + + # # check that OpenFOAM Foundation copyright is current # @@ -322,6 +368,9 @@ checkIllegalCode # ensure code conforms to 80 columns max checkLineLengthNonDirective +# check for non-standard code patterns +checkNonStandardCodePatterns + checkCopyright exit 0