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

42 lines
970 B
Plaintext

== Why is this an issue?
Instead of creating an array and then setting its items one by one, creation an initialization can - and should - happen all in one step. Doing so results in clearer code and eliminates the possibility that an item might be accidentally overwritten or left uninitialized.
=== Noncompliant code example
[source,javascript]
----
var colors = []; // Noncompliant
colors[1] = "red"; // Oops! Explicit initialization means that the 0th element is left empty
colors[2] = "green";
colors[2] = "blue"; // Oops again! "green" overwritten
----
=== Compliant solution
[source,javascript]
----
var colors = ["red","green","blue"];
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Create and initialize the "xxx" array using array literal syntax.
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]