[PATCH] D39829: add new check for property declaration
Ben Hamilton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 10 08:25:14 PST 2017
benhamilton added inline comments.
Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:41
+ // the property name should be in Lower Camel Case like
+ // 'lowerCamelCase'
There are some exceptions we should special case. Acronyms like `URL` and `HTTP` and `HTML` are allowed at the beginning of method names (and property names—although that is not explicitly mentioned, property names follow the same guidelines as method names):
> For method names, start with a lowercase letter and capitalize the first letter of embedded words. Don’t use prefixes.
> An exception to this guideline is method names that start with a well-known acronym, for example, `TIFFRepresentation` (NSImage).
There is a list of well-known acronyms listed here:
Comment at: docs/clang-tidy/checks/google-objc-global-variable-declaration.rst:1
.. title:: clang-tidy - google-objc-global-variable-declaration
Let's remove "google-" everywhere and mention only Apple's style guide.
Comment at: docs/clang-tidy/checks/objc-property-declaration.rst:7
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Google's Objective-C Style Guide. The property name should
+be in the format of Lower Camel Case.
> benhamilton wrote:
> > hokein wrote:
> > > Google style? but the link you provided is Apple.
> > Google's Objective-C style guide is a list of additions on top of Apple's Objective-C style guide.
> > Property naming standards are defined in Apple's style guide, and not changed by Google's.
> I see, thanks for the clarification, I think the "Apple" would be clearer.
Yeah, we don't want to mention Google here. Apple is good.
Comment at: test/clang-tidy/objc-property-declaration.m:8
+ at property(assign, nonatomic) int camelCase;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:34: warning: property 'camelCase' is not in proper format according to property naming convention [objc-property-declaration]
+ at end
> hokein wrote:
> > Why does the check catch this case? Isn't `camelCase` a correct name?
> This is CHECK-MESSAGES-NOT
I think in that case you don't need an explicit CHECK (there is implicitly a "CHECK-MESSAGES-NOT" on every line for all warnings which fails the test if a warning is raised).
More information about the cfe-commits