rspec/rules/S2662/rule.adoc

31 lines
548 B
Plaintext

== Why is this an issue?
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
[source,text]
----
a == 4; //noncompliant
...
for( a == 0; a < 10; a++){ //noncompliant
...
}
----
=== Compliant solution
[source,text]
----
a = 4;
...
for( a = 0; a < 10; a++){
...
}
----