The assignment of a boolean variable inside the test of a control structure such as an ``++if++``, ``++while++`` or ``++for++`` loop is almost always a mistake and should be corrected to avoid unexpected program results. In fact, even if it was done on purpose, it should be re-examined. 


== Noncompliant Code Example

----
boolean b = false;
if ( b = m.getTrue()) { ... } // Noncompliant

while (b = getTrue()) { ... } // Noncompliant; unintentionally infinite

for (int i = 0; i < 10 && b = getTrue(); i++) { ... } // Noncompliant
----


== Compliant Solution

----
boolean b = false;
if ( b = m.getTrue())
{
  System.out.println("How did we get here");
}
----



ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
