[clang-tidy] readability-identifier-naming does not enforce `MemberCase` when `PrivateMemberSuffix` is enabled.
Example:
class Foo
{
private:
int Something_;
};
Running clang-tidy with:
-checks=readability-identifier-naming --config="{CheckOptions: {readability-identifier-naming.MemberCase: lower_case, readability-identifier-naming.PrivateMemberSuffix: '_'}}"
Gives no warnings even though the member should have lower_case. https://godbolt.org/z/PPr35KqjW
Removing the PrivateMemberSuffix option makes the warning show up as intended:
https://godbolt.org/z/Tdz5fT9fj
But these are orthogonal options so they should have no effect on each other.
@llvm/issue-subscribers-clang-tidy
Author: Carlos Galvez (carlosgalvezp)
class Foo
{
private:
int Something_;
};
Running clang-tidy with:
-checks=readability-identifier-naming --config="{CheckOptions: {readability-identifier-naming.MemberCase: lower_case, readability-identifier-naming.PrivateMemberSuffix: '_'}}"
Gives no warnings even though the member should have lower_case. https://godbolt.org/z/PPr35KqjW
Removing the PrivateMemberSuffix option makes the warning show up as intended:
https://godbolt.org/z/Tdz5fT9fj
But these are orthogonal options so they should have no effect on each other.
Same issue for PrivateMemberPrefix:
https://godbolt.org/z/8Y6aE6Td8
hey can i work on this issue ??
@AnkitDubeycs25 Sure, just assigned you :)
hey i am working on another thing and i am not getting time to solve this issue can you unassign ..
Hey, I might have the same, or at least a closely related issue. Example:
struct myStructure_t
{
};
--checks=readability-identifier-naming --config="{CheckOptions: {readability-identifier-naming.StructCase: camelBack, readability-identifier-naming.StructSuffix: '_c'}}"
clang-tidy tells me
warning: invalid case style for struct 'myStructure_t' [readability-identifier-naming]
93 | struct myStructure_t
| ^~~~~~~~~~~~~~~~~~~~~~~
| myStructure_t_c
94 | {
95 | };
We use different suffixes, mostly _c for classes and structs, and _t for types and a couple more things. I guess because clang-tidy just sees an _ in the class name, it assumes some form of snake case, assumes that to be wrong, and also suggests adding the correct suffix on top. Hence its suggestion myStructure_t_c, however its own suggestion doesn't pass both checks, does it? At least it looks like that any case has more precedence than some pure form like camelBack 🤔
Can this be overcome somehow with the current feature set of clang-tidy? If you think this is another issue and worth reporting separately, just say so. Thanks.