Yassin Kammoun 65743cb622
Modify S3353: Migrate To LayC (#3302)
## Review

A dedicated reviewer checked the rule description successfully for:

- [ ] logical errors and incorrect information
- [ ] information gaps and missing content
- [ ] text style and tone
- [ ] PR summary and labels follow [the
guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)

---------

Co-authored-by: Zsolt Kolbay <121798625+zsolt-kolbay-sonarsource@users.noreply.github.com>
2023-10-17 17:44:58 +00:00

75 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

include::../why.adoc[]
include::../how.adoc[]
=== Code examples
==== Noncompliant code example
[source,javascript,diff-id=1,diff-type=noncompliant]
----
function seek(input) {
let target = 32; // Noncompliant
for (const i of input) {
if (i === target) {
return true;
}
}
return false;
}
----
==== Compliant solution
[source,javascript,diff-id=1,diff-type=compliant]
----
function seek(input) {
const target = 32;
for (const i of input) {
if (i === target) {
return true;
}
}
return false;
}
----
[source,javascript,diff-id=2,diff-type=noncompliant]
----
function getUrl(protocol, domain, path) {    
let url; // Noncompliant
url = `${protocol}/${domain}/${path}`;
return url;
}
----
==== Compliant solution
[source,javascript,diff-id=2,diff-type=compliant]
----
function getUrl(protocol, domain, path) {  
const url = `${protocol}/${domain}/${path}`;
return url;
}
----
== Resources
=== Documentation
* MDN - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const[const]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Make "xxx" "const".
endif::env-github,rspecator-view[]