Skip to content

Commit a695b89

Browse files
committed
Improve clang-tidy
1 parent 53a5238 commit a695b89

2 files changed

Lines changed: 73 additions & 53 deletions

File tree

.clang-tidy

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
1-
Checks: >
2-
clang-analyzer-*,
3-
bugprone-*,
4-
performance-*,
5-
readability-*,
6-
modernize-*,
7-
cppcoreguidelines-*,
8-
misc-*,
9-
-modernize-use-trailing-return-type,
10-
-modernize-use-auto,
11-
-modernize-use-using,
12-
-modernize-use-nodiscard,
13-
-cppcoreguidelines-macro-usage,
14-
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
15-
-cppcoreguidelines-pro-type-union-access,
16-
-readability-function-cognitive-complexity,
17-
-llvmlibc-restrict-system-libc-headers,
18-
-llvmlibc-implementation-in-namespace,
19-
-altera-unroll-loops,
20-
-misc-definitions-in-headers,
21-
-readability-identifier-naming,
22-
-readability-identifier-length
1+
Checks:
2+
- '*'
3+
4+
FormatStyle: 'file'
235

24-
WarningsAsErrors: ''
25-
HeaderFilterRegex: '.*\.(cpp|h)$'
26-
FormatStyle: file
27-
AnalyzeTemporaryDtors: true
286
CheckOptions:
29-
- key: modernize-loop-convert.MaxCopySize
30-
value: '16'
31-
- key: readability-identifier-naming.VariableCase
32-
value: camelBack
33-
- key: readability-identifier-naming.ClassCase
34-
value: CamelCase
35-
- key: readability-identifier-naming.FunctionCase
36-
value: camelBack
37-
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreEnums
38-
value: '1'
39-
- key: cppcoreguidelines-avoid-magic-numbers.IgnoreOctalLiterals
40-
value: '1'
7+
- key: 'bugprone-argument-comment.CommentBoolLiterals'
8+
value: '0'
9+
- key: 'bugprone-assert-side-effect.AssertMacros'
10+
value: 'assert'
11+
- key: 'bugprone-dangling-handle.HandleClasses'
12+
value: 'std::basic_string_view;std::experimental::basic_string_view'
13+
- key: 'bugprone-dynamic-static-initializers.HeaderFileExtensions'
14+
value: ',h,hh,hpp,hxx'
15+
- key: 'bugprone-suspicious-string-compare.WarnOnImplicitComparison'
16+
value: '1'
17+
- key: 'cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors'
18+
value: '1'
19+
- key: 'cppcoreguidelines-no-malloc.Allocations'
20+
value: '::malloc;::calloc'
21+
- key: 'google-readability-function-size.StatementThreshold'
22+
value: '800'
23+
- key: 'readability-identifier-naming.FunctionCase'
24+
value: 'lower_case'
25+
- key: 'readability-static-accessed-through-instance.NameSpecifierNestingThreshold'
26+
value: '3'
Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Static code analysis (clang-tidy)
1+
name: Static code analysis (clang-tidy)
22

33
on:
44
push:
@@ -12,26 +12,39 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414

15-
- name: Install dependencies
15+
# Cache Vulkan SDK
16+
- name: Cache Vulkan SDK
17+
id: cache-vulkan
18+
uses: actions/cache@v4
19+
with:
20+
path: vulkan_sdk
21+
key: vulkan-sdk-1.4.309.0
22+
23+
# Install system dependencies
24+
- name: Install system dependencies
1625
run: |
1726
sudo apt update
18-
sudo apt install -y clang-15 clang-tidy-15 cmake ninja-build libc++-15-dev libc++abi-15-dev
19-
20-
- name: Set clang-tidy version
21-
run: echo "CLANG_TIDY=clang-tidy-15" >> $GITHUB_ENV
27+
sudo apt install -y clang-15 clang-tidy-15 cmake parallel libc++-15-dev libc++abi-15-dev
2228
23-
- name: Prepare Vulkan SDK
29+
# Download Vulkan SDK only if not cached
30+
- name: Download Vulkan SDK
31+
if: steps.cache-vulkan.outputs.cache-hit != 'true'
2432
run: |
2533
curl -LS -o vulkansdk.tar.xz https://sdk.lunarg.com/sdk/download/1.4.309.0/linux/vulkansdk-linux-x86_64-1.4.309.0.tar.xz
2634
mkdir -p vulkan_sdk
2735
tar xf vulkansdk.tar.xz -C vulkan_sdk
28-
export VULKAN_SDK=$GITHUB_WORKSPACE/vulkan_sdk/1.4.309.0/x86_64
29-
echo "VULKAN_SDK=$VULKAN_SDK" >> $GITHUB_ENV
30-
echo "PATH=$VULKAN_SDK/bin:$PATH" >> $GITHUB_ENV
31-
echo "LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
32-
echo "VK_ICD_FILENAMES=$VULKAN_SDK/etc/vulkan/icd.d" >> $GITHUB_ENV
33-
echo "VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/layer.d" >> $GITHUB_ENV
3436
37+
# Set environment variables for Clang and Vulkan SDK
38+
- name: Set environment variables
39+
run: |
40+
echo "CLANG_TIDY=clang-tidy-15" >> $GITHUB_ENV
41+
echo "VULKAN_SDK=${GITHUB_WORKSPACE}/vulkan_sdk/1.4.309.0/x86_64" >> $GITHUB_ENV
42+
echo "PATH=${GITHUB_WORKSPACE}/vulkan_sdk/1.4.309.0/x86_64/bin:$PATH" >> $GITHUB_ENV
43+
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/vulkan_sdk/1.4.309.0/x86_64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
44+
echo "VK_ICD_FILENAMES=${GITHUB_WORKSPACE}/vulkan_sdk/1.4.309.0/x86_64/etc/vulkan/icd.d" >> $GITHUB_ENV
45+
echo "VK_LAYER_PATH=${GITHUB_WORKSPACE}/vulkan_sdk/1.4.309.0/x86_64/etc/vulkan/layer.d" >> $GITHUB_ENV
46+
47+
# Configure the project with CMake
3548
- name: Configure with CMake
3649
run: |
3750
cmake -S . -B build \
@@ -40,6 +53,27 @@ jobs:
4053
-DCMAKE_C_COMPILER=clang-15 \
4154
-DVMA_BUILD_SAMPLES=YES
4255
43-
- name: Run Clang-Tidy
56+
# List files to analyze
57+
- name: Check the files found for clang-tidy
58+
run: |
59+
find src include \
60+
-path '*/_deps/*' -prune -o \
61+
-path '*/build/*' -prune -o \
62+
\( -name '*.cpp' -o -name '*.hpp' \) -print
63+
64+
# Run clang-tidy in parallel
65+
- name: Run clang-tidy
66+
run: |
67+
find src include \
68+
-path '*/_deps/*' -prune -o \
69+
-path '*/build/*' -prune -o \
70+
\( -name '*.cpp' -o -name '*.hpp' \) -print0 |
71+
parallel -0 clang-tidy -p build {} |
72+
tee output || true
73+
74+
# Summarize warnings
75+
- name: Summarize clang-tidy warnings
4476
run: |
45-
find . -path ./build -prune -o \( -name '*.cpp' -o -name '*.h' \) -print | xargs clang-tidy-15 -p build || true
77+
grep -hEo '\[[a-z0-9]+-[a-z0-9-]+\]' output \
78+
| sort | uniq -c | sort -nr \
79+
| sed 's/[][]//g' || true

0 commit comments

Comments
 (0)