From: Joel Rosdahl Date: Wed, 8 Jun 2022 13:54:04 +0000 (+0200) Subject: ci: Bump Clang-Tidy job to Clang-Tidy 12 X-Git-Tag: v4.7~194 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=74d816e0c6add58436a5723c3b295d24c1bf905d;p=thirdparty%2Fccache.git ci: Bump Clang-Tidy job to Clang-Tidy 12 --- diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 82a13618c..fe0e3a39f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -255,12 +255,12 @@ jobs: apt_get: libzstd-dev pkg-config libhiredis-dev asciidoctor - name: Clang-Tidy - os: ubuntu-18.04 - CC: clang-9 - CXX: clang++-9 + os: ubuntu-20.04 + CC: clang-12 + CXX: clang++-12 RUN_TESTS: none - CMAKE_PARAMS: -DENABLE_CLANG_TIDY=ON -DCLANGTIDY=/usr/bin/clang-tidy-9 - apt_get: libzstd-dev pkg-config libhiredis-dev clang-9 clang-tidy-9 + CMAKE_PARAMS: -DENABLE_CLANG_TIDY=ON -DCLANGTIDY=/usr/bin/clang-tidy-12 + apt_get: libzstd-dev pkg-config libhiredis-dev clang-12 clang-tidy-12 steps: - name: Get source diff --git a/src/.clang-tidy b/src/.clang-tidy index 35c8668be..8d4f31b0a 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -13,6 +13,7 @@ Checks: '-*, -readability-implicit-bool-conversion, -readability-magic-numbers, -readability-else-after-return, + -readability-function-cognitive-complexity, -readability-named-parameter, -readability-qualified-auto, -readability-redundant-declaration, diff --git a/src/Hash.cpp b/src/Hash.cpp index ecd19e303..93df21b1e 100644 --- a/src/Hash.cpp +++ b/src/Hash.cpp @@ -67,7 +67,7 @@ Hash::hash_delimiter(std::string_view type) { hash_buffer(HASH_DELIMITER); hash_buffer(type); - hash_buffer(std::string_view("", 1)); // NUL + hash_buffer(std::string_view("\x00", 1)); add_debug_text("### "); add_debug_text(type); add_debug_text("\n"); diff --git a/src/InodeCache.cpp b/src/InodeCache.cpp index 15a339280..9b0562552 100644 --- a/src/InodeCache.cpp +++ b/src/InodeCache.cpp @@ -82,6 +82,8 @@ static_assert( static_cast(InodeCache::ContentType::precompiled_header) == 3, "Numeric value is part of key, increment version number if changed."); +const void* MMAP_FAILED = reinterpret_cast(-1); // NOLINT: Must cast here + } // namespace struct InodeCache::Key @@ -148,7 +150,7 @@ InodeCache::mmap_file(const std::string& inode_cache_file) SharedRegion* sr = reinterpret_cast(mmap( nullptr, sizeof(SharedRegion), PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0)); fd.close(); - if (sr == reinterpret_cast(-1)) { + if (sr == MMAP_FAILED) { LOG("Failed to mmap {}: {}", inode_cache_file, strerror(errno)); return false; } @@ -280,7 +282,7 @@ InodeCache::create_new_file(const std::string& filename) MAP_SHARED, *tmp_file.fd, 0)); - if (sr == reinterpret_cast(-1)) { + if (sr == MMAP_FAILED) { LOG("Failed to mmap new inode cache: {}", strerror(errno)); return false; } diff --git a/src/storage/Storage.cpp b/src/storage/Storage.cpp index d1aa4fb30..3a9ab09f1 100644 --- a/src/storage/Storage.cpp +++ b/src/storage/Storage.cpp @@ -235,7 +235,7 @@ Storage::get(const Digest& key, MTR_SCOPE("storage", "get"); if (mode != Mode::secondary_only) { - const auto path = primary.get(key, type); + auto path = primary.get(key, type); primary.increment_statistic(path ? core::Statistic::primary_storage_hit : core::Statistic::primary_storage_miss); if (path) { diff --git a/unittest/.clang-tidy b/unittest/.clang-tidy index 978237e36..de6a65844 100644 --- a/unittest/.clang-tidy +++ b/unittest/.clang-tidy @@ -2,6 +2,7 @@ Checks: '-*, readability-*, -readability-implicit-bool-conversion, + -readability-function-cognitive-complexity, -readability-magic-numbers, -readability-else-after-return, -readability-named-parameter,