From 22072147bec7ce496e8c9c3496021394871f9342 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Sun, 1 Sep 2024 16:37:20 +0300 Subject: [PATCH] Disable google tidy issues (#6) --- .clang-tidy | 3 +++ README.md | 3 +++ code-quality.sh | 3 ++- tests/data.hpp | 8 ++++---- tests/zip_benchmark.cpp | 7 ++++--- tests/zip_test.cpp | 13 +++++++++++++ 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d8aaf10..ba58f9c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -13,6 +13,9 @@ Checks: > -fuchsia-default-arguments-calls, -cppcoreguidelines-avoid-magic-numbers, -readability-magic-numbers, + -fuchsia-statically-constructed-objects, + -cert-err58-cpp, + -cppcoreguidelines-owning-memory, WarningsAsErrors: "*" diff --git a/README.md b/README.md index 0f83a2a..28e03a4 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,9 @@ See [tests](tests/). * constexpr * const correctness * Write benchmarks +* Ignore google headers from clang-tidy + * Remove from clangtidy: -fuchsia-statically-constructed-objects, -cert-err58-cpp, -cppcoreguidelines-owning-memory, + * Remove other exceptions from tests * ContainersAndAlgorithms test fails at `EXPECT_EQ(it, std::prev(const_zip.end()));` for std::list * Can the zip iterator really be bidirectional? * Document or conditionaly set the iterator tag by the containers types diff --git a/code-quality.sh b/code-quality.sh index efc6204..a4df7dd 100755 --- a/code-quality.sh +++ b/code-quality.sh @@ -32,7 +32,8 @@ cmake ${workspace} \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_BUILD_TYPE=${build_type} \ - -DENABLE_TESTS=ON + -DENABLE_TESTS=ON \ + -DENABLE_BENCHMARKS=ON cmake --build . --config ${build_type} --target ${build_target} cd ${cwd} diff --git a/tests/data.hpp b/tests/data.hpp index af1c57f..d42297a 100644 --- a/tests/data.hpp +++ b/tests/data.hpp @@ -3,10 +3,10 @@ class data { public: - inline static int constructs_ = 0; - inline static int copies_ = 0; - inline static int moves_ = 0; - int num = 0; + inline static int constructs_ = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + inline static int copies_ = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + inline static int moves_ = 0; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + int num = 0; // NOLINT(misc-non-private-member-variables-in-classes) explicit data(int n) : num{n} { ++constructs_; } diff --git a/tests/zip_benchmark.cpp b/tests/zip_benchmark.cpp index 940a83f..9a2e4da 100644 --- a/tests/zip_benchmark.cpp +++ b/tests/zip_benchmark.cpp @@ -6,8 +6,9 @@ Results on release build... */ -static void BM_Zip(benchmark::State& state) { (void)state; } +static void BM_Zip(benchmark::State&) {} // NOLINT(google-runtime-references) -BENCHMARK(BM_Zip); +BENCHMARK(BM_Zip); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -BENCHMARK_MAIN(); +// NOLINTNEXTLINE(modernize-avoid-c-arrays,hicpp-no-array-decay,cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-avoid-c-arrays) +BENCHMARK_MAIN(); // NOLINT(cppcoreguidelines-avoid-c-arrays) diff --git a/tests/zip_test.cpp b/tests/zip_test.cpp index b39178f..8c07347 100644 --- a/tests/zip_test.cpp +++ b/tests/zip_test.cpp @@ -3,7 +3,10 @@ #include #include +#include #include +#include +#include #include #include "data.hpp" @@ -171,9 +174,11 @@ TEST_F(ZipTest, FrontWhenZipIsEmpty) std::vector empty{}; msd::zip zip(non_empty, empty); + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(zip.front(), ""); const msd::zip const_zip = zip; + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(const_zip.front(), ""); } @@ -199,7 +204,10 @@ TEST_F(ZipTest, BackWhenZipIsEmpty) msd::zip zip(non_empty, empty); const msd::zip const_zip(non_empty, empty); + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(zip.back(), ""); + + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(const_zip.back(), ""); } @@ -220,7 +228,10 @@ TEST_F(ZipTest, OperatorSubscript) TEST_F(ZipTest, OperatorSubscriptWithIndexOutOfRange) { + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(zip_[99], ""); + + // NOLINTNEXTLINE(hicpp-vararg,cppcoreguidelines-avoid-goto,cppcoreguidelines-pro-type-vararg,hicpp-avoid-goto) EXPECT_DEBUG_DEATH(const_zip_[99], ""); } @@ -236,6 +247,8 @@ TEST_F(ZipTest, NoCopiesAndMovesOfContainersWhileIterating) std::size_t iterations = 0; for (auto [a, b] : msd::zip(vector_four_, items)) { + std::ignore = a; + std::ignore = b; static_assert(std::is_same_v); static_assert(std::is_same_v); ++iterations;