For code of ivar declaration:
int barWithoutPrefix;
The fix will be:
int _barWithoutPrefix;
Differential D45392
[clang-tidy] add new check to find out objc ivars which do not have prefix '_' Wizard on Apr 6 2018, 3:38 PM. Authored by
Details
For code of ivar declaration: int barWithoutPrefix; The fix will be: int _barWithoutPrefix;
Diff Detail
Event TimelineComment Actions If this is Apple guideline, check name should reflect this. I think will be good idea to have general check for Apple naming conventions instead of separate checks for specific situations like objc-ivar-declaration and objc-property-declaration.
Comment Actions Thanks for the suggestion. I understand your point that they are both naming convention, however, they are about different components and using totally different naming rules. PropertyDeclarationCheck is already a very complicated check (the most complicated one for ObjC), I would rather not make it more heavy and try my best to split independent logic to different checks.
Comment Actions See readability-identifier-naming as example of multiple rules in one check.
Comment Actions I took a look at IdentifierNamingCheck. Here's my thought:
However, this check provides a good example of refactoring if in the future we have the needs of organizing complicated naming styles. Moving from simplicity to complexity is always easier. Thanks for pointing this out for us.
Comment Actions My point is not flexibility of configuration, but handling of various types of identifiers in same check, even if conventions are different. Comment Actions Yes I understand but I mean "flexibility of configuration" is one of the reasons of handling of various types of identifiers in same check, but we don't need it here. Comment Actions From user point of view, it's much easy to have one check which will check all possible types of identifiers, then set of not so obviously related checks. Comment Actions I wonder whether the readability-identifier-naming check could be extended to support this use case instead of adding a new check specifically for underscores in ivar names? Comment Actions Hmm readability-identifier-naming is a C++ check but this one is only for ObjC. I prefer putting them in separate places unless they work for both languages. Comment Actions I see no reasons why this check can't work for ObjC, if the handling of ObjC-specific AST nodes is added to it.
It has some sort of a hierarchical structure of rules that allow it to only touch a certain subset of identifiers. E.g. configure different naming styles for local variables and local constants. What it's lacking is a good documentation for all of these options =\
Yes, the existing check may need some modifications to do what this check needs to do, but I'd expect these modifications to be quite small, and we would potentially get a much more useful and generic tool instead of "one check per type of named entity per naming style" situation.
IIUC, it can be configured to only verify certain kinds of named entities. Thus there's no requirement to make it work with every aspect of our naming rules.
I'll respectfully disagree here. I would prefer to have a generic solution, if it's feasible. And so far, it looks like it is. Comment Actions Done. Yes it is very small changes to integrate this into it. I like it. The only annoying part was the doc is not that good and I spent a lot of time understanding the whole structure. Just one question, when we enable it in google by default, do we need to take care of the flags in the tests like -I%S/Inputs/readability-identifier-naming and -isystem %S/Inputs/readability-identifier-naming/system? Comment Actions Thank you, that's much better! I'd also appreciate, if you could document the options this check supports in its .rst document (separately from this patch). A few more comments inline.
Comment Actions BTW, it looks like the http://clang.llvm.org/extra/clang-tidy/checks/objc-property-declaration.html check could also be replaced with readability-identifier-naming (not in this patch).
|
I'd try committing the patch without disabling the test for powerpc64le and see whether the relevant buildbot complains. Looking at the description of r288563, I don't see anything that could be relevant to this test.