Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.3
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Description
See "loopfunc" in http://www.jshint.com/docs/ and http://stackoverflow.com/questions/3927054/jslint-error-dont-make-functions-within-a-loop-leads-to-question-about-javas
Title
Avoid definition of functions inside loops
Severity
Major
Description
<p>Defining functions inside of loops can lead to bugs such as this one:</p>
<pre>
var funs = [];
for (var i = 0; i < 13; i++) {
funs[i] = function() { // Non-Complian
return i;
};
}
print(funs[0]()); // 13 instead of 0
</pre>
Message
Avoid definition of function inside loop.
Activated?
Yes
Cardinality
Single
Issue Links
- depends upon
-
SONARPLUGINS-1788
Provide JavaScript rule engine based on SSLR
-
- is related to
-
SONARPLUGINS-2743
Update the SQALE mapping for new rules
-
Integration tests were updated.