llvm-project/clang-tools-extra/clang-tidy/google
Yan Zhang 2d83647007 [clang-tidy/google] Improve the Objective-C global variable declaration check 🔧
Summary:
The current Objective-C global variable declaration check restricts naming that is permitted by the Google Objective-C style guide.

The Objective-C style guide states the following:
"Global and file scope constants should have an appropriate prefix. [...] Constants may use a lowercase k prefix when appropriate"
http://google.github.io/styleguide/objcguide#constants

This change fixes the check to allow two or more capital letters as an appropriate prefix. This change intentionally avoids making a decision regarding whether to flag constants that use a two letter prefix (two letter prefixes are reserved by Apple¹ but many projects seem to violate this guideline).

This change eliminates an important category of false positives (constants prefixed with '[A-Z]{2,}') at the cost of introducing a less important category of false negatives (constants prefixed with only '[A-Z]'). The false positives are observed in standard recommended code while the false negatives occur in non-standard unrecommended code. The number of eliminated false positives is expected to be significantly larger than the number of exposed false negatives.

❧

(1)
"Two-letter prefixes like these are reserved by Apple for use in framework classes."
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Conventions/Conventions.html

Reviewers: aaron.ballman, Wizard, hokein, benhamilton

Reviewed By: aaron.ballman, Wizard

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 326046
2018-02-25 04:11:26 +00:00
..
AvoidCStyleCastsCheck.cpp [clang-tidy] Ignore blank spaces between cast's ")" and its sub expr. 2017-07-12 16:38:59 +00:00
AvoidCStyleCastsCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
AvoidThrowingObjCExceptionCheck.cpp add check to avoid throwing objc exception according to Google Objective-C guide 2017-11-16 01:28:29 +00:00
AvoidThrowingObjCExceptionCheck.h add check to avoid throwing objc exception according to Google Objective-C guide 2017-11-16 01:28:29 +00:00
CMakeLists.txt add check to avoid throwing objc exception according to Google Objective-C guide 2017-11-16 01:28:29 +00:00
DefaultArgumentsCheck.cpp [clang-tidy] new google-default-arguments check 2016-05-09 13:43:58 +00:00
DefaultArgumentsCheck.h [clang-tidy] new google-default-arguments check 2016-05-09 13:43:58 +00:00
ExplicitConstructorCheck.cpp [clang-tidy] Fix google-explicit-constructor issue with out-of-line conversions 2017-04-18 17:26:00 +00:00
ExplicitConstructorCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
ExplicitMakePairCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
ExplicitMakePairCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
GlobalNamesInHeadersCheck.cpp [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
GlobalNamesInHeadersCheck.h [clang-tidy] Fix/add style guide links. 2016-05-19 09:31:30 +00:00
GlobalVariableDeclarationCheck.cpp [clang-tidy/google] Improve the Objective-C global variable declaration check 🔧 2018-02-25 04:11:26 +00:00
GlobalVariableDeclarationCheck.h Add new check in google module for Objective-C code to ensure global variables follow the naming convention of Google Objective-C Style Guide 2017-11-07 08:53:37 +00:00
GoogleTidyModule.cpp add check to avoid throwing objc exception according to Google Objective-C guide 2017-11-16 01:28:29 +00:00
IntegerTypesCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
IntegerTypesCheck.h [clang-tidy] google-runtime-int: fix a false positive in implicit code. 2016-02-11 16:22:58 +00:00
NonConstReferences.cpp modernize-use-auto NFC fixes 2016-12-14 15:29:23 +00:00
NonConstReferences.h [clang-tidy] Add a whitelist option in google-runtime-references. 2016-10-10 16:38:11 +00:00
OverloadedUnaryAndCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
OverloadedUnaryAndCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
StringReferenceMemberCheck.cpp Adapt clang-tidy checks to changing semantics of hasDeclaration. 2017-08-02 13:13:11 +00:00
StringReferenceMemberCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
TodoCommentCheck.cpp [clang-tidy] Refactor: Move google clang-tidy checks to namespace clang::tidy::google 2015-03-05 13:46:14 +00:00
TodoCommentCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
UnnamedNamespaceInHeaderCheck.cpp [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
UnnamedNamespaceInHeaderCheck.h [clang-tidy] update links to Google Code Style in docs 2016-02-25 14:31:10 +00:00
UsingNamespaceDirectiveCheck.cpp Make google-build-using-namespace skip std::.*literals 2017-05-15 17:37:48 +00:00
UsingNamespaceDirectiveCheck.h Make google-build-using-namespace skip std::.*literals 2017-05-15 17:37:48 +00:00