From bcd331dcb74b121cdd0b1018783861ef5b4f9fae Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Wed, 26 Jun 2024 22:40:05 +0200 Subject: [PATCH 1/2] add clang-tidy checks --- .github/workflows/keyvi.yml | 2 +- CMakeLists.txt | 9 +++++++++ keyvi/.clang-tidy | 18 ++++++++++++++++++ keyvi/tests/.clang-tidy | 9 +++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 keyvi/.clang-tidy create mode 100644 keyvi/tests/.clang-tidy diff --git a/.github/workflows/keyvi.yml b/.github/workflows/keyvi.yml index 2024dd91a..945dc2016 100644 --- a/.github/workflows/keyvi.yml +++ b/.github/workflows/keyvi.yml @@ -26,7 +26,7 @@ jobs: if: runner.os == 'Linux' run: | sudo apt-get update - sudo apt-get install -y libsnappy-dev libzzip-dev zlib1g-dev libboost-all-dev + sudo apt-get install -y libsnappy-dev libzzip-dev zlib1g-dev libboost-all-dev clang-tidy - name: install macOS deps if: runner.os == 'macOS' run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 8076362d7..43faca2c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,15 @@ if (CMAKE_BUILD_TYPE) string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER) endif() +#### Linting +find_program(CLANGTIDY clang-tidy) +if(CLANGTIDY) + message ("-- Found clang-tidy") + set(CMAKE_CXX_CLANG_TIDY clang-tidy; --extra-arg-before=-std=c++17) +else() + message(SEND_ERROR "-- clang-tidy not found") +endif() + #### Cmake modules set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") diff --git a/keyvi/.clang-tidy b/keyvi/.clang-tidy new file mode 100644 index 000000000..994895618 --- /dev/null +++ b/keyvi/.clang-tidy @@ -0,0 +1,18 @@ +--- +Checks: "*, + -abseil-*, + -altera-*, + -android-*, + -fuchsia-*, + -google-*, + -llvm*, + -modernize-use-trailing-return-type, + -zircon-*, + -readability-else-after-return, + -readability-static-accessed-through-instance, + -readability-avoid-const-params-in-decls, + -cppcoreguidelines-non-private-member-variables-in-classes, + -misc-non-private-member-variables-in-classes, +" +HeaderFilterRegex: '' +FormatStyle: none diff --git a/keyvi/tests/.clang-tidy b/keyvi/tests/.clang-tidy new file mode 100644 index 000000000..2978af83b --- /dev/null +++ b/keyvi/tests/.clang-tidy @@ -0,0 +1,9 @@ +--- +# be less strict for tests +InheritParentConfig: true +Checks: "-cppcoreguidelines-avoid-magic-numbers, + -readability-function-cognitive-complexity, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-magic-numbers, +" \ No newline at end of file From 1abd180e5ccdbb460d8a68b1837df5d53df343f2 Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Wed, 26 Jun 2024 22:48:06 +0200 Subject: [PATCH 2/2] make it optional --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43faca2c8..cc00d911b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ if(CLANGTIDY) message ("-- Found clang-tidy") set(CMAKE_CXX_CLANG_TIDY clang-tidy; --extra-arg-before=-std=c++17) else() - message(SEND_ERROR "-- clang-tidy not found") + message ("-- clang-tidy not found") endif() #### Cmake modules