-
Notifications
You must be signed in to change notification settings - Fork 7
chore: Add Taskfile tasks to lint C++ files. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbb762c
Add clang-format cpp lint
Bill-hbrhbr 67566f7
Merge branch 'main' into add-cpp-lint
Bill-hbrhbr 2f72373
Add clang-tidy tasks and task descriptions
Bill-hbrhbr 21c967e
Add a dummy cpp source file for tasks to succeed
Bill-hbrhbr c5548bf
Complete CMakeLists.txt
Bill-hbrhbr 631eece
Add compile commands
Bill-hbrhbr b21289d
Remove unnecessary dir attributes for tasks that call utility tasks f…
Bill-hbrhbr 2924dc3
Add venv checksum to tasks with sources
Bill-hbrhbr 50e9a3d
Apply suggestions from code review
Bill-hbrhbr 795cfef
Add one more level to src folder
Bill-hbrhbr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| clang-format>=19.1.6 | ||
| clang-tidy>=19.1.0 | ||
| colorama>=0.4.6 | ||
| gersemi>=0.16.2 | ||
| yamllint>=1.35.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| version: "3" | ||
|
|
||
| tasks: | ||
| cpp-check: | ||
| desc: "Runs the C++ linters." | ||
| cmds: | ||
| - task: "cpp-format-check" | ||
| - task: "cpp-static-check" | ||
|
|
||
| cpp-fix: | ||
| desc: "Runs the C++ linters to fix all formatting issues and perform static code analysis. " | ||
| cmds: | ||
| - task: "cpp-format-fix" | ||
| - task: "cpp-static-fix" | ||
|
|
||
| cpp-format-check: | ||
| desc: "Runs the C++ linters that identify formatting issues." | ||
| sources: &cpp_format_src_files | ||
| - "{{.ROOT_DIR}}/**/*.cpp" | ||
| - "{{.ROOT_DIR}}/**/*.h" | ||
| - "{{.ROOT_DIR}}/**/*.hpp" | ||
| - "{{.ROOT_DIR}}/**/*.inc" | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - "{{.ROOT_DIR}}/.clang-format" | ||
| - "{{.TASKFILE}}" | ||
| dir: "{{.ROOT_DIR}}" | ||
| deps: | ||
| - "cpp-configs" | ||
| - "venv" | ||
| cmds: | ||
| - task: ":utils:clang-format" | ||
| vars: | ||
| FLAGS: "--dry-run" | ||
| SRC_PATHS: | ||
| ref: ".G_LINT_CPP_DIRS" | ||
| VENV_DIR: "{{.G_LINT_VENV_DIR}}" | ||
|
|
||
| cpp-format-fix: | ||
| desc: "Runs the C++ linters and fixes all formatting issues." | ||
| sources: *cpp_format_src_files | ||
| dir: "{{.ROOT_DIR}}" | ||
| deps: | ||
| - "cpp-configs" | ||
| - "venv" | ||
| cmds: | ||
| - task: ":utils:clang-format" | ||
| vars: | ||
| FLAGS: "-i" | ||
| SRC_PATHS: | ||
| ref: ".G_LINT_CPP_DIRS" | ||
| VENV_DIR: "{{.G_LINT_VENV_DIR}}" | ||
|
|
||
| cpp-static-check: | ||
| # Alias task to `cpp-static-fix` since we don't currently support automatic fixes. | ||
| # NOTE: clang-tidy does have the ability to fix some errors, but the fixes can be inaccurate. | ||
| # When we eventually determine which errors can be safely fixed, we'll allow clang-tidy to | ||
| # fix them. | ||
| desc: "Runs the C++ static analyzers. Only checks for warnings and violations." | ||
| aliases: | ||
| - "cpp-static-fix" | ||
| sources: | ||
| - "{{.G_CMAKE_CACHE}}" | ||
| - "{{.G_COMPILE_COMMANDS_DB}}" | ||
| - "{{.ROOT_DIR}}/**/*.cpp" | ||
| - "{{.ROOT_DIR}}/**/*.h" | ||
| - "{{.ROOT_DIR}}/**/*.hpp" | ||
| - "{{.ROOT_DIR}}/**/*.inc" | ||
Bill-hbrhbr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - "{{.ROOT_DIR}}/.clang-tidy" | ||
| - "{{.TASKFILE}}" | ||
| deps: | ||
| - ":config-cmake-project" | ||
| - "cpp-configs" | ||
| - "venv" | ||
| cmds: | ||
| - task: ":utils:clang-tidy" | ||
| vars: | ||
| FLAGS: >- | ||
| --config-file "{{.ROOT_DIR}}/.clang-tidy" | ||
| -p "{{.G_COMPILE_COMMANDS_DB}}" | ||
| SRC_PATHS: | ||
| ref: ".G_LINT_CPP_DIRS" | ||
| VENV_DIR: "{{.G_LINT_VENV_DIR}}" | ||
|
|
||
| cpp-configs: | ||
| internal: true | ||
| sources: | ||
| - "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/.clang-format" | ||
| - "{{.ROOT_DIR}}/tools/yscope-dev-utils/lint-configs/.clang-tidy" | ||
| - "{{.TASKFILE}}" | ||
| generates: | ||
| - "{{.ROOT_DIR}}/.clang-format" | ||
| - "{{.ROOT_DIR}}/.clang-tidy" | ||
| dir: "{{.ROOT_DIR}}" | ||
| cmds: | ||
| - "tools/yscope-dev-utils/lint-configs/symlink-cpp-lint-configs.sh" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
Bill-hbrhbr marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #include <iostream> | ||
|
|
||
| [[nodiscard]] auto main() -> int { | ||
| std::cout << "Hello, world!" << '\n'; | ||
| return 0; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.