rspec/rules/S2123/javascript/comments-and-links.adoc
2021-06-02 20:44:38 +02:00

23 lines
872 B
Plaintext

=== On 2015-03-16T13:31:43Z Pierre-Yves Nicolas Wrote:
Raising issues on "return i{plus}{plus}" would lead to false positives because variable i can be referenced and used by other places in the code: it could be an object property and it could also be referenced by a closure.
=== On 2015-03-16T14:34:31Z Ann Campbell Wrote:
I'm confused, [~pierre-yves.nicolas]. The original code examples showed post-incrementing a method-scope var...?
=== On 2015-03-16T14:46:43Z Pierre-Yves Nicolas Wrote:
\[~ann.campbell.2]: the following example illustrates the case of a closure which keeps a reference on a variable:
----
function f(x) {
var i = 0;
x.y = function () { return i; };
return i++;
}
var z = {};
f(z); // 0
z.y(); // 1
----
I don't think we can currently raise issues on "return i{plus}{plus};" without false positives.
include::../comments-and-links.adoc[]