70 lines
980 B
Plaintext
70 lines
980 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source, java, diff-id=11, diff-type=noncompliant]
|
|
----
|
|
a = true;
|
|
if (a) { // Noncompliant
|
|
doSomething();
|
|
}
|
|
|
|
if (b && a) { // Noncompliant; "a" is always "true"
|
|
doSomething();
|
|
}
|
|
|
|
if (c || !a) { // Noncompliant; "!a" is always "false"
|
|
doSomething();
|
|
}
|
|
|
|
if (c || (!c && b)) { // Noncompliant; c || (!c && b) is equal to c || b
|
|
doSomething();
|
|
}
|
|
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source, java, diff-id=11, diff-type=compliant]
|
|
----
|
|
a = true;
|
|
if (foo(a)) {
|
|
doSomething();
|
|
}
|
|
|
|
if (b) {
|
|
doSomething();
|
|
}
|
|
|
|
if (c) {
|
|
doSomething();
|
|
}
|
|
|
|
if (c || b) {
|
|
doSomething();
|
|
}
|
|
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|