Skip to content

Commit

Permalink
Merge pull request #125 from joto/modernize-clang-tidy
Browse files Browse the repository at this point in the history
Modernize clang tidy
  • Loading branch information
joto authored Jan 3, 2025
2 parents 3b30856 + 3497cb5 commit bf3b7e7
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
11 changes: 8 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
---
Checks: '*,-altera-*,-bugprone-easily-swappable-parameters,-bugprone-signed-char-misuse,-cert-dcl21-cpp,-cert-err58-cpp,-cert-err60-cpp,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-reinterpret-cast,-fuchsia-*,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-no-array-decay,-hicpp-vararg,-llvmlibc-*,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-implicit-bool-conversion,-readability-magic-numbers'
Checks: '*,-altera-*,-boost-use-ranges,-bugprone-chained-comparison,-bugprone-easily-swappable-parameters,-bugprone-signed-char-misuse,-cert-dcl21-cpp,-cert-err58-cpp,-cert-err60-cpp,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-macro-usage,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-type-reinterpret-cast,-fuchsia-*,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-no-array-decay,-hicpp-vararg,-llvmlibc-*,-misc-no-recursion,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-function-cognitive-complexity,-readability-identifier-length,-readability-implicit-bool-conversion,-readability-magic-numbers'
#
# Disabled checks:
#
# altera-*
# Doesn't apply.
#
# boost-use-ranges
# Would introduce extra dependency on boost.
#
# bugprone-chained-comparison
# These are generated by our test framework.
#
# bugprone-easily-swappable-parameters
# Can't change this any more, because these functions are part of our public
# interface.
Expand Down Expand Up @@ -75,7 +81,6 @@ Checks: '*,-altera-*,-bugprone-easily-swappable-parameters,-bugprone-signed-char
# readability-implicit-bool-conversion
# Not necessarily more readable.
#
WarningsAsErrors: '*'
#WarningsAsErrors: '*'
HeaderFilterRegex: '\/include\/'
AnalyzeTemporaryDtors: false
...
53 changes: 53 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: clang-tidy

#on: workflow_dispatch
on: [ push, pull_request ]

jobs:
clang-tidy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image: ["debian:bookworm", "debian:testing", "debian:experimental"]
include:
- image: "debian:bookworm"
clang: 15
- image: "debian:testing"
clang: 19
- image: "debian:experimental"
clang: 20
container:
image: ${{ matrix.image }}
env:
BUILD_TYPE: Debug
CC: clang-${{ matrix.clang }}
CXX: clang++-${{ matrix.clang }}
CXXFLAGS: -Wno-c++20-extensions
CPP_VERSION: 14
APT_LISTCHANGES_FRONTEND: none
DEBIAN_FRONTEND: noninteractive
steps:
- name: Prepare container (apt)
run: |
apt-get update -qq
apt-get install -yq \
clang-${{ matrix.clang }} \
clang-tidy-${{ matrix.clang }} \
cmake \
libprotobuf-dev \
make \
protobuf-compiler
shell: bash
- uses: actions/checkout@v4
- uses: ./.github/actions/cmake
- name: Run clang-tidy
run: make clang-tidy | tee protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}.log
shell: bash
working-directory: build
- name: Upload clang-tidy log
uses: actions/upload-artifact@v4
if: always()
with:
name: protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}-log
path: build/protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}.log
14 changes: 7 additions & 7 deletions test/include/test.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef TEST_HPP
#define TEST_HPP

#include <catch.hpp>
#include <catch.hpp> // IWYU pragma: export

#include <array>
#include <vector>
#include <array> // IWYU pragma: export
#include <vector> // IWYU pragma: export

#include <stdexcept>
// Define protozero_assert() to throw this error. This allows the tests to
Expand All @@ -15,10 +15,10 @@ struct assert_error : public std::runtime_error {
};
#define protozero_assert(x) if (!(x)) { throw assert_error{#x}; } // NOLINT(readability-simplify-boolean-expr)

#include <protozero/pbf_builder.hpp>
#include <protozero/pbf_message.hpp>
#include <protozero/pbf_reader.hpp>
#include <protozero/pbf_writer.hpp>
#include <protozero/pbf_builder.hpp> // IWYU pragma: export
#include <protozero/pbf_message.hpp> // IWYU pragma: export
#include <protozero/pbf_reader.hpp> // IWYU pragma: export
#include <protozero/pbf_writer.hpp> // IWYU pragma: export

extern std::string load_data(const std::string& filename);

Expand Down

0 comments on commit bf3b7e7

Please sign in to comment.