Feature/566 introduce clang tidy setup #834
Draft
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.
This PR introduces a clang-tidy setup for the project.
I know we previously introduced the GCC static analyzer, but was already testing clang-tidy in the background. A key benefit of clang-tidy is its compatibility with both Clang and GCC. Additionally, you do not need to perform a full compilation first, though clang-tidy does require the CMake-generated
compile_commands.jsonfile.I have enabled most check groups but disabled individual checks that currently report issues. I expect we can enable almost all checks over time (if desired), though some will require further discussion.
Potentially Problematic Checks:
extern "C"directives with//NOLINTBEGIN(cppcoreguidelines-*)and//NOLINTEND(cppcoreguidelines-*).readability-identifier-namingflags certain variable names as too short (e.g.,bnd).CI/CD Integration
To run clang-tidy, I added a separate workflow. While it is possible to append a clang-tidy scan to an existing build job, doing so would extend the total execution time. Since clang-tidy only requires a CMake configuration, running it as a parallel job avoids increasing the overall build duration.
For local development, the
ENABLE_CLANG_TIDYbuild option can be used to integrate the scan into the build process. While this is also possible on CI, I believe a single dedicated scan is sufficient.The scan uses the
clang-tidy-sariftool to convert the output into a SARIF report. GitHub supports this format, though I am still confirming exactly how these results integrate into our specific GitHub environment (e.g., the Security tab).Final Notes:
cert-dcl59-cppcheck so that there is are least some findings to report for testing purposes.cargo-bins/cargo-binstallaction is restricted in our organization, soclang-tidy-sarifis currently "installed" viacurl. I have kept the action usage in comments for now. If we agree that clang-tidy is the right path forward and thecurlapproach is acceptable, I will remove the commented-out code.