[clang-tools-extra] r322886 - [clang-tidy objc-property-declaration] Expand list of ObjC acronyms

Ben Hamilton via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 12:51:24 PST 2018


Author: benhamilton
Date: Thu Jan 18 12:51:24 2018
New Revision: 322886

URL: http://llvm.org/viewvc/llvm-project?rev=322886&view=rev
Log:
[clang-tidy objc-property-declaration] Expand list of ObjC acronyms

Summary:
We were missing some pretty common acronyms in the camelCase
property name check objc-property-declaration.

This expands the list and sorts it lexicographically, so we can
avoid duplicates.

Test Plan: make -j12 check-clang-tools

Reviewers: Wizard, hokein, klimek

Reviewed By: Wizard

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D42253

Modified:
    clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
    clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
    clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=322886&r1=322885&r2=322886&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Thu Jan 18 12:51:24 2018
@@ -24,25 +24,63 @@ namespace objc {
 namespace {
 /// The acronyms are from
 /// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/APIAbbreviations.html#//apple_ref/doc/uid/20001285-BCIHCGAE
+///
+/// Keep this list sorted.
 constexpr char DefaultSpecialAcronyms[] =
+    "ACL;"
+    "API;"
+    "ARGB;"
     "ASCII;"
-    "PDF;"
-    "XML;"
+    "BGRA;"
+    "CMYK;"
+    "DNS;"
+    "FPS;"
+    "FTP;"
+    "GIF;"
+    "GPS;"
+    "HD;"
+    "HDR;"
     "HTML;"
-    "URL;"
-    "RTF;"
     "HTTP;"
-    "TIFF;"
+    "HTTPS;"
+    "HUD;"
+    "ID;"
     "JPG;"
-    "PNG;"
-    "GIF;"
+    "JS;"
+    "LAN;"
     "LZW;"
-    "ROM;"
-    "RGB;"
-    "CMYK;"
+    "MDNS;"
     "MIDI;"
-    "FTP;"
-    "ID";
+    "OS;"
+    "PDF;"
+    "PIN;"
+    "PNG;"
+    "POI;"
+    "PSTN;"
+    "PTR;"
+    "QA;"
+    "QOS;"
+    "RGB;"
+    "RGBA;"
+    "RGBX;"
+    "ROM;"
+    "RPC;"
+    "RTF;"
+    "RTL;"
+    "SDK;"
+    "SSO;"
+    "TCP;"
+    "TIFF;"
+    "TTS;"
+    "UI;"
+    "URI;"
+    "URL;"
+    "VC;"
+    "VOIP;"
+    "VPN;"
+    "VR;"
+    "WAN;"
+    "XML";
 
 /// For now we will only fix 'CamelCase' property to
 /// 'camelCase'. For other cases the users need to

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst?rev=322886&r1=322885&r2=322886&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst Thu Jan 18 12:51:24 2018
@@ -23,8 +23,8 @@ The check will only fix 'CamelCase' to '
 only provide warning messages since the property name could be complicated.
 Users will need to come up with a proper name by their own.
 
-This check also accepts special acronyms as prefix. Such prefix will suppress
-the check of Lower Camel Case according to the guide:
+This check also accepts special acronyms as prefixes or suffixes. Such prefixes or suffixes
+will suppress the Lower Camel Case check according to the guide:
 https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html#//apple_ref/doc/uid/20001281-1002931-BBCFHEAB
 
 For a full list of well-known acronyms:
@@ -37,7 +37,7 @@ Options
 
 .. option:: Acronyms
 
-   Semicolon-separated list of acronyms that can be used as prefix
-   of property names.
+   Semicolon-separated list of acronyms that can be used as a prefix
+   or a suffix of property names.
 
-   Defaults to `ASCII;PDF;XML;HTML;URL;RTF;HTTP;TIFF;JPG;PNG;GIF;LZW;ROM;RGB;CMYK;MIDI;FTP`.
+   If unset, defaults to "ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML".

Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=322886&r1=322885&r2=322886&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Thu Jan 18 12:51:24 2018
@@ -1,5 +1,7 @@
 // RUN: %check_clang_tidy %s objc-property-declaration %t
+ at class NSData;
 @class NSString;
+ at class UIViewController;
 
 @interface Foo
 @property(assign, nonatomic) int NotCamelCase;
@@ -8,6 +10,8 @@
 @property(assign, nonatomic) int camelCase;
 @property(strong, nonatomic) NSString *URLString;
 @property(strong, nonatomic) NSString *bundleID;
+ at property(strong, nonatomic) NSData *RGBABytes;
+ at property(strong, nonatomic) UIViewController *notificationsVC;
 @property(strong, nonatomic) NSString *URL_string;
 // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration]
 @end




More information about the cfe-commits mailing list