include::../description-common.adoc[]

=== Code examples

==== Noncompliant code example

[source,java,diff-id=1,diff-type=noncompliant]
----
public class MyClass {
    public void doThings(boolean b, boolean c) {
        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=1,diff-type=compliant]
----
public class MyClass {
    public void doThings(boolean b, boolean c) {
        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[]
