2020-06-30 12:47:33 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
2021-04-26 17:29:13 +02:00
|
|
|
if (val = value() && check()) { // Noncompliant
|
|
|
|
// ...
|
2020-06-30 12:47:33 +02:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
2021-04-26 17:29:13 +02:00
|
|
|
val = value();
|
|
|
|
if (val && check()) {
|
|
|
|
// ...
|
2020-06-30 12:47:33 +02:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-04-26 17:29:13 +02:00
|
|
|
== Exceptions
|
|
|
|
|
|
|
|
The rule does not raise issues for the following patterns:
|
|
|
|
|
|
|
|
|
|
|
|
* assignments at declaration-level: ``++let a = b = 0;++``
|
|
|
|
* chained assignments: ``++a = b = c = 0;++``
|
|
|
|
* relational assignments: ``++(a = 0) != b++``
|
|
|
|
* sequential assignments: ``++a = 0, b = 1, c = 2++``
|
|
|
|
* assignments in lambda body: ``++() => a = 0++``
|
|
|
|
* conditional assignment idiom: ``++a || (a = 0)++``
|
|
|
|
* assignments in (do-)while conditions: ``++while (a = 0);++``
|
|
|
|
|
2020-06-30 12:47:33 +02:00
|
|
|
include::../see.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
|
|
|
ifdef::rspecator-view[]
|
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::rspecator-view[]
|