diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-06-13 23:03:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-06-14 05:09:16 +0300 |
commit | c879c26ddcf5bf027d2789b27d2bdc2ea6087aac (patch) | |
tree | ffff815fb910d6182974c1120ad32d9596f6f803 | |
parent | 2980c3ca3737afaf39cc8a8595737f131adacf5d (diff) | |
download | plus-c879c26ddcf5bf027d2789b27d2bdc2ea6087aac.tar.gz plus-c879c26ddcf5bf027d2789b27d2bdc2ea6087aac.tar.bz2 plus-c879c26ddcf5bf027d2789b27d2bdc2ea6087aac.tar.xz plus-c879c26ddcf5bf027d2789b27d2bdc2ea6087aac.zip |
add clang-tidy checks.
-rw-r--r-- | .clang-tidy | 2 | ||||
-rw-r--r-- | .gitlab-ci.yml | 13 | ||||
-rwxr-xr-x | tools/ci/jobs/clang_tidy.sh | 28 | ||||
-rwxr-xr-x | tools/ci/scripts/clang_tidy.sh | 5 |
4 files changed, 46 insertions, 2 deletions
diff --git a/.clang-tidy b/.clang-tidy index 20dc715d2..fe80fa865 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,9 +1,7 @@ --- Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-llvm-header-guard,-cppcoreguidelines-special-member-functions,-readability-avoid-const-params-in-decls,-modernize-use-equals-default,-hicpp-use-override,-hicpp-special-member-functions,-readability-redundant-member-init,-hicpp-use-equals-default,-modernize-use-using,-modernize-use-override,-cert-err58-cpp,-modernize-use-default-member-init,-google-runtime-references,-modernize-pass-by-value,-misc-misplaced-const,-cppcoreguidelines-pro-type-const-cast,-readability-else-after-return,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-modernize-loop-convert,-modernize-use-auto,-readability-simplify-boolean-expr,-readability-inconsistent-declaration-parameter-name,-cert-msc30-c,-cert-msc50-cpp,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-union-access,-llvm-include-order,-google-runtime-int,-cppcoreguidelines-pro-type-member-init,-modernize-use-emplace,-hicpp-member-init,-cert-err34-c,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-no-malloc,-cert-dcl50-cpp,-clang-analyzer-core.CallAndMessage,-misc-macro-parentheses,-cppcoreguidelines-interfaces-global-init,-readability-redundant-string-cstr,-google-default-arguments,-cert-err52-cpp,-cert-env33-c,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-cplusplus.NewDelete,-modernize-raw-string-literal,-clang-analyzer-core.DivideZero,-misc-misplaced-widening-cast,-modernize-return-braced-init-list,-clang-analyzer-core.NullDereference,-google-readability-function-size,-readability-function-size,-clang-analyzer-security.insecureAPI.strcpy,-CWE-119,-performance-type-promotion-in-math-fn,-google-readability-todo,-clang-analyzer-deadcode.DeadStores,-hicpp-function-size,-misc-definitions-in-headers,-misc-incorrect-roundings,-google-runtime-member-string-references,-google-explicit-constructor,-readability-misleading-indentation,-cert-dcl58-cpp,-hicpp-use-equals-delete,-misc-string-literal-with-embedded-nul,-hicpp-explicit-conversions,-modernize-use-equals-delete,-google-readability-braces-around-statements,-readability-braces-around-statements' -WarningsAsErrors: '' HeaderFilterRegex: '*' AnalyzeTemporaryDtors: false -FormatStyle: none CheckOptions: - key: cert-dcl59-cpp.HeaderFileExtensions value: h,hh,hpp,hxx diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f8b51427..573499005 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2811,6 +2811,19 @@ gcc-6_SDL_default_old_sanitize: tags: - docker +clang-tidy: + stage: build + script: + - ./tools/ci/jobs/clang_tidy.sh + <<: *job-push + variables: + PACKAGES: clang clang-tidy + libxml2-dev libcurl4-gnutls-dev libpng-dev + libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev + FLAGS: "-readability-implicit-bool-cast,-clang-analyzer-optin.cplusplus.VirtualCall,-performance-unnecessary-value-param,-misc-unused-parameters,-modernize-use-default,-clang-analyzer-alpha.deadcode.UnreachableCode,-clang-analyzer-alpha.cplusplus.VirtualCall,-clang-analyzer-alpha.unix.Stream,-clang-analyzer-alpha.security.taint.TaintPropagation,-clang-analyzer-alpha.core.CastToStruct,-clang-analyzer-alpha.core.BoolAssignment" + tags: + - docker + gcc-6_openglerrors_i386: stage: build script: diff --git a/tools/ci/jobs/clang_tidy.sh b/tools/ci/jobs/clang_tidy.sh new file mode 100755 index 000000000..593d986f4 --- /dev/null +++ b/tools/ci/jobs/clang_tidy.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +export LOGFILE=tidy.log + +source ./tools/ci/scripts/init.sh + +rm "logs/clang_tidy.txt" + +cd src + +find . -type f -name "*.cpp" -exec ../tools/ci/scripts/clang_tidy.sh "${FLAGS}" "" {} \; >>../logs/clang_tidy.txt +check_error $? +find . -type f -name "*.cc" -exec ../tools/ci/scripts/clang_tidy.sh "${FLAGS}" "-DUNITTESTS -DUNITTESTS_CATCH" {} \; >>../logs/clang_tidy.txt +check_error $? +find . -type f -name "*.h" -exec ../tools/ci/scripts/clang_tidy.sh "${FLAGS}" "" {} \; >>../logs/clang_tidy.txt +check_error $? + +cd .. + +grep "warning:" logs/clang_tidy.txt \ +| grep -v "src/test/doctest.h" \ +| grep -v "src/test/catch.hpp" \ +| grep -v "src/sdl2gfx/" \ +>${ERRFILE} + +run_check_warnings + +echo ok diff --git a/tools/ci/scripts/clang_tidy.sh b/tools/ci/scripts/clang_tidy.sh new file mode 100755 index 000000000..56761379a --- /dev/null +++ b/tools/ci/scripts/clang_tidy.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +dir=`pwd` + +clang-tidy -checks="$1" "$3" -- -std=c++11 -x c++ -DENABLE_LIBXML -DTMWA_SUPPORT -DDEBUGBUILD $2 -I$dir -I/usr/include -I/usr/include/SDL -I/usr/include/libxml2 |