2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-01-27 16:55:38 +01:00
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.
2020-06-30 12:49:37 +02:00
2021-02-02 15:02:10 +01:00
2020-06-30 12:49:37 +02:00
This rule raises an issue when an assignment is useless because the assigned-to variable already holds the value on all execution paths.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-06-30 12:49:37 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:49:37 +02:00
----
a = b;
c = a;
b = c; // Noncompliant: c and b are already the same
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-06-30 12:49:37 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:49:37 +02:00
----
a = b;
c = a;
----