Skip to content

Commit b39bd89

Browse files
committed
Add a script to run clang-tidy on specific files
1 parent e5d91e0 commit b39bd89

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

.clang-tidy

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
---
1919
Checks: >
20-
# It follows https://github.com/googleapis/google-cloud-cpp/blob/main/.clang-tidy
20+
# The following checks are based on https://github.com/googleapis/google-cloud-cpp/blob/main/.clang-tidy
2121
-*,
22-
abseil-*,
2322
bugprone-*,
2423
google-*,
2524
misc-*,
@@ -56,16 +55,22 @@ Checks: >
5655
-bugprone-implicit-widening-of-multiplication-result,
5756
-bugprone-unchecked-optional-access,
5857
-bugprone-unused-local-non-trivial-variable,
59-
-bugprone-unused-return-value
58+
-bugprone-unused-return-value,
59+
# Here are new excluded checks that are not in the original file
60+
-bugprone-reserved-identifier,
61+
-google-build-using-namespace,
62+
-modernize-deprecated-headers,
63+
-modernize-use-using,
64+
-readability-enum-initial-value,
6065
WarningsAsErrors: '*'
6166
HeaderFileExtensions:
6267
- ''
6368
- h
6469
ImplementationFileExtensions:
70+
# TODO: the *.c files are not being linted because they use a different style
6571
- cc
6672
HeaderFilterRegex: '.*'
6773
FormatStyle: none
68-
User: xuyunze
6974
CheckOptions:
7075
cert-err33-c.CheckedFunctions: '^::aligned_alloc;^::asctime_s;^::at_quick_exit;^::atexit;^::bsearch;^::bsearch_s;^::btowc;^::c16rtomb;^::c32rtomb;^::calloc;^::clock;^::cnd_broadcast;^::cnd_init;^::cnd_signal;^::cnd_timedwait;^::cnd_wait;^::ctime_s;^::fclose;^::fflush;^::fgetc;^::fgetpos;^::fgets;^::fgetwc;^::fopen;^::fopen_s;^::fprintf;^::fprintf_s;^::fputc;^::fputs;^::fputwc;^::fputws;^::fread;^::freopen;^::freopen_s;^::fscanf;^::fscanf_s;^::fseek;^::fsetpos;^::ftell;^::fwprintf;^::fwprintf_s;^::fwrite;^::fwscanf;^::fwscanf_s;^::getc;^::getchar;^::getenv;^::getenv_s;^::gets_s;^::getwc;^::getwchar;^::gmtime;^::gmtime_s;^::localtime;^::localtime_s;^::malloc;^::mbrtoc16;^::mbrtoc32;^::mbsrtowcs;^::mbsrtowcs_s;^::mbstowcs;^::mbstowcs_s;^::memchr;^::mktime;^::mtx_init;^::mtx_lock;^::mtx_timedlock;^::mtx_trylock;^::mtx_unlock;^::printf_s;^::putc;^::putwc;^::raise;^::realloc;^::remove;^::rename;^::scanf;^::scanf_s;^::setlocale;^::setvbuf;^::signal;^::snprintf;^::snprintf_s;^::sprintf;^::sprintf_s;^::sscanf;^::sscanf_s;^::strchr;^::strerror_s;^::strftime;^::strpbrk;^::strrchr;^::strstr;^::strtod;^::strtof;^::strtoimax;^::strtok;^::strtok_s;^::strtol;^::strtold;^::strtoll;^::strtoul;^::strtoull;^::strtoumax;^::strxfrm;^::swprintf;^::swprintf_s;^::swscanf;^::swscanf_s;^::thrd_create;^::thrd_detach;^::thrd_join;^::thrd_sleep;^::time;^::timespec_get;^::tmpfile;^::tmpfile_s;^::tmpnam;^::tmpnam_s;^::tss_create;^::tss_get;^::tss_set;^::ungetc;^::ungetwc;^::vfprintf;^::vfprintf_s;^::vfscanf;^::vfscanf_s;^::vfwprintf;^::vfwprintf_s;^::vfwscanf;^::vfwscanf_s;^::vprintf_s;^::vscanf;^::vscanf_s;^::vsnprintf;^::vsnprintf_s;^::vsprintf;^::vsprintf_s;^::vsscanf;^::vsscanf_s;^::vswprintf;^::vswprintf_s;^::vswscanf;^::vswscanf_s;^::vwprintf_s;^::vwscanf;^::vwscanf_s;^::wcrtomb;^::wcschr;^::wcsftime;^::wcspbrk;^::wcsrchr;^::wcsrtombs;^::wcsrtombs_s;^::wcsstr;^::wcstod;^::wcstof;^::wcstoimax;^::wcstok;^::wcstok_s;^::wcstol;^::wcstold;^::wcstoll;^::wcstombs;^::wcstombs_s;^::wcstoul;^::wcstoull;^::wcstoumax;^::wcsxfrm;^::wctob;^::wctrans;^::wctype;^::wmemchr;^::wprintf_s;^::wscanf;^::wscanf_s;'
7176
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true'
@@ -77,6 +82,7 @@ CheckOptions:
7782
readability-identifier-naming.ClassCase: 'CamelCase'
7883
readability-identifier-naming.ParameterCase: 'camelBack'
7984
readability-identifier-naming.MethodCase: 'camelBack'
85+
readability-identifier-naming.EnumCase: 'CamelCase'
8086
readability-identifier-naming.FunctionCase: 'camelBack'
8187
readability-identifier-naming.MemberCase: 'camelBack'
8288
readability-identifier-naming.PrivateMemberSuffix: '_'

