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.