Can javascript:S138 pick up functions in general, but exclude AMD module functions?

javascript:S138 fires on whole AMD modules unless they are under 200 lines. Lots of our AMD modules are over 200 lines long.

AMD modules (https://requirejs.org/docs/whyamd.html) look like this:

define(['jquery'] , function ($) {
    return function () {};
});

Is there a way to have it pick up functions in general, but exclude AMD module functions?

Hello Alain,

Which version of SonarJS do you use? AMD are already ignored in this rule since version 2.6 (released 2.5 years ago)

Thank you, Elena.

We’re running:
SonarQube Enterprise: 7.4.0.18908
SonarJS: 5.0 (build 6962)

Ok, probably I know what’s wrong. In your code example you have 2 function expressions. Our rule ignores the outer one only, the inner one is checked as usual. So I expect you are having an undesirable issue on an inner function expression. Please confirm it. Anyway I’m not sure it’s a good idea to have a big returned function.

1 Like

I get it. It turns out we had a very large Jasmine describe block in one of the files. We can break those up or tactically accept them as wontfix.

Thank you :slight_smile:

1 Like