From 5546c31f07ba809ea3f7301d336dc93594035e5f Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 1 Aug 2023 14:26:31 -0400 Subject: [PATCH] Use ClangTidy from Noa Signed-off-by: Juan Cruz Viotti --- .clang-tidy | 44 ---------------------------------------- .github/workflows/ci.yml | 13 ------------ CMakeLists.txt | 5 +++-- GNUmakefile | 4 ++++ Makefile | 3 +++ cmake/clang-tidy.cmake | 12 ----------- test/.clang-tidy | 2 -- 7 files changed, 10 insertions(+), 73 deletions(-) delete mode 100644 .clang-tidy delete mode 100644 cmake/clang-tidy.cmake delete mode 100644 test/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 972548b8..00000000 --- a/.clang-tidy +++ /dev/null @@ -1,44 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,clang-analyzer-*,modernize-*,concurrency-*,cppcoreguidelines-*,performance-*,portability-*,readability-*' -WarningsAsErrors: '*' -HeaderFilterRegex: '' -FormatStyle: none -CheckOptions: - - key: readability-function-cognitive-complexity.Threshold - value: 100 - - key: llvm-else-after-return.WarnOnConditionVariables - value: 'false' - - key: modernize-loop-convert.MinConfidence - value: reasonable - - key: modernize-replace-auto-ptr.IncludeStyle - value: llvm - - key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons - value: 'false' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField - value: 'false' - - key: modernize-pass-by-value.IncludeStyle - value: llvm - - key: cert-dcl16-c.NewSuffixes - value: 'L;LL;LU;LLU' - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic - value: 'true' - - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors - value: 'true' - - key: modernize-use-nullptr.NullMacros - value: 'NULL' - - key: llvm-qualified-auto.AddConstToQualified - value: 'false' - - key: modernize-loop-convert.NamingStyle - value: CamelCase - - key: llvm-else-after-return.WarnOnUnfixable - value: 'false' - - key: google-readability-function-size.StatementThreshold - value: '800' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f73c224b..91466a4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,19 +7,6 @@ on: - 'www/**' jobs: - # Only run clang-tidy on GNU/Linux as a separate jobs - # given how expensive clang-tidy this, even more on - # other platforms. - # clang-tidy: - # runs-on: ubuntu-20.04 - # if: github.ref != 'refs/heads/main' - # steps: - # - uses: actions/checkout@v2 - # - run: sudo apt-get install --yes clang-tidy - # - run: cmake --version - # - run: cmake --preset release --log-context - # - run: cmake --build --preset release --target clang_tidy - test: strategy: fail-fast: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d0df406..5262077b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,11 +71,12 @@ endif() if(PROJECT_IS_TOP_LEVEL) file(GLOB_RECURSE JSONBINPACK_CXX_SOURCE_FILES src/*.cc src/*.h test/*.cc test/*.h) file(GLOB_RECURSE JSONBINPACK_SH_SOURCE_FILES test/*.sh scripts/*.sh) + noa_target_clang_format(SOURCES ${JSONBINPACK_CXX_SOURCE_FILES}) + noa_target_clang_tidy(SOURCES ${JSONBINPACK_CXX_SOURCE_FILES}) + string(TOLOWER ${CMAKE_BUILD_TYPE} JSONBINPACK_BUILD_TYPE) set(JSONBINPACK_WEBSITE_OUT ${PROJECT_SOURCE_DIR}/build/${JSONBINPACK_BUILD_TYPE}/www) set(JSONBINPACK_WEBSITE_SRC ${PROJECT_SOURCE_DIR}/www) - noa_target_clang_format(SOURCES ${JSONBINPACK_CXX_SOURCE_FILES}) - include(${PROJECT_SOURCE_DIR}/cmake/clang-tidy.cmake) include(${PROJECT_SOURCE_DIR}/cmake/bundler.cmake) include(${PROJECT_SOURCE_DIR}/cmake/jekyll.cmake) include(${PROJECT_SOURCE_DIR}/cmake/doxygen.cmake) diff --git a/GNUmakefile b/GNUmakefile index e8b77cc6..cc15c9bb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -41,6 +41,10 @@ debug: exit 1 endif +.PHONY: clean +lint: + $(CMAKE) --build --preset $(PRESET) --target clang_tidy + .PHONY: clean clean: $(CMAKE) -E rm -R -f build .bundle .sass-cache diff --git a/Makefile b/Makefile index f9eb10a5..0a398ecc 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ test: .always $(CMAKE) --build --preset $(PRESET) --parallel $(CTEST) --preset $(PRESET) --verbose --parallel +lint: .always + $(CMAKE) --build --preset $(PRESET) --target clang_tidy + clean: .always $(CMAKE) -E rm -R -f build diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake deleted file mode 100644 index 26a5ba6e..00000000 --- a/cmake/clang-tidy.cmake +++ /dev/null @@ -1,12 +0,0 @@ -find_program(CLANG_TIDY_BIN NAMES clang-tidy) -if(CLANG_TIDY_BIN) - add_custom_target(clang_tidy - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - VERBATIM - COMMAND "${CLANG_TIDY_BIN}" "-p=${CMAKE_BINARY_DIR}" - ${JSONBINPACK_CXX_SOURCE_FILES}) - set_target_properties(clang_tidy - PROPERTIES FOLDER "Linters") -else() - message(WARNING "Could not find `clang-tidy` in the system") -endif() diff --git a/test/.clang-tidy b/test/.clang-tidy deleted file mode 100644 index d71f7071..00000000 --- a/test/.clang-tidy +++ /dev/null @@ -1,2 +0,0 @@ ---- -Checks: '-cppcoreguidelines-owning-memory,-cppcoreguidelines-avoid-goto'