I’m not entirely sure if it’s a FP or if I’m just doing it wrong, but the following code triggers S2999 (“new” operators should be used with functions):
class Example {
static createInstance() {
return new this();
}
}
I’m not entirely sure if it’s a FP or if I’m just doing it wrong, but the following code triggers S2999 (“new” operators should be used with functions):
class Example {
static createInstance() {
return new this();
}
}
Dimitry,
Is this on SonarQube (if so, what version of SonarQube and SonarJS)? SonarCloud? SonarLint? Help us help you.
Colin
Hi Colin,
Sorry for not mentioning the environment. The issue is valid for both SonarLint and SonarQube. WebStorm 2019.3 + SonarLint 4.3.0.3495, SonarQube 8.0 CE.
The equivalent code that does not use the class syntax does not trigger the error:
function Example() {
}
Example.createInstance = function() {
return new this();
};
Hi,
Thanks for reporting! I created a ticket to fix it: https://github.com/SonarSource/SonarJS/issues/1763
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.