In JavaScript, don't suggest const for variables that are filled in subsequent .forEach loops with attribute accessors

Type
False Positive

Product

  • Enterprise Edition
  • Version 8.9.7 (build 52159)

Rule

  • javascript:S3353
  • Unchanged variables should be marked “const”

Message
‘oFeatures’ is never reassigned. Use ‘const’ instead.

Language
JavaScript

Example

const fnPrepareFeaturesModel = function(aFeatures) {
    let oFeatures = {}; // <== rule hits this
    aFeatures.forEach(function(oFeature) {
        oFeatures[oFeature.name] = oFeature.isActive; // <== variable *is* filled here
    });
    oFeaturesModel.setData(oFeatures);
};

Hey @FlorianHoffmann

Please read this thread regarding reporting false-positives:

(We’re missing what product you’re using and what version if applicable, and the precise Rule ID)

Hey Colin, sure thing. Actually did read it beforehand and thought I had everything together. Okay now?