JavaScript false positive on variable self-assignment

sonarqube 7.5
this javascript rule says “Variables should not be self-assigned”

Noncompliant Code Example

function setName(name) {
name = name;

Compliant Solution

function setName(name) { = name;

but it is wrong.
lets have a look on the belows examples

  1. arrayA = arrayA.sort();

  2. maskedValue = maskedValue.reverse()

  3. list = list.sort(function(a, b) {

     return parseFloat(b) - parseFloat(a);


Hello @nkawxs

the reason behind the issue on the screenshot is that sort function changes the variable on which it is called. So you can rewrite your code without assignment:


I think we can improve message to be more explicit.