brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 105b4ff Raw
48 lines · plain
1.. title:: clang-tidy - google-objc-global-variable-declaration2 3google-objc-global-variable-declaration4=======================================5 6Finds global variable declarations in Objective-C files that do not follow the7pattern of variable names in Google's Objective-C Style Guide.8 9The corresponding style guide rule:10https://google.github.io/styleguide/objcguide.html#variable-names11 12All the global variables should follow the pattern of ``g[A-Z].*`` (variables)13or ``k[A-Z].*`` (constants). The check will suggest a variable name that14follows the pattern if it can be inferred from the original name.15 16For code:17 18.. code-block:: objc19 20  static NSString* myString = @"hello";21 22The fix will be:23 24.. code-block:: objc25 26  static NSString* gMyString = @"hello";27 28Another example of constant:29 30.. code-block:: objc31 32  static NSString* const myConstString = @"hello";33 34The fix will be:35 36.. code-block:: objc37 38  static NSString* const kMyConstString = @"hello";39 40However for code that prefixed with non-alphabetical characters like:41 42.. code-block:: objc43 44  static NSString* __anotherString = @"world";45 46The check will give a warning message but will not be able to suggest47a fix. The user needs to fix it on their own.48