Skip to content

Commit bf3b7e7

Browse files
authored
Merge pull request #125 from joto/modernize-clang-tidy
Modernize clang tidy
2 parents 3b30856 + 3497cb5 commit bf3b7e7

File tree

3 files changed

+68
-10
lines changed

3 files changed

+68
-10
lines changed

.clang-tidy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
---
2-
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'
2+
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'
33
#
44
# Disabled checks:
55
#
66
# altera-*
77
# Doesn't apply.
88
#
9+
# boost-use-ranges
10+
# Would introduce extra dependency on boost.
11+
#
12+
# bugprone-chained-comparison
13+
# These are generated by our test framework.
14+
#
915
# bugprone-easily-swappable-parameters
1016
# Can't change this any more, because these functions are part of our public
1117
# interface.
@@ -75,7 +81,6 @@ Checks: '*,-altera-*,-bugprone-easily-swappable-parameters,-bugprone-signed-char
7581
# readability-implicit-bool-conversion
7682
# Not necessarily more readable.
7783
#
78-
WarningsAsErrors: '*'
84+
#WarningsAsErrors: '*'
7985
HeaderFilterRegex: '\/include\/'
80-
AnalyzeTemporaryDtors: false
8186
...

.github/workflows/clang-tidy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: clang-tidy
2+
3+
#on: workflow_dispatch
4+
on: [ push, pull_request ]
5+
6+
jobs:
7+
clang-tidy:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
image: ["debian:bookworm", "debian:testing", "debian:experimental"]
13+
include:
14+
- image: "debian:bookworm"
15+
clang: 15
16+
- image: "debian:testing"
17+
clang: 19
18+
- image: "debian:experimental"
19+
clang: 20
20+
container:
21+
image: ${{ matrix.image }}
22+
env:
23+
BUILD_TYPE: Debug
24+
CC: clang-${{ matrix.clang }}
25+
CXX: clang++-${{ matrix.clang }}
26+
CXXFLAGS: -Wno-c++20-extensions
27+
CPP_VERSION: 14
28+
APT_LISTCHANGES_FRONTEND: none
29+
DEBIAN_FRONTEND: noninteractive
30+
steps:
31+
- name: Prepare container (apt)
32+
run: |
33+
apt-get update -qq
34+
apt-get install -yq \
35+
clang-${{ matrix.clang }} \
36+
clang-tidy-${{ matrix.clang }} \
37+
cmake \
38+
libprotobuf-dev \
39+
make \
40+
protobuf-compiler
41+
shell: bash
42+
- uses: actions/checkout@v4
43+
- uses: ./.github/actions/cmake
44+
- name: Run clang-tidy
45+
run: make clang-tidy | tee protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}.log
46+
shell: bash
47+
working-directory: build
48+
- name: Upload clang-tidy log
49+
uses: actions/upload-artifact@v4
50+
if: always()
51+
with:
52+
name: protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}-log
53+
path: build/protozero-${{ github.sha }}-clang-tidy-${{ matrix.clang }}.log

test/include/test.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef TEST_HPP
22
#define TEST_HPP
33

4-
#include <catch.hpp>
4+
#include <catch.hpp> // IWYU pragma: export
55

6-
#include <array>
7-
#include <vector>
6+
#include <array> // IWYU pragma: export
7+
#include <vector> // IWYU pragma: export
88

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

18-
#include <protozero/pbf_builder.hpp>
19-
#include <protozero/pbf_message.hpp>
20-
#include <protozero/pbf_reader.hpp>
21-
#include <protozero/pbf_writer.hpp>
18+
#include <protozero/pbf_builder.hpp> // IWYU pragma: export
19+
#include <protozero/pbf_message.hpp> // IWYU pragma: export
20+
#include <protozero/pbf_reader.hpp> // IWYU pragma: export
21+
#include <protozero/pbf_writer.hpp> // IWYU pragma: export
2222

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

0 commit comments

Comments
 (0)