javascript:S138 not always ingoring AMD module function

I read over in a previous help request (Can javascript:S138 pick up functions in general, but exclude AMD module functions?) that the javascript:S138 rule is supposed to ignore AMD module function, however, it is not doing so in our code-base.

We are using a combination of require.js and backbone.js so our module definitions tend to look like this:

define(function(require) { // This function gets flagged by the rule
    var $ = require("jquery");
    var backbone = require("Backbone");
    var Ajax = require("Ajax");
    ...

    return backbone.View.extend({
        /* various function definitions */
    });
})

We are using Developer Edition Version 8.2 (build 32929)

Hi,

Indeed when migrating to eslint implementation for this rule we stopped ignoring AMD pattern (you can check comments on this ticket https://github.com/SonarSource/SonarJS/issues/1367). The idea was that if ESLint is not ignoring that, that’s not a problem for community. Also we hoped that AMD is not used that a lot as before as modules are available already.

We will keep your feedback in mind, but we will not jump on making the rule ignoring AMD as that’s something less and less used.

For now you can consider disabling the rule for the files defining AMD modules (https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.