Skip to content

Commit 2f72373

Browse files
committed
Add clang-tidy tasks and task descriptions
1 parent 67566f7 commit 2f72373

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

lint-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
clang-format>=19.1.6
2+
clang-tidy>=19.1.0
23
colorama>=0.4.6
34
gersemi>=0.16.2
45
yamllint>=1.35.1

taskfile.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ includes:
66

77
vars:
88
G_BUILD_DIR: "{{.ROOT_DIR}}/build"
9+
G_CMAKE_CACHE: "{{.G_BUILD_DIR}}/CMakeCache.txt"
10+
G_COMPILE_COMMANDS_DB: "{{.G_BUILD_DIR}}/compile_commands.json"
11+
# Project-specific variables
912
G_YSTDLIB_CPP_SRC_DIR: "{{.ROOT_DIR}}/ystdlib"
1013

1114
tasks:
@@ -14,6 +17,17 @@ tasks:
1417
cmds:
1518
- "rm -rf '{{.G_BUILD_DIR}}'"
1619

20+
config-cmake-project:
21+
internal: true
22+
sources:
23+
- "CMakeLists.txt"
24+
- "{{.TASKFILE}}"
25+
generates:
26+
- "{{.G_CMAKE_CACHE}}"
27+
- "{{.G_COMPILE_COMMANDS_DB}}"
28+
cmds:
29+
- "cmake -S '{{.ROOT_DIR}}' -B '{{.G_BUILD_DIR}}'"
30+
1731
init:
1832
internal: true
1933
silent: true

taskfiles/lint-cpp.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ version: "3"
22

33
tasks:
44
cpp-check:
5+
desc: "Runs the C++ linters."
56
cmds:
67
- task: "cpp-format-check"
8+
- task: "cpp-static-check"
79

810
cpp-fix:
11+
desc: "Runs the C++ linters to fix all formatting issues and perform static code analysis. "
912
cmds:
1013
- task: "cpp-format-fix"
14+
- task: "cpp-static-fix"
1115

1216
cpp-format-check:
17+
desc: "Runs the C++ linters that identify formatting issues."
1318
sources: &cpp_format_src_files
1419
- "{{.ROOT_DIR}}/**/*.cpp"
1520
- "{{.ROOT_DIR}}/**/*.h"
@@ -30,6 +35,8 @@ tasks:
3035
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
3136

3237
cpp-format-fix:
38+
desc: "Runs the C++ linters and fixes all formatting issues."
39+
sources: *cpp_format_src_files
3340
dir: "{{.ROOT_DIR}}"
3441
deps:
3542
- "cpp-configs"
@@ -42,6 +49,37 @@ tasks:
4249
ref: ".G_LINT_CPP_DIRS"
4350
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
4451

52+
cpp-static-check:
53+
# Alias task to `cpp-static-fix` since we don't currently support automatic fixes.
54+
# NOTE: clang-tidy does have the ability to fix some errors, but the fixes can be inaccurate.
55+
# When we eventually determine which errors can be safely fixed, we'll allow clang-tidy to
56+
# fix them.
57+
desc: "Runs the C++ static analyzers. Only checks for warnings and violations."
58+
aliases:
59+
- "cpp-static-fix"
60+
sources:
61+
- "{{.G_CMAKE_CACHE}}"
62+
- "{{.G_COMPILE_COMMANDS_DB}}"
63+
- "{{.ROOT_DIR}}/**/*.cpp"
64+
- "{{.ROOT_DIR}}/**/*.h"
65+
- "{{.ROOT_DIR}}/**/*.hpp"
66+
- "{{.ROOT_DIR}}/**/*.inc"
67+
- "{{.ROOT_DIR}}/.clang-tidy"
68+
- "{{.TASKFILE}}"
69+
deps:
70+
- ":config-cmake-project"
71+
- "cpp-configs"
72+
- "venv"
73+
cmds:
74+
- task: ":utils:clang-tidy"
75+
vars:
76+
FLAGS: >-
77+
--config-file "{{.ROOT_DIR}}/.clang-tidy"
78+
-p "{{.G_COMPILE_COMMANDS_DB}}"
79+
SRC_PATHS:
80+
ref: ".G_LINT_CPP_DIRS"
81+
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
82+
4583
cpp-configs:
4684
internal: true
4785
sources:

0 commit comments

Comments
 (0)