brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · c4d39a2 Raw
124 lines · plain
1.. title:: clang-tidy - readability-identifier-length2 3readability-identifier-length4=============================5 6This check finds variables and function parameters whose length are too short.7The desired name length is configurable.8 9Special cases are supported for loop counters and for exception variable names.10 11Options12-------13 14The following options are described below:15 16 - :option:`MinimumVariableNameLength`, :option:`IgnoredVariableNames`17 - :option:`MinimumParameterNameLength`, :option:`IgnoredParameterNames`18 - :option:`MinimumLoopCounterNameLength`, :option:`IgnoredLoopCounterNames`19 - :option:`MinimumExceptionNameLength`,20   :option:`IgnoredExceptionVariableNames`21 22.. option:: MinimumVariableNameLength23 24    All variables (other than loop counter, exception names and function25    parameters) are expected to have at least a length of26    `MinimumVariableNameLength` (default is `3`). Setting it to `0` or `1`27    disables the check entirely.28 29 30    .. code-block:: c++31 32      int i = 42;    // warns that 'i' is too short33 34    This check does not have any fix suggestions in the general case since35    variable names have semantic value.36 37.. option:: IgnoredVariableNames38 39    Specifies a regular expression for variable names that are40    to be ignored. The default value is empty, thus no names are ignored.41 42.. option:: MinimumParameterNameLength43 44    All function parameter names are expected to have a length of at least45    `MinimumParameterNameLength` (default is `3`). Setting it to `0` or `1`46    disables the check entirely.47 48 49    .. code-block:: c++50 51         int doubler(int x)   // warns that x is too short52         {53            return 2 * x;54         }55 56    This check does not have any fix suggestions in the general case since57    variable names have semantic value.58 59.. option:: IgnoredParameterNames60 61    Specifies a regular expression for parameters that are to be ignored.62    The default value is `^[n]$` for historical reasons.63 64.. option:: MinimumLoopCounterNameLength65 66    Loop counter variables are expected to have a length of at least67    `MinimumLoopCounterNameLength` characters (default is `2`). Setting it to68    `0` or `1` disables the check entirely.69 70 71    .. code-block:: c++72 73      // This warns that 'q' is too short.74      for (int q = 0; q < size; ++ q) {75         // ...76      }77 78.. option:: IgnoredLoopCounterNames79 80    Specifies a regular expression for counter names that are to be ignored.81    The default value is `^[ijk_]$`; the first three symbols for historical82    reasons and the last one since it is frequently used as a "don't care"83    value, specifically in tools such as Google Benchmark.84 85 86    .. code-block:: c++87 88      // This does not warn by default, for historical reasons.89      for (int i = 0; i < size; ++ i) {90          // ...91      }92 93.. option:: MinimumExceptionNameLength94 95    Exception clause variables are expected to have a length of at least96    `MinimumExceptionNameLength` (default is `2`). Setting it to `0` or `1`97    disables the check entirely.98 99 100    .. code-block:: c++101 102      try {103          // ...104      }105      // This warns that 'e' is too short.106      catch (const std::exception& x) {107          // ...108      }109 110.. option:: IgnoredExceptionVariableNames111 112    Specifies a regular expression for exception variable names that are to113    be ignored. The default value is `^[e]$` mainly for historical reasons.114 115    .. code-block:: c++116 117      try {118          // ...119      }120      // This does not warn by default, for historical reasons.121      catch (const std::exception& e) {122          // ...123      }124