35 lines
556 B
Plaintext
35 lines
556 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 ``*``, ``+``, ``=``, ``<<``, and ``>>``.
|
|
|
|
include::../see.adoc[]
|