Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.0
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Issue Links
- depends upon
-
SONARPLUGINS-1788
Provide JavaScript rule engine based on SSLR
-
This rule requires a extended documentation and I guess the one provided by jslint is correct :
<p> The for in statement allows for looping through the names of all of the properties of an object. Unfortunately, it also loops through all of the properties that were inherited through the prototype chain. This has the bad side effect of serving up method functions when the interest is in data properties. If a program is written without awareness of this situation, then it can fail. </p> <p> The body of every for in statement should be wrapped in an if statement that does filtering. It can select for a particular type or range of values, or it can exclude functions, or it can exclude properties from the prototype. For example,</p> <pre> for (name in object) { if (object.hasOwnProperty(name)) { .... } } </pre>But in that case I expect to get an exception on the following piece of code which is not the case :
for (name in object) { print(something); }