Debian Codegraph @

clang-tools-extra/docs/clang-tidy/checks/google/objc-global-variable-declaration.rst

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