== Why is this an issue? include::../description.adoc[] === Noncompliant code example [source,javascript] ---- function pickNumber() { let i = 0; i = i++; // Noncompliant; i is still zero return i++; // Noncompliant; 0 returned } ---- === Compliant solution [source,javascript] ---- function pickNumber() { let i = 0; i++; return ++i; } ---- ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] ''' == Comments And Links (visible only on this page) === on 16 Mar 2015, 13:31:43 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 16 Mar 2015, 14:34:31 Ann Campbell wrote: I'm confused, [~pierre-yves.nicolas]. The original code examples showed post-incrementing a method-scope var...? === on 16 Mar 2015, 14:46:43 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[] endif::env-github,rspecator-view[]