Configure ci clang tidy report#338
Configure ci clang tidy report#338filipe-cuim wants to merge 32 commits intoeclipse-openbsw:mainfrom
Conversation
d256dec to
18cf424
Compare
|
Hello @rolandreichweinbmw @christian-schilling @hbragge-acn @johannes-esr let's maybe move the discussion here. In this PR I followed the suggestion of doing a full report of clang-tidy findings, instead of just checking a diff. I tried to fix some of the warnings, but I didn't do it for all of them. There is a commit that addresses only one of the checkers. I also focused on the posix build, and as such you will find in the s32k1xx build some warnings that supposedly were cleaned up in some of the commits. There is also some clang-diagnostic-error which I'm not yet sure how to solve. These happen because clang-tidy looks to each compilation unit that is written in the compile_commands.json, and apparently some of these have invalid targets for unit test builds, and because of this CMake ignores those targets, and as such the compile commands becomes incomplete. Let me know what you think. Also, the checkers that I introduced came from a previous project, so I'm not really enforcing them. We may remove the ones you don't want to have. |
rolandreichweinbmw
left a comment
There was a problem hiding this comment.
Only put a few remarks.
Also: Are the included "Fix" commits directly related to clang-tidy findings? E.g. directly enabling a clean acceptable baseline? Otherwise, "unrelated" changes could be separated out to a cleanup PR.
Theoretically yes, each commit is respective to one clang-tidy finding. So, in principle, if I remove one commit the PR should remain clean, or at least not needed many rebase changes |
d829127 to
7d9d4f7
Compare
b816b37 to
385b457
Compare
27cb498 to
3d404e2
Compare
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
Signed-off-by: Filipe Cuim <filipe.cuim@ctw.bmwgroup.com>
3d404e2 to
19193f1
Compare
simon-d-bmw
left a comment
There was a problem hiding this comment.
@filipe-cuim there are still 7 clang-diagnostic-errors remaining.
|
|
||
| Additionally, most of these practices are enforced by clang-tidy which is run as part of our CI pipeline. | ||
| The clang-tidy configuration can be found in the file ``.clang-tidy`` in the root directory of openbsw repository. | ||
| The ci script for running clang-tidy is located in ``.ci/clang-tidy.py``, which runs an llvm helper tool called |
There was a problem hiding this comment.
nit:
| The ci script for running clang-tidy is located in ``.ci/clang-tidy.py``, which runs an llvm helper tool called | |
| The CI script for running clang-tidy is located in ``.ci/clang-tidy.py``, which runs an llvm helper tool called |
| parser.add_argument( | ||
| "--build_directory", | ||
| type=Path, | ||
| help="Path to the build directory containing compile_commands.json generated by CMake", | ||
| ) |
There was a problem hiding this comment.
nit:
| parser.add_argument( | |
| "--build_directory", | |
| type=Path, | |
| help="Path to the build directory containing compile_commands.json generated by CMake", | |
| ) | |
| parser.add_argument( | |
| "--build_directory", | |
| type=Path, | |
| help="Path to the build directory containing compile_commands.json generated by CMake", | |
| required=True | |
| ) |
| parser.add_argument( | ||
| "--output_file", | ||
| type=str, | ||
| help="Path to the output YAML file where clang-tidy findings will be stored", |
There was a problem hiding this comment.
nit:
| help="Path to the output YAML file where clang-tidy findings will be stored", | |
| help="Path to the output YAML file where clang-tidy findings will be stored", | |
| required=True |
| python3 .ci/clang-tidy.py --build_directory=build/tests/${{ matrix.platform }}/${{ matrix.config }} --output_file=ct-findings.yaml --exclude="3rdparty" --ignore-checks="clang-diagnostic-error" | ||
|
|
||
| - name: Upload clang-tidy findings | ||
| if: always() |
There was a problem hiding this comment.
nit: can't we skip this upload if the output file doesn't exist?
| { | ||
| // 64 = 8 byte payload | ||
| // 53 = CAN overhead | ||
| // NOLINTNEXTLINE(clang-analyzer-core.DivideZero): CAN Baudrate can never be zero here. |
There was a problem hiding this comment.
@filipe-cuim , just a quick question: Have you ever experimented with __builtin_assume()? I know this might introduce portability issues, but I was generally curious if the could work in such cases.
|
Interesting...I was actually trying to review and approve commit by commit but that doesn't seem to work... |
| using namespace ::runtime; | ||
| using namespace ::estd::test; | ||
|
|
||
| // NOLINTBEGIN(cert-oop54-cpp): This is intentional for testing purposes. |
There was a problem hiding this comment.
Same here, if it's an alias, we should only check for one rule.
| using namespace ::runtime; | ||
| using namespace ::estd::test; | ||
|
|
||
| // NOLINTBEGIN(cert-oop54-cpp): This is intentional for testing purposes. |
There was a problem hiding this comment.
According to here the two rules are aliased. If that's the case, we should only have suppressions for one.
| // NOLINTBEGIN(bugprone-reserved-identifier): Explanation for this suppression is below | ||
| /** | ||
| * \par Linking this module | ||
| * The diab compiler is providing these methods for char in-/output. They will |
There was a problem hiding this comment.
I think, we need to review this since we are using gcc and clang.
| { | ||
| #endif | ||
|
|
||
| // NOLINTBEGIN(cert-dcl51-cpp): Explanation for this suppression is below |
There was a problem hiding this comment.
According to here
these rules are aliases. I don't think we should suppress each of them but decide to use only one rule.
| } | ||
|
|
||
| #ifdef UNIT_TEST | ||
| static void unsetDiagSession() { sfpSessionManager = nullptr; } |
There was a problem hiding this comment.
nit: I'd call it unsetDiagSessionManager() to have a clear distiction between session manager and the actual session.
Description
The goal of this PR is to configure a .clang-tidy that respects openbsw coding conventions, and a ci job that runs clang-tidy checks on all compilation units that are generated in compile_commands.json.
In this first step we start with fewer clang-tidy checks enabled, because currently with all checks enabled the repository has around 3924 findings (excluding all files in test, 3rdparty and mock) and around 23386 findings (when excluding only 3rdparty folder).
Each clang-tidy CI workflow will print a report of all findings for each checker in stdout. After that it will also upload an artifact with a yaml file generated by clang-tidy, which will contain the location (both file name and file offset) of all findings.
There may also exist some checkers that we do not want to activate, and as such it's better to do small PRs after this one, where only few checkers are considered, in order to limit the amount of changes in the repository.