-
Notifications
You must be signed in to change notification settings - Fork 184
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
Universal revisions based on clang-tidy #2828
Comments
|
I wouldn't want to accept the automated changes for Edit: Wouldn't want to blindly accept the automated change; happy to manually revise #2829 if necessary. |
On #2702 I'm currently getting a lot of |
I agree on that example.
That'd be great!
Although I understand that this check is noisy, my opinion is that we should make an effort to follow its advice. If a conversion is benign (which often can be a deceiving matter), an explicit cast (preferably |
Something to think about as #2829 hopefully gets merged: It might be the case that, for those Where I'm not sure if this would work is in precommit hooks. It often takes a long time for |
Added a few to the list in reviewing #2877. |
Since #2745,
clang-tidy
was introduced.It is run only on proposed changes within PRs, not across the whole code base, since the latter would be overly burdensome.
We can however elect to take any recommendations that it makes based on isolated code, and apply the same changes across the code base, eg. in cases where instances of such can be found through a regex search or where it's known that a particular design pattern is used in a finite number of places.
This issue will serve to facilitate listing
clang-tidy
proposals that may be worthwhile revising the code base.Hopefully it will doubly serve to show
clang-tidy
proposals that we are aware of but may not necessarily resolve in any unrelated PR, so that those less experienced will not panic if they see them.cppcoreguidelines-pro-bounds-array-to-pointer-decay
Exemplified in Disable clang format cli take2 #2818.
Really does not like the way that strings and lists-of-strings are handled in the CLI; particularly for
Argument::type_choice()
, but also for eg.App::DESCRIPTION
.Would be best resolved comprehensively with Back-end: Remove all char* / char** usages #2111.
cppcoreguidelines-macro-usage
Exemplified in Disable clang format cli take2 #2818 for
cmd/mrview.cpp
, but macro functions are likely used in a number of other places.readability-container-size-empty
"warning: the 'empty' method should be used to check for emptiness instead of 'size'"
First seen in dwicat: Support different voxel grids #2702.
Might be most applicable to cases where
get_option_value()
should instead be used. The case in dwicat: Support different voxel grids #2702 is an enum class, which from memory preventedget_option_value()
from being used. But probably also many other instances, and potentially something that could be found via grep.Addressed in Check emptiness of containers using empty() #2829.
readability-uppercase-literal-suffix
Shown in Check emptiness of containers using empty() #2829, though I've seen it elsewhere also.
Had never encountered the recommendation that datatype suffices should be capitalised. This is another that might be possible to automatically correct across the code base, at least as a first pass; it's possible that some casts to single precision predate the transition of
default_type
to double precision, and therefore in fact the suffix should be removed.misc-const-correctness
Shown in Check emptiness of containers using empty() #2829, but also one I've seen elsewhere.
This might be possible to accept automatic changes with some manual revisions to tweak formatting. As long as both major compilers are happy after the change.
Only catch if trying to apply an automatic fix here is that it seems to like placing the
const
qualifier after the type, rather than before. I presume this is because it better disambiguates cases like const pointers to const objects, but it still looks alien to me currently.readability-implicit-bool-conversion
This includes comparing pointers to
nullptr
and checking if integers are greater than zero. The occurrences I've seen I've agreed with, so might be applicable across the board.cppcoreguidelines-init-variables
There are certainly instances where the content of a variable gets immediately set through some function call, and so the lack of initialization only persists for one line of code. It would nevertheless be preferable to initialise all variables anyway to shut this one up. Indeed in some circumstances I've explicitly used
std::numeric_limits::signaling_NaN()
in initialisers; we may not be catching such, but it clearly signals within the code that it's not intended to be a valid value (unlike other pieces of code where we intentionally exploit NaNs).readability-make-member-function-const
concurrency-mt-unsafe
Somewhat related to Document what resources should be protected by mutexes #2795.
readability-const-return-type
Converse to prior listing, using
const
where it shouldn't be used. Also a potential flag that the return type may have been intended to be a reference but the ampersand was erroneously omitted.The text was updated successfully, but these errors were encountered: