From 7e3626c84e0679022bda3c3708299cbcfc9cbdce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 15 Jul 2019 20:58:07 +0200 Subject: [PATCH] Travis: Check the naming conventions again --- .travis.yml | 13 +++++++------ cli/cppcheckexecutor.cpp | 10 +++++----- cli/cppcheckexecutor.h | 2 +- naming.json | 8 ++++++++ 4 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 naming.json diff --git a/.travis.yml b/.travis.yml index 9471dbdf1..cd5c95c12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -220,13 +220,14 @@ script: - make -s -j2 # building gui generates some more files that cppcheck can check, so check the repo *after* building gui - cd ../ -# self check - - ${CPPCHECK} --template=gcc -D__CPPCHECK__ --error-exitcode=1 --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling --inline-suppr --suppressions-list=.travis_suppressions -itest/cli -itest/synthetic -itest/testsuites -iaddons -igui cli lib gui test tools -j 2 +# self check lib/cli + - mkdir b1 + - ${CPPCHECK} -j2 --template=gcc --cppcheck-build-dir=b1 -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=cppcheck-lib --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling cli lib # check gui with qt settings - - ${CPPCHECK} --template=gcc -D__CPPCHECK__ -DQT_VERSION=0x050000 --library=qt --error-exitcode=1 -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --enable=style,performance,portability,warning,internal --exception-handling -j 2 gui/*.cpp --suppressions-list=.travis_suppressions -igui/test -# check naming conventions TODO this is temporarily disabled -# - ${CPPCHECK} -i gui/test -j 2 --dump -q gui lib -# - find lib gui -maxdepth 1 -name "*.dump" | xargs -n 1 -P 4 python addons/naming.py --private-member-variable='m[A-Z].*' + - mkdir b2 + - ${CPPCHECK} -j2 --template=gcc --cppcheck-build-dir=b2 -D__CPPCHECK__ -DQT_VERSION=0x050000 --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=qt --addon=naming.json -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ --enable=style,performance,portability,warning,internal --exception-handling gui/*.cpp +# self check test and tools + - ${CPPCHECK} -j2 --template=gcc -D__CPPCHECK__ --error-exitcode=1 --inline-suppr --suppressions-list=.travis_suppressions --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml/ -Icli --inconclusive --enable=style,performance,portability,warning,internal --exception-handling test/*.cpp tools # Build gui - cd ./gui # clean rebuild diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 57daaafc1..5fccc494f 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -79,7 +79,7 @@ /*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout; CppCheckExecutor::CppCheckExecutor() - : mSettings(nullptr), latestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false) + : mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false) { } @@ -848,7 +848,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha } if (settings.reportProgress) - latestProgressOutputTime = std::time(nullptr); + mLatestProgressOutputTime = std::time(nullptr); if (!settings.outputFile.empty()) { mErrorOutput = new std::ofstream(settings.outputFile); @@ -1016,13 +1016,13 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st { (void)filename; - if (!latestProgressOutputTime) + if (!mLatestProgressOutputTime) return; // Report progress messages every 10 seconds const std::time_t currentTime = std::time(nullptr); - if (currentTime >= (latestProgressOutputTime + 10)) { - latestProgressOutputTime = currentTime; + if (currentTime >= (mLatestProgressOutputTime + 10)) { + mLatestProgressOutputTime = currentTime; // format a progress message std::ostringstream ostr; diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 08d639145..8c1d8cd39 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -175,7 +175,7 @@ private: /** * Report progress time */ - std::time_t latestProgressOutputTime; + std::time_t mLatestProgressOutputTime; /** * Output file name for exception handler diff --git a/naming.json b/naming.json new file mode 100644 index 000000000..ef93af6d0 --- /dev/null +++ b/naming.json @@ -0,0 +1,8 @@ +{ + "script": "addons/naming.py", + "args": [ + "--private-member-variable=m[A-Z].*" + "--var=[a-z].*", + "--function=[a-z].*" + ] +}