Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.2
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Description
- Title
Avoid use of constructor functions for side-effects
- Description
Some people like to call constructor functions without assigning its result to any variable:var something = new MyConstructor(); //Compliant new MyConstructor(); //Non-Compliant, do we call a constructor to get a side effect ? If this is the case, this is definitely misleading.
There is no advantage in this approach over simply calling MyConstructor since the object that the operator new creates isn't used anywhere. So such kind of syntax is misleading and should be avoided.
- Violation message
Replace the statement by a standard call to the MyConstructor() function
- Default severity
Major
Part of Sonar war quality profile
Origin: JSHint
Issue Links
- is related to
-
SONARPLUGINS-2515
Update the SQALE mapping for new rules
-
Manually tested.