In code below assignment to a null value is reported as useless assignment (S1854) even though it is said in the docs that this is an exception to the rule
Lang: JavaScript
Version: 1.6.0
Sample Code:
function doSomething () {
var foo = new Foo();
foo.buzz();
// I'm done using it and I want to clean it up early.
foo = null // <- This line gets tagged as Useless Assignment (S1845)
}
the documentation states that initializations to null are ignored [1]. In your case, though, the assignment is not an initialization. Further, if the scope of the variable foo is restricted to doSomething(), the object should be freed/garbage collected anyway and explicitely setting it to null would be unnecessary (assuming the JavaScript’s memory managment is comparable to Java/C++)