-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[Overview] Modernization code with clang-tidy #2731
Comments
I think modernize-use-auto makes a lot of sense for iterators, but for new expressions and cast expressions to make sense, MinTypeNameLength has to be at least larger or equal the default 5. modernize-avoid-c-arrays and modernize-deprecated-headers is definitely needed. I think modernize-make-shared, modernize-make-unique, modernize-use-emplace, modernize-use-nullptr are also good to add in. |
modernize-use-auto: be very careful with Eigen types. Basically, do not use the auto keywords with Eigen's expressions, unless you are 100% sure about what you are doing (ref). |
@jasjuang modernize-make-shared & modernize-make-unique will not have any effect, because we didn't had C++11 before ;). |
I added two points for discussion. |
Maybe we should also replace |
I suggest to skip |
Generally, I agree with you on this. However, due to the fact that PCL is a heavily templated library, we already have default values in ".h" files most of the times. And even if we don't have them in ".h", then they are in ".hpp", which is effectively the same. Meantime, there are benefits in using default member init. For example, when there are multiple constructors (which is often the case in PCL) it helps to maintain consistency between default values. |
Just wanted to add here the decision we took for |
Just to mention: I don't believe we can integrate clang-tidy in near feature into build server. I tried it in our project, but there are some issues:
|
😱 In case it turns out to be very expensive to run, we may consider making it a periodic job which runs, say, weekly. But the rest of the items you posted make this all sound like a very daunting task. |
General question, due to:
Originally posted by @SergioRAgostinho in #3112 (comment) Should I stop applying modernization until release of 1.10.0 or still continue? |
If you have time to spare, I would rather have your help on the transition to std until the release is complete. There are a couple of items now that are simply manual labor, e.g.: the bind -> lambda replacement. But let Sergey express his opinion, since he was still reviewing things. |
I am fine reviewing/merging clang-tidy conversions. But indeed help on the milestone items would be more important. |
Well ok, don't know if I really have (currently) time to help on boost. There is a small thing I will change, if I have time (PCL is using boost filesystem still via iterator instead of for-ranged loop). Nevertheless I will continue with some clang-tidy changes, because I can run clang-tidy if I don't need my PC and just need to review it after it . |
Updated list, so progress is better to see. |
I did run this night clang-tidy with all checks on our build server, to get a better feeling, which checks will produce smaller PRs and which bigger one. Well, this did run a bit out of control 😆 Job statistic:
Following stats are manually grepped via regex. So no duplicating detection was done. General warnings statistic:
Categories:
|
Sheer curiosity: what exactly is your company doing with PCL? I'm curious on the reasons for subjecting all your code base to this extensive battery of checks. 👀 |
We are not using this much modules of PCL. Most reason to use PCL for us: If we want to experiment with data we have here already a lot of algorithms, so we don't need to implement everything on our own.
We are working with a lot of students, so we have a lot of developer who only spend a few month/years on our project. So automatic checks are perfect to reduce time we maintainer have to spend on MRs to get the code ready to merge. In general: My main task in our project is to refactor code (I'm doing it since some years now), so I have less work later if the code kept clean automatically (Build- And clang-tidy is nice, because e.g. when to use |
Curious to see those :) |
With deduplication these are not this much:
|
Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs. |
Easiest way:
|
Is there a way to generate |
|
Yes, as it requires a successful run of CMake. Furthermore clang-tidy requires also all dependencies, to can check the code (not like CppCheck). |
Generating |
Yes, but when a dependency is missing, the target which requires these are not part of the database, as we skip some CMake code than. |
Opened PR #4560, working from the base modules of the PCL dependency graph to keep the LOC changed to a manageable quantity. Future PRs will continue up the dependency graph. Supersedes #4249 which was too large for sensible review. |
This issue is just to have an overview about clang-tidy modernizations.
Full list of clang-tidy checks.
Checks which redirect to another test are removed from following list.
Android:
cloexec
option tofopen
#2755, Addcloexec
option tofopen
#3223)cloexec
option tofopen
#2755)Boost:
std::to_string
overboost::lexical_cast
for integer conversions #2785)Bugprone:
Cert:
Clang-Analyzer:
cppcoreguidelines
hicpp:
Misc:
Modernize:
std::array
instead of C-array for ColorLUT #4489)modernize-concat-nested-namespaces(requires C++17)modernize-unary-static-assert(requires C++17)modernize-use-auto(developer decision, so no auto transformation, see discussion in Transform classic loops to range-based for loops in module common #2838)bool
literals #2793)emplace_back
overpush_back
#2784)=delete
to disable special members #2779)modernize-use-nodiscard(requires C++17)override
#2728)modernize-use-uncaught-exceptions(requires C++17)using
instead oftypedef
#3139)MPI
OpenMP
Performance
performance-inefficient-string-concatenation(discussion: [Clang-Tidy] Inefficient string concatenation #3233)std::move
orconst
reference for parameters #3232, Add missingstd::move
orconst
reference for parameters #3253)Readability:
empty()
oversize()
when checking container state #3033)nullptr
checks beforedelete
#2990)std::string::c_str()
#3517)""
#2758)Not relevant checks:
In case you see a modernization we could apply or can't apply, feel free to write it as comment. In case there is a modernization that needs discussion, open a new issue and write reference to it as comment, so I can add it to this list.
The text was updated successfully, but these errors were encountered: