-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Modernized code with clang-tidy [PCL-2731] #4249
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
Modernized code with clang-tidy [PCL-2731] #4249
Conversation
|
Could I request you to help integrate clang-tidy in the CI before adding the improvements to prevent a backslide later on? |
@kunaltyagi If there's a way to run As something to run with each CI build, however, it makes CI much longer without adding much value. Policy at places I've worked is for the developer to run |
|
Does it take long to run clang-tidy? (How long did it take to run on PCL?) |
Try this:
|
|
@PointCloudLibrary/maintainers What about trying GitHub actions for this? |
|
No opposition from my side. |
2593283 to
a042b05
Compare
|
@gnawme Could you please add a clang-tidy action to this PR on the lines of the format CI:
https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions |
@kunaltyagi Add this sequence to |
This will be in |
I don't know. Does the file needs to be in master for this? @shrijitsingh99 |
Just setup Github Actions on your fork. That should work. Nothing to be done on PCL side to test.
I would also recommend looking into #4004. The idea was to first integrate it into CMake or provide some tooling for running clang-tidy then integrate it. As I remember the blocker was CMake version since newer versions had tidy support. Without providing tooling for contributors to run |
Older CMake versions are also blocking the transition to C++17 or later, since they don't recognize
Yes, @kunaltyagi I recommend that this initial modernization be a one-time task, to be revisited periodically. Backsliding will just have to be caught by reviewers. |
Have opened an issue #4004, we can continue the discussion there.
Yeah, for now at least we can also provide a bash script. Maybe using the commands you are currently running for |
|
@kunaltyagi once these changes are approved, I think the affected files could use a |
We've been rolling out clang-format bit by bit (since the patch can be monstrous as well has mess up the comments and some code). Which module do you think should be prioritised? PR by modifying the whitelist in |
These are the directories where the
Which will give most bang for the buck if they had |
|
Lines of code affected in each module would be a better indicator. You can get per directory stats (in alphabetical order) using: ls -d ./* | xargs -n1 bash -c 'git diff --numstat master -- $@ | python -c "import fileinput as f; print(sum([int(line.strip()[0]) for line in f.input()]))"' {}The largest one should be the priority |
@SergioRAgostinho Wow, your graph is a lot cleaner and simpler than the one produced by |
ff1dee6 to
3bc3aa5
Compare
|
@kunaltyagi @SergioRAgostinho I ran |
I didn't, @divmadan did :)
My preferred approach is to submit a PR per tool per module e.g. pass cmake tidy over common open PR, once merged enable cmake format for common, continue for other modules. We just had a PR of equivalent magnitude in LoC changes, a "simple find replace", and it was a nightmare to review. |
|
Split the PR. |
d92d818 to
c3194d4
Compare
c3194d4 to
245dc1d
Compare
OK, opened #4283 to deal with empty destructors, reverted this PR to focus on the |
f1c6bd8 to
251a484
Compare
| #include <stdlib.h> // NOLINT | ||
| #include <stdio.h> // NOLINT | ||
| #include <math.h> // NOLINT | ||
| #include <string.h> // NOLINT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a header-filter regex
32c9514 to
085e65f
Compare
085e65f to
5d25b3c
Compare
5d25b3c to
754e3fa
Compare
754e3fa to
c449866
Compare
|
Marking this as stale due to 30 days of inactivity. Commenting or adding a new commit to the pull request will revert this. |
Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Fixed clang-format violations Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted to C++14 for older versions of CMake Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Test enabling C++17 when CMAKE_CXX_STANDARD 17 is not supported [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Test full(?) C++17 enable to see which CI builds fail [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted to C++14, since CI dies with C++17 Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added tags to exclude from clang-tidy [PL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Created initial clang-tidy GitHub action [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Created initial GitHub Action for clang-tidy [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Revised GitHub action, revised destructors per code review [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted miscommunication [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Modernized code with clang-tidy [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Fixed clang-format violations Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted to C++14 for older versions of CMake Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Test enabling C++17 when CMAKE_CXX_STANDARD 17 is not supported [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Test full(?) C++17 enable to see which CI builds fail [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted to C++14, since CI dies with C++17 Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added tags to exclude from clang-tidy [PL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Created initial clang-tidy GitHub action [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Created initial GitHub Action for clang-tidy [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Revised GitHub action, revised destructors per code review [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Reverted miscommunication [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Deleted empty virtual destructors [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Deleted another empty virtual destructor [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Made suggested changes to clang-tidy Action [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Restored clang-tidy bash script [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Fixed permissions on clang-tidy runner [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Modified Action to install clang-tidy [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added sudo, switched to use apt-get in Action [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Changed to run 'cmake .' to generate compile_commands.json [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Test adding compile_commands.json to repo [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Modified to install all clang tools [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Modified to install clang-10 Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added explicit clang-tidy version [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Revised clang installer packages [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Revised to install minimal Boost and Eigen [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added VTK installation [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added full Boost install package [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Removed clang-tidy checks to .clang-format [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Made changes from code review [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Removed --line-filter [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Restored checks, since .clang-tidy is not being honored [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Changed to run clang-tidy check in a container [PCL-2731] Co-authored-by: Shrijit Singh <shrijitsingh99@gmail.com> Removed unnecessary installation commands since containerized [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Restored clang-tidy, clang-tools installation [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added -y to installation command [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added pyyaml installation [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added python-pip installation [PCL-2731] Added git to installation [PCL-2731] Added explicit branch checkout to Action Inspected and revised destructors marked "empty" [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Added Ensenso to conform to Docker, split PR [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Qualified override to make Mojave build happy [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Found magic order for run-clang-tidy -config command [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Switched to installing latest clang tools [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Removed additional clang installs [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Specified clang-tools-10 explicitly [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Explicitly specify run-clang-tidy script [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com> Implemented exclusion filter, fixed file end [PCL-2731] Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com>
c449866 to
16b956e
Compare
Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com>
Signed-off-by: Norm Evangelista <norm.evangelista@gmail.com>
|
Replaced by #4560, which is taking a phased approach to applying |

Initial modernization of code base using
clang-tidyand an innocuous subset of itsmodernizechecks: