[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:28:28 PST 2017
benhamilton added inline comments.
================
Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:41
+ objcPropertyDecl(
+ // the property name should be in Lower Camel Case like
+ // 'lowerCamelCase'
----------------
benhamilton wrote:
> 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):
>
> https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
>
> > For method names, start with a lowercase letter and capitalize the first letter of embedded words. Don’t use prefixes.
> > `fileExistsAtPath:isDirectory:`
> >
> > 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:
>
> https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
>
> ```
> ASCII
> PDF
> XML
> HTML
> URL
> RTF
> HTTP
> TIFF
> JPG
> PNG
> GIF
> LZW
> ROM
> RGB
> CMYK
> MIDI
> FTP
> ```
>
Probably the right thing to do is make this a configuration option, the same way I did with `objc-forbidden-subclassing`, and default to the above list.
https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/objc/ForbiddenSubclassingCheck.cpp#L25
https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/objc/ForbiddenSubclassingCheck.cpp#L74
https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/objc/ForbiddenSubclassingCheck.cpp#L110
https://reviews.llvm.org/D39829
More information about the cfe-commits
mailing list