From 68a91b73da09f17b0bc8064ef5260f169e6afc2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 18 Jun 2018 09:55:43 +0200 Subject: [PATCH] Travis: Enforce naming convention, private variable names must start with 'm[A-Z]' --- .travis.yml | 3 +++ addons/naming.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5a0fd789..f002fa7d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,6 +73,9 @@ script: # check gui with qt settings - ${CPPCHECK} --library=qt --error-exitcode=1 -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling -j 2 gui --suppressions-list=.travis_suppressions -igui/test |& tee --append /tmp/cppcheck.cppcheck - sh -c "! grep '^\[' /tmp/cppcheck.cppcheck" +# check naming conventions + - ${CPPCHECK} --dump -q lib + - python addons/naming.py --private-member-variable='m[A-Z].*' lib/*.cpp.dump # run extra tests - tools/generate_and_run_more_tests.sh # Validate XML diff --git a/addons/naming.py b/addons/naming.py index 6b841bae9..512a492ce 100755 --- a/addons/naming.py +++ b/addons/naming.py @@ -23,7 +23,11 @@ for arg in sys.argv[1:]: RE_FUNCTIONNAME = arg[11:] +FoundError = False + def reportError(token, severity, msg): + global FoundError + FoundError = True sys.stderr.write( '[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') naming.py: ' + msg + '\n') @@ -56,3 +60,8 @@ for arg in sys.argv[1:]: if not res: reportError( scope.bodyStart, 'style', 'Function ' + scope.className + ' violates naming convention') + +if FoundError: + print('FoundError') + sys.exit(1) +