JavaScript - Destructuring assignment without declaration misinterpreted as assignment within subexpression

javascript
false-positive

(Trip) #1

Using SonarQube Version 3.89.2, I get this error with JavaScript code like:

const recordObject = state[recordNumber]; 

let foo = 'default1',
   bar = 'default2';

if (recordObject) {
   ({
      foo,
      bar
   } = recordObject);
}

return {foo, bar};

SonarQube misinterprets destructuring assignment without declaration as assignment within a sub-expression, and insists that foo and bar should be declared with const. But there’s also a rule to require destructuring assignment.


(Trip) #2

This issue has been fixed in this PR, so we’ll just need to update.