rspec/rules/S2662/rule.adoc

27 lines
492 B
Plaintext
Raw Normal View History

When the equality operator '==' is unexpectedly used in place of the assignment operator '=', this leads to execute a useless condition expression and to not do the expected assignment.
By default, clang compiler for instance generates a warning in such case but doesn't fail the build.
== Noncompliant Code Example
----
a == 4; //noncompliant
...
for( a == 0; a < 10; a++){ //noncompliant
...
}
----
== Compliant Solution
----
a = 4;
...
for( a = 0; a < 10; a++){
...
}
----