[false-negative]S1656 can not detect static variables self-assigned in a special case: foo = foo = bar

Affects Sonarqube Version:
Sonarqube version: 8.1.0.31237
sonar-scanner version: 4.2.0.1873-windows

Rule:
S1656: Variables should not be self-assigned

Description:
Unable to detect static variables self-assigned in a special case: foo = foo = bar.
This rule is implemented in java-checks-6.2.0.21135-sources.jar!\org\sonar\java\checks\SelfAssignementCheck.java.
This rule uses if (SyntacticEquivalence.areEquivalent(node.expression(), node.variable())) { to determine whether the two sides of assignment statements are the same.
In the special case of foo = foo = bar, the left and right sides of the first equal sign are different, so it can not be detected

Code Sample demonstrating the issue:

Example 1:
while (x > 0 && x < screensize().width) {
	x = x = vx;
	g.drawImage(c.getCardImage(cardBack), x, y, this);
}

Example 2:
if (currentCount >= estimatedTotalCount) {
	estimatedTotalCount = estimatedTotalCount *= 2;
}

Expected outcome:
false-negative

Running Sonarqube through:
command line

Hi wongwuchiu,

Thank you for the detailed report. I have had a look into the issue you are reporting and while you are right that S1656 does not trigger in that case, S4165 does and indicates that the useless assignment should be removed. As such, it is not a problem that S1656 doesn’t trigger here. Have you perhaps disabled S4165?