
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.
57 lines
1.0 KiB
Plaintext
57 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
||
|
||
Marking a variable that is unchanged after initialization ``++const++`` is an indication to future maintainers that "no this isn't updated, and it's not supposed to be". ``++const++`` should be used in these situations in the interests of code clarity.
|
||
|
||
=== Noncompliant code example
|
||
|
||
[source,javascript]
|
||
----
|
||
function seek(input) {
|
||
let target = 32; // Noncompliant
|
||
for (let i of input) { // Noncompliant
|
||
if (i == target) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function getUrl(query) {
|
||
let url; // Noncompliant
|
||
url = "http://example.com";
|
||
return url;
|
||
}
|
||
----
|
||
|
||
=== Compliant solution
|
||
|
||
[source,javascript]
|
||
----
|
||
function seek(input) {
|
||
const target = 32;
|
||
for (const i of input) {
|
||
if (i == target) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function getUrl(query) {
|
||
const url = "http://example.com";
|
||
return url;
|
||
}
|
||
----
|
||
ifdef::env-github,rspecator-view[]
|
||
|
||
'''
|
||
== Implementation Specification
|
||
(visible only on this page)
|
||
|
||
=== Message
|
||
|
||
Make "xxx" "const".
|
||
|
||
|
||
endif::env-github,rspecator-view[]
|