rspec/rules/S4165/rule.adoc

27 lines
566 B
Plaintext

== Why is this an issue?
The transitive property says that if ``++a == b++`` and ``++b == c++``, then ``++a == c++``. In such cases, there's no point in assigning ``++a++`` to ``++c++`` or vice versa because they're already equivalent.
This rule raises an issue when an assignment is useless because the assigned-to variable already holds the value on all execution paths.
=== Noncompliant code example
[source,text]
----
a = b;
c = a;
b = c; // Noncompliant: c and b are already the same
----
=== Compliant solution
[source,text]
----
a = b;
c = a;
----