Skip to content

Commit

Permalink
ci: Add clang-tidy check for C-style casts (acts-project#3149)
Browse files Browse the repository at this point in the history
Adds a new clang-tidy check. Necessary changes and more details in the PR below.
blocked by:
- acts-project#3146

## Sample
```
╭─ /builds/acts/ci-bridge/src/Tests/UnitTests/Core/Vertexing/SingleSeedVertexF─╮
│ 🟡                                                                           │
│ /builds/acts/ci-bridge/src/Tests/UnitTests/Core/Vertexing/SingleSeedVertexFi │
│ nderTests.cpp:47:10 WARNING [google-readability-casting]                     │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ C-style casts are discouraged; use static_cast                           │ │
│ │    47 |   return (int)(gen() / 4294967296. * (to - from) + from);        │ │
│ │       |          ^~~~~                                                   │ │
│ │       |          static_cast<int>                                        │ │
│ │                                                                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ ──────────────────────────────────────────────────────────────────────────── │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ /builds/acts/ci-bridge/src/Tests/UnitTests/Core/Material/MaterialCompositio─╮
│ 🟡                                                                           │
│ /builds/acts/ci-bridge/src/Tests/UnitTests/Core/Material/MaterialComposition │
│ Tests.cpp:28:26 WARNING [google-readability-casting]                         │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ C-style casts are discouraged; use static_cast                           │ │
│ │    28 |   float carbonFraction = float(carbonWeight) / 255u;             │ │
│ │       |                          ^~~~~                                   │ │
│ │       |                          static_cast<float>                      │ │
│ │                                                                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│ ──────────────────────────────────────────────────────────────────────────── │
╰──────────────────────────────────────────────────────────────────────────────╯
```
  • Loading branch information
AJPfleger authored and asalzburger committed May 21, 2024
1 parent 4d9b5dc commit 055737b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Checks: '-*, \
clang-analyzer-optin.cplusplus.UninitializedObject, \
cppcoreguidelines-init-variables, \
cppcoreguidelines-pro-type-member-init, \
google-readability-casting, \
modernize-concat-nested-namespaces, \
modernize-use-equals-default, \
modernize-use-default-member-init, \
Expand Down
1 change: 1 addition & 0 deletions CI/clang_tidy/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ limits:
"clang-diagnostic-error": 0
"cppcoreguidelines-init-variables": 0
"cppcoreguidelines-pro-type-member-init": 0
"google-readability-casting": 0
"modernize-concat-nested-namespaces": 0
"modernize-use-equals-default": 0
"modernize-use-default-member-init": 0
Expand Down
1 change: 1 addition & 0 deletions cmake/ActsStaticAnalysis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(ACTS_RUN_CLANG_TIDY)
list(APPEND _chks "clang-analyzer-optin.cplusplus.UninitializedObject")
list(APPEND _chks "cppcoreguidelines-init-variables")
list(APPEND _chks "cppcoreguidelines-pro-type-member-init")
list(APPEND _chks "google-readability-casting")
list(APPEND _chks "modernize-concat-nested-namespaces")
list(APPEND _chks "modernize-use-equals-default")
list(APPEND _chks "modernize-use-default-member-init")
Expand Down

0 comments on commit 055737b

Please sign in to comment.