1 .. title:: clang-tidy - readability-identifier-length
3 readability-identifier-length
4 =============================
6 This check finds variables and function parameters whose length are too short.
7 The desired name length is configurable.
9 Special cases are supported for loop counters and for exception variable names.
14 The following options are described below:
16 - :option:`MinimumVariableNameLength`, :option:`IgnoredVariableNames`
17 - :option:`MinimumParameterNameLength`, :option:`IgnoredParameterNames`
18 - :option:`MinimumLoopCounterNameLength`, :option:`IgnoredLoopCounterNames`
19 - :option:`MinimumExceptionNameLength`, :option:`IgnoredExceptionVariableNames`
21 .. option:: MinimumVariableNameLength
23 All variables (other than loop counter, exception names and function
24 parameters) are expected to have at least a length of
25 `MinimumVariableNameLength` (default is `3`). Setting it to `0` or `1`
26 disables the check entirely.
31 int doubler(int x) // warns that x is too short
36 This check does not have any fix suggestions in the general case since
37 variable names have semantic value.
39 .. option:: IgnoredVariableNames
41 Specifies a regular expression for variable names that are
42 to be ignored. The default value is empty, thus no names are ignored.
44 .. option:: MinimumParameterNameLength
46 All function parameter names are expected to have a length of at least
47 `MinimumParameterNameLength` (default is `3`). Setting it to `0` or `1`
48 disables the check entirely.
53 int i = 42; // warns that 'i' is too short
55 This check does not have any fix suggestions in the general case since
56 variable names have semantic value.
58 .. option:: IgnoredParameterNames
60 Specifies a regular expression for parameters that are to be ignored.
61 The default value is `^[n]$` for historical reasons.
63 .. option:: MinimumLoopCounterNameLength
65 Loop counter variables are expected to have a length of at least
66 `MinimumLoopCounterNameLength` characters (default is `2`). Setting it to
67 `0` or `1` disables the check entirely.
72 // This warns that 'q' is too short.
73 for (int q = 0; q < size; ++ q) {
77 .. option:: IgnoredLoopCounterNames
79 Specifies a regular expression for counter names that are to be ignored.
80 The default value is `^[ijk_]$`; the first three symbols for historical
81 reasons and the last one since it is frequently used as a "don't care"
82 value, specifically in tools such as Google Benchmark.
87 // This does not warn by default, for historical reasons.
88 for (int i = 0; i < size; ++ i) {
92 .. option:: MinimumExceptionNameLength
94 Exception clause variables are expected to have a length of at least
95 `MinimumExceptionNameLength` (default is `2`). Setting it to `0` or `1`
96 disables the check entirely.
104 // This warns that 'e' is too short.
105 catch (const std::exception& x) {
109 .. option:: IgnoredExceptionVariableNames
111 Specifies a regular expression for exception variable names that are to
112 be ignored. The default value is `^[e]$` mainly for historical reasons.
119 // This does not warn by default, for historical reasons.
120 catch (const std::exception& e) {