Skip to content

Commit

Permalink
Disable google tidy issues (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiavrammsd authored Sep 1, 2024
1 parent dbf188d commit 2207214
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion code-quality.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions tests/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }

Expand Down
7 changes: 4 additions & 3 deletions tests/zip_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 13 additions & 0 deletions tests/zip_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#include <gtest/gtest.h>

#include <array>
#include <cstddef>
#include <iterator>
#include <type_traits>
#include <utility>
#include <vector>

#include "data.hpp"
Expand Down Expand Up @@ -171,9 +174,11 @@ TEST_F(ZipTest, FrontWhenZipIsEmpty)
std::vector<int> 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(), "");
}

Expand All @@ -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(), "");
}

Expand All @@ -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], "");
}

Expand All @@ -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<decltype(a), const int&>);
static_assert(std::is_same_v<decltype(b), data&>);
++iterations;
Expand Down

0 comments on commit 2207214

Please sign in to comment.