35 lines
601 B
Plaintext
35 lines
601 B
Plaintext
![]() |
include::../description.adoc[]
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
if ( a == a ) // always true
|
||
|
{
|
||
|
doZ();
|
||
|
}
|
||
|
if ( a != a ) // always false
|
||
|
{
|
||
|
doY();
|
||
|
}
|
||
|
if ( a == b && a == b ) // if the first one is true, the second one is too
|
||
|
{
|
||
|
doX();
|
||
|
}
|
||
|
if ( a == b || a == b ) // if the first one is true, the second one is too
|
||
|
{
|
||
|
doW();
|
||
|
}
|
||
|
|
||
|
int j = 5 / 5; //always 1
|
||
|
int k = 5 - 5; // always 0
|
||
|
|
||
|
c.Equals(c); //always true
|
||
|
Object.Equals(c, c); //always true
|
||
|
----
|
||
|
|
||
|
== Exceptions
|
||
|
|
||
|
This rule ignores <code>*</code>, <code>+</code>, <code>=</code>, <code><<</code>, and <code>>></code>.
|
||
|
|
||
|
include::../see.adoc[]
|