HomeHEPForge

Add CMake options for enabling clang-tidy static analysis checks during build

Description

Add CMake options for enabling clang-tidy static analysis checks during build

Summary:
Add the following CMake options:

  • EVTGEN_RUN_CLANG_TIDY
  • EVTGEN_CLANG_TIDY_FIX
  • EVTGEN_CLANG_TIDY_CHECKS

to control running of clang-tidy static analysis checks during build.

  • The first toggles whether the checks should be run.
  • The second toggles whether auto-fix should be enabled.
  • The third allows customisation of the exact checks to be run.

The checks currently default to a single check:
modernize-use-nullptr
just to test that things are working as expected.

Going forward, we can use the large set of possible checks to gradually improve the code.

Eventually we can establish a set of checks to run in the CI to test new/changed code.

See:
https://clang.llvm.org/extra/clang-tidy/index.html
for general info on clang-tidy, and
https://clang.llvm.org/extra/clang-tidy/checks/list.html
for the list of all currently supported checks.

Test Plan:

  • Enable the EVTGEN_RUN_CLANG_TIDY option when configuring the build and see that the modernize-use-nullptr check runs.
  • Enable additionally the EVTGEN_CLANG_TIDY_FIX option and see that the code is auto-fixed during the checks.
  • Set a variety of values for list of checks and see that the right checks run.

Reviewers: jback, kreps

Reviewed By: jback, kreps

Tags: #evtgen

Differential Revision: https://phab.hepforge.org/D80

Details

Provenance
tlathamAuthored on Apr 7 2022, 2:11 PM
tlathamPushed on May 11 2022, 4:51 PM
Reviewer
jback
Differential Revision
D80: Add CMake options for enabling clang-tidy static analysis checks during build
Parents
rEVTGENcaf006859dad: Update History file to include D81 and D82 changes.
Branches
Unknown
Tags
Unknown