Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

47 lines
1013 B
Plaintext

== Why is this an issue?
The assignment of default parameter values is generally intended to help the caller. But when a default assignment causes side effects, the caller may not be aware of the extra changes or may not fully understand their implications. I.e. default assignments with side effects may end up hurting the caller, and for that reason, they should be avoided.
=== Noncompliant code example
[source,javascript]
----
var count = 0;
function go(i = count++) { // Noncompliant
console.log(i);
}
go(); // outputs 0
go(7); // outputs 7
go(); // outputs 1
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the side effects from this default assignment of "xxx".
=== Highlighting
parameter and default assignment
'''
== Comments And Links
(visible only on this page)
=== on 1 Nov 2019, 17:35:25 Elena Vilchik wrote:
See \https://github.com/SonarSource/SonarJS/issues/1698
endif::env-github,rspecator-view[]