.github/workflows/ci-pr-validation.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ jobs:
9292

9393
- name: Build core libraries
9494
run: |
95-
cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=OFF
96-
cmake --build . -j8
95+
cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=OFF
96+
cmake --build build -j8
9797
9898
- name: Check formatting
9999
run: |
@@ -105,8 +105,8 @@ jobs:
105105
106106
- name: Build tests
107107
run: |
108-
cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
109-
cmake --build . -j8
108+
cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
109+
cmake --build build -j8
110110
111111
- name: Install gtest-parallel
112112
run: |
@@ -115,24 +115,24 @@ jobs:
115115
- name: Tidy check
116116
run: |
117117
sudo apt-get install -y clang-tidy
118-
run-clang-tidy -p .
118+
./build-support/run_clang_tidy.sh
119119
if [[ $? -ne 0 ]]; then
120120
echo "clang-tidy failed"
121121
exit 1
122122
fi
123123
124124
- name: Run unit tests
125-
run: RETRY_FAILED=3 ./run-unit-tests.sh
125+
run: RETRY_FAILED=3 CMAKE_BUILD_DIRECTORY=./build ./run-unit-tests.sh
126126

127127
- name: Build perf tools
128128
run: |
129-
cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON
130-
cmake --build . -j8
129+
cmake -B build -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DBUILD_PERF_TOOLS=ON
130+
cmake --build build -j8
131131
132132
- name: Verify custom vcpkg installation
133133
run: |
134134
mv vcpkg /tmp/
135-
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg/scripts/buildsystems/vcpkg.cmake"
135+
cmake -B build-2 -DINTEGRATE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE="/tmp/vcpkg/scripts/buildsystems/vcpkg.cmake"
136136
137137
cpp20-build:
138138
name: Build with the C++20 standard

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,6 @@ Testing
106106
.test-token.txt
107107
pkg/mac/.build
108108
pkg/mac/.install
109+
110+
# Used in ./build-support/run_clang_tidy.sh
111+
files.txt

build-support/run_clang_tidy.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
21+
FILES=$(find $PWD/include $PWD/lib $PWD/tests $PWD/examples -name "*.h" -o -name "*.cc" \
22+
| grep -v "lib\/c\/" | grep -v "lib\/checksum\/" | grep -v "lib\/lz4\/" \
23+
| grep -v "include\/pulsar\/c\/" | grep -v "tests\/c\/")
24+
25+
rm -f files.txt
26+
for FILE in $FILES; do
27+
echo $FILE >> files.txt
28+
done
29+
run-clang-tidy -p build -j8 $(cat files.txt)

0 commit comments

Comments
 (0)