rspec/rules/S800/rule.adoc

44 lines
1.0 KiB
Plaintext

== Why is this an issue?
Ideally, identifiers (names of classes, variables, methods, structures, macros, labeles, &etc.) are all easily distinguished from one another. Unfortunately, some characters or combinations of characters look enough alike that that's not always the case.
Therefore, identifiers that differ from each other only by one of these problematic characters (or character combinations) should be renamed.
The problem pairs are:
* capital 'O' and digit 0
* capital 'I' (eye) and digit 1
* capital 'I' (eye) and lowercase 'l' (el)
* lowercase 'l' (el) and digit 1
* capital 'S' and digit 5
* capital 'Z' and digit 2
* lowercase 'n' and lowercase 'h'
* capital 'B' and digit 8
* lowercase 'm' and the combination "rn" ('r' followed by 'n')
* any lowercase letter and its uppercase variant
* the presence or absence of an underscore
=== Noncompliant code example
[source,text]
----
int myl;
int myI;
int my1;
----
=== Compliant solution
[source,text]
----
int my_el;
int my_upper_i;
int my_one;
----