From 9dc9703730443b90fb87bd92e1d384b3e42685fd Mon Sep 17 00:00:00 2001
From: Tibor Blenessy
Date: Fri, 20 Oct 2023 16:46:07 +0200
Subject: [PATCH] Update rule metadata (#4302)
---
css-sonarpedia/sonarpedia.json | 2 +-
.../org/sonar/l10n/css/rules/css/S1128.json | 2 +-
.../org/sonar/l10n/css/rules/css/S4649.html | 38 +++++++---
.../org/sonar/l10n/css/rules/css/S4666.html | 44 ++++++++----
.../javascript/rules/javascript/S106.html | 40 +++++++++--
.../javascript/rules/javascript/S1066.html | 32 ++++++++-
.../javascript/rules/javascript/S1066.json | 2 +-
.../javascript/rules/javascript/S1068.html | 5 +-
.../javascript/rules/javascript/S109.html | 27 +++----
.../javascript/rules/javascript/S1110.html | 26 +++----
.../javascript/rules/javascript/S1117.html | 42 ++++++++++-
.../javascript/rules/javascript/S1117.json | 2 +-
.../javascript/rules/javascript/S1119.html | 6 +-
.../javascript/rules/javascript/S1121.html | 42 ++++++-----
.../javascript/rules/javascript/S1125.html | 21 +++---
.../javascript/rules/javascript/S1126.html | 7 +-
.../javascript/rules/javascript/S1128.html | 2 +-
.../javascript/rules/javascript/S1128.json | 2 +-
.../javascript/rules/javascript/S1131.html | 8 +--
.../javascript/rules/javascript/S1135.html | 2 +-
.../javascript/rules/javascript/S1143.html | 13 ++--
.../javascript/rules/javascript/S117.html | 53 +++++++++++---
.../javascript/rules/javascript/S1172.html | 41 ++++++-----
.../javascript/rules/javascript/S1186.html | 72 ++++++++++---------
.../javascript/rules/javascript/S1192.html | 31 +++++++-
.../javascript/rules/javascript/S1199.html | 68 +++++++++---------
.../javascript/rules/javascript/S1226.html | 11 +--
.../javascript/rules/javascript/S125.html | 5 +-
.../javascript/rules/javascript/S1264.html | 4 +-
.../javascript/rules/javascript/S1301.html | 5 +-
.../javascript/rules/javascript/S1314.html | 8 +--
.../javascript/rules/javascript/S1321.html | 4 +-
.../javascript/rules/javascript/S134.html | 58 +++++++++++----
.../javascript/rules/javascript/S1439.html | 2 +-
.../javascript/rules/javascript/S1440.html | 67 +++++++++++++----
.../javascript/rules/javascript/S1472.html | 13 ++--
.../javascript/rules/javascript/S1481.html | 7 +-
.../javascript/rules/javascript/S1488.html | 42 +++++------
.../javascript/rules/javascript/S1515.html | 4 +-
.../javascript/rules/javascript/S1516.html | 4 +-
.../javascript/rules/javascript/S1527.html | 8 +--
.../javascript/rules/javascript/S1529.html | 14 ++--
.../javascript/rules/javascript/S1533.html | 10 +--
.../javascript/rules/javascript/S1534.html | 5 +-
.../javascript/rules/javascript/S1536.html | 6 +-
.../javascript/rules/javascript/S1763.html | 12 ++--
.../javascript/rules/javascript/S1774.html | 14 ++--
.../javascript/rules/javascript/S1788.html | 6 +-
.../javascript/rules/javascript/S1848.html | 8 +--
.../javascript/rules/javascript/S1854.html | 59 ++++++++++-----
.../javascript/rules/javascript/S1854.json | 2 +-
.../javascript/rules/javascript/S1862.html | 7 +-
.../javascript/rules/javascript/S1874.html | 29 +++++---
.../javascript/rules/javascript/S2068.html | 1 -
.../javascript/rules/javascript/S2077.html | 1 -
.../javascript/rules/javascript/S2092.html | 1 -
.../javascript/rules/javascript/S2137.html | 10 +--
.../javascript/rules/javascript/S2189.html | 13 ++--
.../javascript/rules/javascript/S2201.html | 12 ++--
.../javascript/rules/javascript/S2208.html | 13 ++--
.../javascript/rules/javascript/S2234.html | 2 +-
.../javascript/rules/javascript/S2251.html | 4 +-
.../javascript/rules/javascript/S2259.html | 14 ++--
.../javascript/rules/javascript/S2310.html | 6 +-
.../javascript/rules/javascript/S2392.html | 10 +--
.../javascript/rules/javascript/S2432.html | 2 +-
.../javascript/rules/javascript/S2589.html | 29 ++++++--
.../javascript/rules/javascript/S2612.html | 1 -
.../javascript/rules/javascript/S2639.html | 5 +-
.../javascript/rules/javascript/S2685.html | 19 ++---
.../javascript/rules/javascript/S2688.html | 10 +--
.../javascript/rules/javascript/S2692.html | 7 +-
.../javascript/rules/javascript/S2699.html | 4 +-
.../javascript/rules/javascript/S2703.html | 13 ++--
.../javascript/rules/javascript/S2737.html | 5 +-
.../javascript/rules/javascript/S2870.html | 23 +++---
.../javascript/rules/javascript/S2871.html | 13 ++--
.../javascript/rules/javascript/S2933.html | 33 +++++----
.../javascript/rules/javascript/S2933.json | 2 +-
.../javascript/rules/javascript/S2970.html | 4 +-
.../javascript/rules/javascript/S2990.html | 25 +++----
.../javascript/rules/javascript/S2999.html | 8 +--
.../javascript/rules/javascript/S3001.html | 12 ++--
.../javascript/rules/javascript/S3257.html | 23 ++++--
.../javascript/rules/javascript/S3330.html | 1 -
.../javascript/rules/javascript/S3353.html | 51 ++++++++-----
.../javascript/rules/javascript/S3353.json | 2 +-
.../javascript/rules/javascript/S3415.html | 25 ++++---
.../javascript/rules/javascript/S3498.html | 28 ++++++--
.../javascript/rules/javascript/S3500.html | 10 +--
.../javascript/rules/javascript/S3504.html | 14 ++--
.../javascript/rules/javascript/S3516.html | 5 +-
.../javascript/rules/javascript/S3524.html | 43 ++++++++---
.../javascript/rules/javascript/S3531.html | 4 +-
.../javascript/rules/javascript/S3579.html | 7 +-
.../javascript/rules/javascript/S3616.html | 9 +--
.../javascript/rules/javascript/S3626.html | 6 +-
.../javascript/rules/javascript/S3686.html | 2 +-
.../javascript/rules/javascript/S3696.html | 4 +-
.../javascript/rules/javascript/S3699.html | 7 +-
.../javascript/rules/javascript/S3735.html | 7 +-
.../javascript/rules/javascript/S3776.html | 5 ++
.../javascript/rules/javascript/S3782.html | 4 +-
.../javascript/rules/javascript/S3785.html | 14 ++--
.../javascript/rules/javascript/S3796.html | 2 +-
.../javascript/rules/javascript/S3799.html | 2 +-
.../javascript/rules/javascript/S3800.html | 2 +-
.../javascript/rules/javascript/S3812.html | 15 ++--
.../javascript/rules/javascript/S3834.html | 6 +-
.../javascript/rules/javascript/S3854.html | 8 +--
.../javascript/rules/javascript/S3863.html | 4 +-
.../javascript/rules/javascript/S3984.html | 6 +-
.../javascript/rules/javascript/S4030.html | 4 +-
.../javascript/rules/javascript/S4043.html | 25 ++++---
.../javascript/rules/javascript/S4123.html | 6 +-
.../javascript/rules/javascript/S4124.html | 9 +--
.../javascript/rules/javascript/S4125.html | 4 +-
.../javascript/rules/javascript/S4138.html | 4 +-
.../javascript/rules/javascript/S4140.html | 3 +-
.../javascript/rules/javascript/S4156.html | 6 +-
.../javascript/rules/javascript/S4158.html | 4 +-
.../javascript/rules/javascript/S4204.html | 50 ++++++++-----
.../javascript/rules/javascript/S4275.html | 7 +-
.../javascript/rules/javascript/S4323.html | 7 +-
.../javascript/rules/javascript/S4325.html | 8 ++-
.../javascript/rules/javascript/S4335.html | 12 ++--
.../javascript/rules/javascript/S4423.html | 1 -
.../javascript/rules/javascript/S4502.html | 1 -
.../javascript/rules/javascript/S4524.html | 2 +-
.../javascript/rules/javascript/S4619.html | 9 +--
.../javascript/rules/javascript/S4621.html | 3 +-
.../javascript/rules/javascript/S4622.html | 2 +-
.../javascript/rules/javascript/S4623.html | 3 +-
.../javascript/rules/javascript/S4624.html | 4 +-
.../javascript/rules/javascript/S4634.html | 12 ++--
.../javascript/rules/javascript/S4721.html | 1 -
.../javascript/rules/javascript/S4782.html | 5 +-
.../javascript/rules/javascript/S4787.html | 1 -
.../javascript/rules/javascript/S4790.html | 1 -
.../javascript/rules/javascript/S4818.html | 2 -
.../javascript/rules/javascript/S4822.html | 17 ++---
.../javascript/rules/javascript/S4823.html | 1 -
.../javascript/rules/javascript/S5122.html | 1 -
.../javascript/rules/javascript/S5542.html | 1 -
.../javascript/rules/javascript/S5547.html | 1 -
.../javascript/rules/javascript/S5693.html | 2 +-
.../javascript/rules/javascript/S5843.html | 19 ++---
.../javascript/rules/javascript/S5850.html | 9 +--
.../javascript/rules/javascript/S5860.html | 4 +-
.../javascript/rules/javascript/S5863.html | 2 +-
.../javascript/rules/javascript/S5876.html | 2 +-
.../javascript/rules/javascript/S5958.html | 6 +-
.../javascript/rules/javascript/S6079.html | 2 +-
.../javascript/rules/javascript/S6080.html | 6 +-
.../javascript/rules/javascript/S6092.html | 20 +++---
.../javascript/rules/javascript/S6324.html | 7 +-
.../javascript/rules/javascript/S6325.html | 4 +-
.../javascript/rules/javascript/S6328.html | 13 ++--
.../javascript/rules/javascript/S6351.html | 13 ++--
.../javascript/rules/javascript/S6353.html | 22 +++---
.../javascript/rules/javascript/S6426.html | 6 +-
.../javascript/rules/javascript/S6435.html | 4 +-
.../javascript/rules/javascript/S6438.html | 2 +-
.../javascript/rules/javascript/S6439.html | 2 +-
.../javascript/rules/javascript/S6440.html | 4 +-
.../javascript/rules/javascript/S6441.html | 4 +-
.../javascript/rules/javascript/S6442.html | 7 +-
.../javascript/rules/javascript/S6443.html | 6 +-
.../javascript/rules/javascript/S6477.html | 8 +--
.../javascript/rules/javascript/S6479.html | 8 +--
.../javascript/rules/javascript/S6481.html | 8 +--
.../javascript/rules/javascript/S6486.html | 8 +--
.../javascript/rules/javascript/S6509.html | 10 +--
.../javascript/rules/javascript/S6522.html | 11 +--
.../javascript/rules/javascript/S6523.html | 11 +--
.../javascript/rules/javascript/S6534.html | 10 +--
.../javascript/rules/javascript/S6535.html | 6 +-
.../javascript/rules/javascript/S6544.html | 8 +--
.../javascript/rules/javascript/S6550.html | 2 +-
.../javascript/rules/javascript/S6551.html | 5 +-
.../javascript/rules/javascript/S6557.html | 6 +-
.../javascript/rules/javascript/S6565.html | 4 +-
.../javascript/rules/javascript/S6568.html | 5 +-
.../javascript/rules/javascript/S6569.html | 5 +-
.../javascript/rules/javascript/S6571.html | 5 +-
.../javascript/rules/javascript/S6572.html | 2 +-
.../javascript/rules/javascript/S6578.html | 2 +-
.../javascript/rules/javascript/S6582.html | 3 +-
.../javascript/rules/javascript/S6583.html | 2 +-
.../javascript/rules/javascript/S6590.html | 2 +-
.../javascript/rules/javascript/S6594.html | 8 +--
.../javascript/rules/javascript/S6598.html | 4 +-
.../javascript/rules/javascript/S6635.html | 2 +-
.../javascript/rules/javascript/S6637.html | 5 +-
.../javascript/rules/javascript/S6643.html | 6 +-
.../javascript/rules/javascript/S6644.html | 7 +-
.../javascript/rules/javascript/S6645.html | 9 +--
.../javascript/rules/javascript/S6647.html | 2 +-
.../javascript/rules/javascript/S6650.html | 6 +-
.../javascript/rules/javascript/S6653.html | 8 ++-
.../javascript/rules/javascript/S6654.html | 14 ++--
.../javascript/rules/javascript/S6657.html | 7 +-
.../javascript/rules/javascript/S6660.html | 3 +-
.../javascript/rules/javascript/S6661.html | 9 +--
.../javascript/rules/javascript/S6666.html | 7 +-
.../javascript/rules/javascript/S6671.html | 4 +-
.../javascript/rules/javascript/S6676.html | 14 ++--
.../javascript/rules/javascript/S6679.html | 10 +--
.../javascript/rules/javascript/S6746.html | 4 +-
.../javascript/rules/javascript/S6746.json | 7 +-
.../javascript/rules/javascript/S6747.html | 12 ++--
.../javascript/rules/javascript/S6747.json | 7 +-
.../javascript/rules/javascript/S6748.html | 2 +-
.../javascript/rules/javascript/S6748.json | 7 +-
.../javascript/rules/javascript/S6749.html | 2 +-
.../javascript/rules/javascript/S6749.json | 6 +-
.../javascript/rules/javascript/S6750.html | 5 +-
.../javascript/rules/javascript/S6750.json | 7 +-
.../javascript/rules/javascript/S6754.html | 2 +-
.../javascript/rules/javascript/S6754.json | 6 +-
.../javascript/rules/javascript/S6756.html | 4 +-
.../javascript/rules/javascript/S6756.json | 7 +-
.../javascript/rules/javascript/S6757.html | 6 +-
.../javascript/rules/javascript/S6757.json | 7 +-
.../javascript/rules/javascript/S6759.html | 7 +-
.../javascript/rules/javascript/S6759.json | 4 +-
.../javascript/rules/javascript/S6761.html | 6 +-
.../javascript/rules/javascript/S6761.json | 7 +-
.../javascript/rules/javascript/S6763.html | 4 +-
.../javascript/rules/javascript/S6763.json | 7 +-
.../javascript/rules/javascript/S6766.html | 4 +-
.../javascript/rules/javascript/S6766.json | 7 +-
.../javascript/rules/javascript/S6767.html | 6 +-
.../javascript/rules/javascript/S6767.json | 4 +-
.../javascript/rules/javascript/S6770.html | 2 +-
.../javascript/rules/javascript/S6770.json | 6 +-
.../javascript/rules/javascript/S6772.html | 8 +--
.../javascript/rules/javascript/S6772.json | 7 +-
.../javascript/rules/javascript/S6774.html | 8 ++-
.../javascript/rules/javascript/S6774.json | 5 +-
.../javascript/rules/javascript/S6775.html | 8 +--
.../javascript/rules/javascript/S6775.json | 4 +-
.../javascript/rules/javascript/S6793.html | 22 +++---
.../javascript/rules/javascript/S6793.json | 3 +-
.../javascript/rules/javascript/S6807.html | 11 +--
.../javascript/rules/javascript/S6807.json | 10 +--
.../javascript/rules/javascript/S6811.html | 9 +--
.../javascript/rules/javascript/S6811.json | 10 +--
.../javascript/rules/javascript/S6819.html | 18 ++---
.../javascript/rules/javascript/S6819.json | 2 +-
.../javascript/rules/javascript/S6821.html | 28 ++++----
.../javascript/rules/javascript/S6821.json | 3 +-
.../javascript/rules/javascript/S6822.html | 8 +--
.../javascript/rules/javascript/S6822.json | 4 +-
.../javascript/rules/javascript/S6823.html | 39 ++++++----
.../javascript/rules/javascript/S6823.json | 7 +-
.../javascript/rules/javascript/S6824.html | 24 +++----
.../javascript/rules/javascript/S6824.json | 3 +-
.../javascript/rules/javascript/S6825.html | 26 +++----
.../javascript/rules/javascript/S6825.json | 10 +--
.../javascript/rules/javascript/S6827.html | 33 +++++----
.../javascript/rules/javascript/S6827.json | 1 -
.../javascript/rules/javascript/S878.html | 26 ++++---
.../javascript/rules/javascript/S905.html | 42 ++++++++---
.../javascript/rules/javascript/S930.html | 10 +--
sonarpedia.json | 2 +-
266 files changed, 1690 insertions(+), 1157 deletions(-)
diff --git a/css-sonarpedia/sonarpedia.json b/css-sonarpedia/sonarpedia.json
index c2a959996ca..be0445a8c8e 100644
--- a/css-sonarpedia/sonarpedia.json
+++ b/css-sonarpedia/sonarpedia.json
@@ -3,7 +3,7 @@
"languages": [
"CSS"
],
- "latest-update": "2023-09-22T12:30:24.906477Z",
+ "latest-update": "2023-10-20T14:08:17.442676Z",
"options": {
"no-language-in-filenames": true
}
diff --git a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S1128.json b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S1128.json
index 62b141924c6..0740f19b60a 100644
--- a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S1128.json
+++ b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S1128.json
@@ -10,7 +10,7 @@
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
- "constantCost": "2min"
+ "constantCost": "1min"
},
"tags": [
"unused"
diff --git a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html
index fe52c6d68df..df8de8aa75c 100644
--- a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html
+++ b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4649.html
@@ -1,23 +1,45 @@
Why is this an issue?
+The font-family
(and the shorthand font
) CSS property specifies a prioritized list of one or more font family names
+and/or generic family names for the selected element.
If none of the font names defined in a font
or font-family
declaration are available on the browser of the user, the
browser will display the text using its default font. It’s recommended to always define a generic font family for each declaration of
-font
or font-family
to get a less degraded situation than relying on the default browser font. All browsers should implement
-a list of generic font matching these families: Serif
, Sans-serif
, cursive
, fantasy
,
-Monospace
.
-Noncompliant code example
-
+font
or font-family
to get a less degraded situation than relying on the default browser font. This lets the browser select
+an acceptable fallback font when necessary.
+The list of generic font families is as follows:
+
+ -
serif
: Glyphs have finishing strokes, flared or tapering ends, or actual serifed endings.
+ -
sans-serif
: Glyphs have plain stroke endings.
+ -
cursive
: Glyphs in cursive fonts generally have either joining strokes or other cursive characteristics beyond those of italic
+ typefaces.
+ -
fantasy
: Fantasy fonts are primarily decorative fonts that contain playful representations of characters.
+ -
monospace
: All glyphs have the same fixed width.
+ -
system-ui
: Glyphs are taken from the default user interface font on a given platform.
+ -
ui-serif
: The default user interface serif font.
+ -
ui-sans-serif
: The default user interface sans-serif font.
+ -
ui-monospace
: The default user interface monospace font.
+ -
ui-rounded
: The default user interface font that has rounded features.
+
+How to fix it
+You should always include at least one generic family name in a font-family
list, since there’s no guarantee that any given font is
+available.
+Code examples
+Noncompliant code example
+
a {
font-family: Helvetica, Arial, Verdana, Tahoma; /* Noncompliant; there is no generic font family in the list */
}
-Compliant solution
-
+Compliant solution
+
a {
font-family: Helvetica, Arial, Verdana, Tahoma, sans-serif;
}
Resources
+Documentation
diff --git a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html
index 6966d8f65e8..ea9cd78f470 100644
--- a/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html
+++ b/sonar-plugin/css/src/main/resources/org/sonar/l10n/css/rules/css/S4666.html
@@ -1,21 +1,39 @@
Why is this an issue?
-Duplication of selectors might indicate a copy-paste mistake. The rule detects the following kinds of duplications:
+In CSS, when selectors are duplicated, the browser applies them in cascade. This means that if two selectors are identical, the second one takes
+precedence. However, if the declarations within the selectors are not conflicting, they will be combined.
+This behavior can lead to unexpected results and make debugging more difficult, especially in larger stylesheets. Therefore, it’s generally
+recommended to avoid duplicating selectors.
+The rule detects the following kinds of duplications:
- - within a list of selectors in a single rule set
+ - within a list of selectors in a single rule set,
- for duplicated selectors in different rule sets within a single stylesheet.
-Noncompliant code example
-
-.foo, .bar, .foo { ... } /* Noncompliant */
+How to fix it
+To fix your code, either remove the duplicated selector or merge all declarations.
+Code examples
+Noncompliant code example
+
+p {
+ color: blue;
+ font-size: 16px;
+}
-.class1 { ... }
-.class1 { ... } /* Noncompliant */
+p { /* Noncompliant: duplicated selector 'p', overwrites property 'color' */
+ color: red;
+}
-Compliant solution
-
-.foo, .bar { ... }
-
-.class1 { ... }
-.class2 { ... }
+Compliant solution
+
+p {
+ color: red;
+ font-size: 16px;
+}
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S106.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S106.html
index 6a8733c0a94..d4c024db055 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S106.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S106.html
@@ -1,9 +1,39 @@
Why is this an issue?
-Debug statements are always useful during development. But include them in production code - particularly in code that runs client-side - and you
-run the risk of inadvertently exposing sensitive information, slowing down the browser, or even erroring-out the site for some users.
-Noncompliant code example
-
-console.log(password_entered); // Noncompliant
+In software development, logs serve as a record of events within an application, providing crucial insights for debugging. When logging, it is
+essential to ensure that the logs are:
+
+ - easily accessible
+ - uniformly formatted for readability
+ - properly recorded
+ - securely logged when dealing with sensitive data
+
+Those requirements are not met if a program directly writes to the standard outputs (e.g., console). That is why defining and using a dedicated
+logger is highly recommended.
+Code examples
+The following noncompliant code:
+
+function doSomething() {
+ // ...
+ console.log("My Message");
+ // ...
+}
+
+In Node.js
could be replaced by the winston
logging library:
+
+const winston = require("winston");
+
+const logger = winston.createLogger({
+ level: "debug",
+ format: winston.format.json(),
+ transports: [new winston.transports.Console()],
+});
+
+
+function doSomething() {
+ // ...
+ logger.info("My Message");
+ // ...
+}
Resources
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.html
index 8db78242257..4538480ff5b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.html
@@ -1,6 +1,8 @@
Why is this an issue?
-Merging collapsible if
statements increases the code’s readability.
-Noncompliant code example
+Nested code - blocks of code inside blocks of code - is eventually necessary, but increases complexity. This is why keeping the code as flat as
+possible, by avoiding unnecessary nesting, is considered a good practice.
+Merging if
statements when possible will decrease the nesting of the code and improve its readability.
+Code like
if (x != undefined) {
if (y === 2) {
@@ -8,10 +10,34 @@ Noncompliant code example
}
}
-Compliant solution
+Will be more readable as
if (x != undefined && y === 2) {
// ...
}
+How to fix it
+If merging the conditions seems to result in a more complex code, extracting the condition or part of it in a named function or variable is a
+better approach to fix readability.
+Code examples
+Noncompliant code example
+
+if (file != undefined) {
+ if (file.isFile() || file.isDirectory()) { // Noncompliant
+ /* ... */
+ }
+}
+
+Compliant solution
+
+function isFileOrDirectory(File file) {
+ return file.isFile() || file.isDirectory();
+}
+
+/* ... */
+
+if (file. != undefined && isFileOrDirectory(file)) { // Compliant
+ /* ... */
+}
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.json
index 1b7d6d25d59..76cf1bd3a0a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1066.json
@@ -1,5 +1,5 @@
{
- "title": "Collapsible \"if\" statements should be merged",
+ "title": "Mergeable \"if\" statements should be combined",
"type": "CODE_SMELL",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1068.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1068.html
index a260c8fb1b8..17bea7d71fd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1068.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1068.html
@@ -37,7 +37,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S109.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S109.html
index e4d159de50f..d999df8dabe 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S109.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S109.html
@@ -1,23 +1,26 @@
+A magic number is a hard-coded numerical value that may lack context or meaning. They should not be used because they can make the code less
+readable and maintainable.
Why is this an issue?
-A magic number is a number that comes out of nowhere, and is directly used in a statement. Magic numbers are often used, for instance to limit the
-number of iterations of a loop, to test the value of a property, etc.
-Using magic numbers may seem obvious and straightforward when you’re writing a piece of code, but they are much less obvious and straightforward at
-debugging time.
-That is why magic numbers must be demystified by first being assigned to clearly named variables before being used.
--1, 0 and 1 are not considered magic numbers.
-Noncompliant code example
-
+Magic numbers make the code more complex to understand as it requires the reader to have knowledge about the global context to understand the
+number itself. Their usage may seem obvious when writing the code, but it may not be the case for another developer or later once the context faded
+away. -1, 0, and 1 are not considered magic numbers.
+How to fix it
+Replacing them with a constant allows us to provide a meaningful name associated with the value. Instead of adding complexity to the code, it
+brings clarity and helps to understand the context and the global meaning.
+Code examples
+Noncompliant code example
+
function doSomething() {
- for (let i = 0; i < 4; i++) { // Noncompliant, 4 is a magic number
+ for (let i = 0; i < 4; i++) { // Noncompliant, 4 is a magic number
// ...
}
}
-Compliant solution
-
+Compliant solution
+
function doSomething() {
const numberOfCycles = 4;
- for (let i = 0; i < numberOfCycles; i++) {
+ for (let i = 0; i < numberOfCycles; i++) { // Compliant
// ...
}
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1110.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1110.html
index f89d470e540..db05834b76e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1110.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1110.html
@@ -1,25 +1,25 @@
This rule is deprecated, and will eventually be removed.
Why is this an issue?
-The use of parentheses, even those not required to enforce a desired order of operations, can clarify the intent behind a piece of code. But
-redundant pairs of parentheses could be misleading, and should be removed.
-Noncompliant code example
+Parentheses can disambiguate the order of operations in complex expressions and make the code easier to understand.
-let x = (y / 2 + 1); //Compliant even if those parenthesis are useless for the compiler
+a = (b * c) + (d * e); // Compliant: the intent is clear.
+
+Redundant parentheses are parenthesis that do not change the behavior of the code, and do not clarify the intent. They can mislead and complexify
+the code. They should be removed.
+Noncompliant code example
+
+let x = ((y / 2 + 1)); // Noncompliant
-if (a && ((x+y > 0))) { // Noncompliant
- //...
+if (a && ((x + y > 0))) { // Noncompliant
+ return ((x + 1)); // Noncompliant
}
-
-return ((x + 1)); // Noncompliant
Compliant solution
-
+
let x = (y / 2 + 1);
-if (a && (x+y > 0)) {
- //...
+if (a && (x + y > 0)) {
+ return (x + 1);
}
-
-return (x + 1);
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.html
index 86ae63e7f62..5ad1766a1d6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.html
@@ -1,4 +1,42 @@
Why is this an issue?
-Overriding or shadowing a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of
-code. Further, it could lead maintainers to introduce bugs because they think they’re using one variable but are really using another.
+Variable shadowing happens when a variable declared in a specific scope has the same name as a variable in an outer scope.
+This can lead to three main problems:
+
+ - Confusion: The same name can refer to different variables in different parts of the scope, making the code hard to read and understand.
+ - Unintended Behavior: You might accidentally use the wrong variable, leading to hard-to-detect bugs.
+ - Maintenance Issues: If the inner variable is removed or renamed, the code’s behavior might change unexpectedly because the outer variable is
+ now being used.
+
+To avoid these problems, rename the shadowing, shadowed, or both variables to accurately represent their purpose with unique and meaningful
+names.
+Note that functions in JavaScript are first-class citizens. This means that they possess the same attributes as variables, including the ability to
+shadow other variables and, conversely, be shadowed by them.
+Noncompliant code example
+The example below shows the typical situations in which shadowing can occur.
+
+function outer(items) {
+ var counter = 0;
+
+ function inner(items) { // Noncompliant: the parameter "items" is shadowed.
+ var counter = counter + 1; // Noncompliant: the outer "counter" is shadowed.
+ }
+
+ inner(items);
+
+ return counter; // returns 0
+}
+
+function search(items, match) { // Noncompliant: the function "match" (below) is shadowed.
+ // ...
+}
+
+function match(value, key) {
+ // ...
+}
+
+Resources
+Related rules
+
+ - {rule:javascript:S2814} - Variables and functions should not be redeclared
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.json
index cd14282b150..a7f4c497883 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1117.json
@@ -1,5 +1,4 @@
{
- "title": "Variables should not be shadowed",
"type": "CODE_SMELL",
"code": {
"impacts": {
@@ -21,6 +20,7 @@
"sqKey": "S1117",
"scope": "Main",
"quickfix": "unknown",
+ "title": "Variables should not be shadowed",
"compatibleLanguages": [
"JAVASCRIPT",
"TYPESCRIPT"
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1119.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1119.html
index 07eb48cb530..904cb0a1c55 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1119.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1119.html
@@ -23,8 +23,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1121.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1121.html
index 841f4589b15..95ee4e4f307 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1121.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1121.html
@@ -1,21 +1,10 @@
Why is this an issue?
-Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have
-side-effects.
-Moreover, using chained assignment in declarations is also dangerous because one may accidentally create global variables, e.g. in let x = y
-= 1;
, if y
is not declared, it will be hoisted as global.
-Noncompliant code example
-
-if (val = value() && check()) { // Noncompliant
- // ...
-}
-
-Compliant solution
-
-val = value();
-if (val && check()) {
- // ...
-}
-
+A common code smell that can hinder the clarity of source code is making assignments within sub-expressions. This practice involves assigning a
+value to a variable inside a larger expression, such as within a loop or a conditional statement.
+This practice essentially gives a side-effect to a larger expression, thus making it less readable. This often leads to confusion and potential
+errors.
+Moreover, using chained assignments in declarations is also dangerous because one may accidentally create global variables. Consider the following
+code snippet: let x = y = 1;
. If y
is not declared, it will be hoisted as global.
Exceptions
The rule does not raise issues for the following patterns:
@@ -26,6 +15,25 @@ Exceptions
- conditional assignment idiom:
a || (a = 0)
- assignments in (do-)while conditions:
while (a = 0);
+How to fix it
+Making assignments within sub-expressions can hinder the clarity of source code.
+This practice essentially gives a side-effect to a larger expression, thus making it less readable. This often leads to confusion and potential
+errors.
+Extracting assignments into separate statements is encouraged to keep the code clear and straightforward.
+Code examples
+Noncompliant code example
+
+if (val = value() && check()) { // Noncompliant
+ // ...
+}
+
+Compliant solution
+
+val = value();
+if (val && check()) {
+ // ...
+}
+
Resources
- MITRE, CWE-481 - Assigning instead of Comparing
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1125.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1125.html
index 8eaeb83dd3a..55b296bd327 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1125.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1125.html
@@ -1,11 +1,14 @@
Why is this an issue?
-Comparing a boolean literal to a variable or expression that evaluates to a boolean value is unnecessary and can make the code harder to read and
-understand. Therefore, boolean literals should be avoided in equality comparison expressions (==
, ===
, !=
, and
-!==
) to improve code readability and reduce unnecessary clutter.
-This rule also reports on redundant boolean operations.
+A boolean literal can be represented in two different ways: true
or false
. They can be combined with logical operators
+(!, &&, ||, ==, !=
) to produce logical expressions that represent truth values. However, comparing a boolean literal to a
+variable or expression that evaluates to a boolean value is unnecessary and can make the code harder to read and understand. The more complex a
+boolean expression is, the harder it will be for developers to understand its meaning and expected behavior, and it will favour the introduction of
+new bugs.
+How to tix it
+Remove redundant boolean literals from expressions to improve readability and make the code more maintainable.
-if (someValue === true) { /* ... */ } // Noncompliant: Redundant comparison
-if (someBooleanValue !== true) { /* ... */ } // Noncompliant: Redundant comparison
+if (someValue == true) { /* ... */ } // Noncompliant: Redundant comparison
+if (someBooleanValue != true) { /* ... */ } // Noncompliant: Redundant comparison
if (booleanMethod() || false) { /* ... */ } // Noncompliant: Redundant OR
doSomething(!false); // Noncompliant: Redundant negation
@@ -19,8 +22,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1126.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1126.html
index 0bf2f5bbc25..9c2dea00dd5 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1126.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1126.html
@@ -22,9 +22,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.html
index db273ec0b9a..bd746685064 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.html
@@ -19,7 +19,7 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.json
index db5174d5b2e..89667dbe5f7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1128.json
@@ -10,7 +10,7 @@
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
- "constantCost": "2min"
+ "constantCost": "1min"
},
"tags": [
"es2015",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1131.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1131.html
index 35cf6cbb7ad..e98d6ed178b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1131.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1131.html
@@ -1,10 +1,8 @@
This rule is deprecated, and will eventually be removed.
Why is this an issue?
-Trailing whitespaces are simply useless and should not stay in code. They may generate noise when comparing different versions of the same
-file.
-If you encounter issues from this rule, this probably means that you are not using an automated code formatter - which you should if you have the
-opportunity to do so.
-Noncompliant code example
+Trailing whitespaces bring no information, they may generate noise when comparing different versions of the same file, and they can create bugs
+when they appear after a \
marking a line continuation. They should be systematically removed.
+An automated code formatter allows to completely avoid this family of issues and should be used wherever possible.
// The following string will error if there is a whitespace after '\'
var str = "Hello \
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1135.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1135.html
index 603beb0815d..cc6d0f8331a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1135.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1135.html
@@ -1,5 +1,5 @@
Why is this an issue?
-Developers often use TOOO
tags to mark areas in the code where additional work or improvements are needed but are not implemented
+
Developers often use TODO
tags to mark areas in the code where additional work or improvements are needed but are not implemented
immediately. However, these TODO
tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This code smell
class aims to identify and address such unattended TODO
tags to ensure a clean and maintainable codebase. This description will explore
why this is a problem and how it can be fixed to improve the overall code quality.
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1143.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1143.html
index 7f7037e5336..7242d92da44 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1143.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1143.html
@@ -61,12 +61,13 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S117.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S117.html
index 2e86613ea30..922dd76e687 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S117.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S117.html
@@ -1,15 +1,52 @@
+Variables, properties, and parameters should be named consistently to communicate intent and improve maintainability. Rename your variable,
+property, or parameter to follow your project’s naming convention to address this issue.
Why is this an issue?
-Sharing some naming conventions is a key point to make it possible for a team to efficiently collaborate. This rule checks that all variable,
-property and parameter names match a provided regular expression.
-Noncompliant code example
+A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
Variables,
+properties, and parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily recognizable
+pattern.
Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to maintain and
+debug. It also ensures consistency in the code, especially when multiple developers are working on the same project.
+This rule checks that variable, property, and parameter names match a provided regular expression.
+What is the potential impact?
+Inconsistent naming of variables, properties, and parameters can lead to several issues in your code:
+
+ - Reduced Readability: inconsistent variable, property, and parameter names make the code harder to read and understand; consequently, it is more
+ difficult to identify the purpose of each variable, spot errors, or comprehend the logic.
+ - Difficulty in Identifying Variables: variables, properties, and parameters that don’t adhere to a standard naming convention are challenging to
+ identify; thus, the coding process slows down, especially when dealing with a large codebase.
+ - Increased Risk of Errors: inconsistent or unclear variable, property, and parameter names lead to misunderstandings about what the variable
+ represents. This ambiguity leads to incorrect assumptions and, consequently, bugs in the code.
+ - Collaboration Difficulties: in a team setting, inconsistent naming conventions lead to confusion and miscommunication among team members.
+ - Difficulty in Code Maintenance: inconsistent naming leads to an inconsistent codebase. The code is difficult to understand, and making changes
+ feels like refactoring constantly, as you face different naming methods. Ultimately, it makes the codebase harder to maintain.
+
+In summary, not adhering to a naming convention for variables, properties, and parameters can lead to confusion, errors, and inefficiencies, making
+the code harder to read, understand, and maintain.
+How to fix it
+First, familiarize yourself with the particular naming convention of the project in question. Then, update the name to match the convention, as
+well as all usages of the name. For many IDEs, you can use built-in renaming and refactoring features to update all usages at once.
+Code examples
+Noncompliant code example
With the default regular expression ^[_$A-Za-z][$A-Za-z0-9]*$|^[_$A-Z][_$A-Z0-9]+$
:
-
-const foo_bar = 1;
-const baz_ = 2;
+
+const foo_bar = 1; // Noncompliant
+const baz_ = 2; // Noncompliant
-Compliant solution
-
+Compliant solution
+
const fooBar = 1;
const _baz = 2;
+Resources
+Documentation
+
+Related rules
+
+ - {rule:javascript:S100} - Function and method names should comply with a naming convention
+ - {rule:javascript:S101} - Class names should comply with a naming convention
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1172.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1172.html
index 2c2161dd6a6..b77b3378ece 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1172.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1172.html
@@ -1,33 +1,40 @@
Why is this an issue?
-Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
-Noncompliant code example
+A typical code smell known as unused function parameters refers to parameters declared in a function but not used anywhere within the function’s
+body. While this might seem harmless at first glance, it can lead to confusion and potential errors in your code. Disregarding the values passed to
+such parameters, the function’s behavior will be the same, but the programmer’s intention won’t be clearly expressed anymore. Therefore, removing
+function parameters that are not being utilized is considered best practice.
+Exceptions
+When arguments
is used in the function body, no parameter is reported as unused.
-function doSomething(a, b) { // "a" is unused
- return compute(b);
+function doSomething(a, b, c) {
+ compute(arguments);
}
-Compliant solution
+The rule also ignores all parameters with names starting with an underscore (_
). This practice is often used to indicate that some
+parameter is intentionally unused. This practice is frequently seen in the TypeScript compiler, for example.
-function doSomething(b) {
+function doSomething(_a, b) {
return compute(b);
}
-or
-
-function doSomething(_a, b) {
+How to fix it
+Having unused function parameters in your code can lead to confusion and misunderstanding of a developer’s intention. They reduce code readability
+and introduce the potential for errors. To avoid these problems, developers should remove unused parameters from function declarations.
+Code examples
+Noncompliant code example
+
+function doSomething(a, b) { // "a" is unused
return compute(b);
}
-Exceptions
-When arguments
is used in the function body, no parameter is reported as unused.
-
-function doSomething(a, b, c) {
- compute(arguments);
+Compliant solution
+
+function doSomething(b) {
+ return compute(b);
}
-Also, the rule ignores all parameters whose name starts with an underscore (_
). This is a common practice to acknowledge the fact that
-some parameter is unused (e.g. in TypeScript compiler).
-
+or
+
function doSomething(_a, b) {
return compute(b);
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1186.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1186.html
index dd35a786173..bb43ec459ff 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1186.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1186.html
@@ -1,50 +1,56 @@
Why is this an issue?
-Empty functions can be a sign of poor code quality and can make the code harder to read and maintain. It usually happens when a developer forgets
-to add any statements to it, or when a function is no longer needed but is not removed from the codebase. In these cases when it is an unintentional
-omission, it should be fixed to prevent an unexpected behavior in production.
-
-function foo() { //Noncompliant: Function does not have any statement
-}
-
-Ensure that all functions contain meaningful statements. Otherwise, they should be removed.
-
-function foo() {
- do_something();
-}
-
-Throw an exception if it is done intentionally due to some functionality not being supported yet.
-
-function foo() {
- throw new Error("Not yet implemented");
-}
-
-Exceptions
+An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no
+functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.
+There are several reasons for a method not to have a body:
- - This rule does not apply to functions containing comments. The comment should explain the reason for the intention of the blank override.
+ - It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
+ - It is not yet, or never will be, supported. In this case an exception should be thrown.
+ - The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.
-
-function foo() {
- // This is intentional
-}
-
+Exceptions
+This does not raise an issue in the following cases:
- - This rule does not apply to function expressions and arrow functions as they can denote default values.
+ - Function expressions and arrow functions as they can denote default values
+ - Empty functions with a name starting with the prefix
on
like onClick
.
static defaultProps = {
listStyle: () => {}
};
-
-
- - The rule allows for empty functions with a name starting with the prefix
on
like onClick
.
-
-
+
function onClick() {
}
+How to fix it
+Code examples
+Noncompliant code example
+
+function shouldNotBeEmpty() { // Noncompliant - method is empty
+}
+
+function notImplemented() { // Noncompliant - method is empty
+}
+
+function emptyOnPurpose() { // Noncompliant - method is empty
+}
+
+Compliant solution
+
+function shouldNotBeEmpty() {
+ doSomething();
+}
+
+function notImplemented() {
+ throw new Error("notImplemented() cannot be performed because ...");
+}
+
+function emptyOnPurpose() {
+ // comment explaining why the method is empty
+}
+
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1192.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1192.html
index 3eaac9f6240..b0fe1ee2efc 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1192.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1192.html
@@ -1,8 +1,35 @@
Why is this an issue?
-Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
-On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
+Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all
+occurrences.
Exceptions
To prevent generating some false-positives, literals having less than 10 characters are excluded as well as literals matching /^\w*$/
.
String literals inside import/export statements and JSX attributes are also ignored. The same goes for statement-like string literals, e.g. 'use
strict';
.
+How to fix it
+Instead, use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a
+single place.
+Code examples
+Noncompliant code example
+With the default threshold of 3:
+
+function run() {
+ prepare("action_to_launch"); // Noncompliant - "action_to_launch" is duplicated 3 times
+ execute("action_to_launch");
+ release("action_to_launch");
+}
+
+function printInQuotes(a, b) {
+ console.log("'" + a + "'" + b + "'"); // Compliant - literal "'" has less than 10 characters and is excluded
+}
+
+Compliant solution
+
+var ACTION_1 = "action_to_launch";
+
+function run() {
+ prepare(ACTION_1); // Compliant
+ execute(ACTION_1);
+ release(ACTION_1);
+}
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1199.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1199.html
index 4e55aa6ad9b..c77f71c09b0 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1199.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1199.html
@@ -1,31 +1,9 @@
Why is this an issue?
Nested code blocks can be used to create a new scope: variables declared within that block cannot be accessed from the outside, and their lifetime
-end at the end of the block. However this only happens when you use ES6 let
or const
keywords, a class declaration or a
-function declaration (in strict mode). Otherwise the nested block is redundant and should be removed.
-The presense of redundant blocks (the ones which are not part of control flow and do not create a new scope) is confusing and may point to errors
-in the code.
-
-{ // Noncompliant: redundant code block
- var foo = bar();
-}
-
-if (condition) {
- doSomething();
- { // Noncompliant: redundant code block
- doOtherStuff();
- }
-}
-
-To fix your code remove redundant blocks.
-
-var foo = bar();
-
-if (condition) {
- doSomething();
- doOtherStuff();
-}
-
+end at the end of the block. However, this only happens when you use ES6 let
or const
keywords, a class declaration or a
+function declaration (in strict mode). Otherwise, the nested block is redundant and should be removed.
Exceptions
+The rule does not apply to the following cases:
+{ // Noncompliant: redundant code block
+ var foo = bar();
+}
+
+if (condition) {
+ doSomething();
+ { // Noncompliant: redundant code block
+ doOtherStuff();
+ }
+}
+
+Compliant solution
+
+var foo = bar();
+
+if (condition) {
+ doSomething();
+ doOtherStuff();
+}
+
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1226.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1226.html
index 56f19f5642b..7152148ebad 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1226.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1226.html
@@ -47,10 +47,11 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S125.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S125.html
index 86475f084cb..0d83de02ce7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S125.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S125.html
@@ -1,4 +1,5 @@
Why is this an issue?
-Programmers should not comment out code as it bloats programs and reduces readability.
-Unused code should be deleted and can be retrieved from source control history if required.
+Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never
+executed, it quickly becomes out of date and invalid.
+Commented-out code should be deleted and can be retrieved from source control history if required.
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1264.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1264.html
index 8296fb3a1ea..4988ebfc062 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1264.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1264.html
@@ -25,7 +25,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1301.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1301.html
index dfdeab6ac2f..ee7a70f1774 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1301.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1301.html
@@ -26,7 +26,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1314.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1314.html
index 36b07c1c5f9..bdc2c6c4e9e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1314.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1314.html
@@ -18,9 +18,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1321.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1321.html
index 1b8f9c79abf..80900a85d58 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1321.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1321.html
@@ -45,7 +45,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S134.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S134.html
index c06d9f96188..863d2c5e1dd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S134.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S134.html
@@ -1,24 +1,52 @@
Why is this an issue?
-Nested if
, for
, while
, switch
, and try
statements are key ingredients for making
-what’s known as "Spaghetti code".
-Such code is hard to read, refactor and therefore maintain.
-Noncompliant code example
-With the default threshold of 3:
-
- if (condition1) { // Compliant - depth = 1
+Nested control flow statements such as if
, for
, while
, switch
, and try
are often
+key ingredients in creating what’s known as "Spaghetti code". This code smell can make your program difficult to understand and maintain.
+When numerous control structures are placed inside one another, the code becomes a tangled, complex web. This significantly reduces the code’s
+readability and maintainability, and it also complicates the testing process.
+How to fix it
+Code examples
+The following example demonstrates the behavior of the rule with the default threshold of 3 levels of nesting and one of the potential ways to fix
+the code smell by introducing guard clauses:
+Noncompliant code example
+
+if (condition1) { // Compliant - depth = 1
+ /* ... */
+ if (condition2) { // Compliant - depth = 2
/* ... */
- if (condition2) { // Compliant - depth = 2
+ for (let i = 0; i < 10; i++) { // Compliant - depth = 3
/* ... */
- for(let i = 0; i < 10; i++) { // Compliant - depth = 3, not exceeding the limit
- /* ... */
- if (condition4) { // Non-Compliant - depth = 4
- if (condition5) { // Depth = 5, exceeding the limit, but issues are only reported on depth = 4
- /* ... */
- }
- return;
+ if (condition4) { // Noncompliant - depth = 4, which exceeds the limit
+ if (condition5) { // Depth = 5, exceeding the limit, but issues are only reported on depth = 4
+ /* ... */
}
+ return;
}
}
}
+}
+Compliant solution
+
+if (!condition1) {
+ return;
+}
+/* ... */
+if (!condition2) {
+ return;
+}
+for (let i = 0; i < 10; i++) {
+ /* ... */
+ if (condition4) {
+ if (condition5) {
+ /* ... */
+ }
+ return;
+ }
+}
+
+Resources
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1439.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1439.html
index ce80c059052..15b63c29126 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1439.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1439.html
@@ -35,7 +35,7 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1440.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1440.html
index 162c73cdf31..da2b201b573 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1440.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1440.html
@@ -1,20 +1,57 @@
Why is this an issue?
-The ==
and !=
operators do type coercion before comparing values. This is bad because it can mask type errors. For
-example, it evaluates ' \t\r\n' == 0
as true
.
-It is best to always use the side-effect-less ===
and !==
operators instead.
-Noncompliant code example
-
-if (var == 'howdy') {...} // Noncompliant
+In JavaScript, there are two types of comparison operators: strict and non-strict.
+
+ - Strict operators: These operators compare both value and type. They are represented as
===
(strict equality) and !==
+ (strict inequality). For example, 5 === "5"
would return false
because, although the values are the same, the types are
+ different (one is a number, the other is a string).
+ - Non-Strict operators: These operators compare only value, not type. They are represented as
==
(equality) and !=
+ (inequality). For example, 5 == "5"
would return true
because the values are the same, even though the types are
+ different.
+
+It’s generally recommended to use strict operators in JavaScript to avoid unexpected results due to JavaScript’s type coercion. This is because
+non-strict operators can lead to some counter-intuitive results. For example, 0 == false
would return true
, which might not
+be the expected outcome.
+
+function checkEqual(a, b) {
+ if (a == b) { // Noncompliant: using non-strict equality '=='
+ return "Equal";
+ } else {
+ return "Not equal";
+ }
+}
+
+console.log(checkEqual(0, false)); // Output: "Equal"
-Compliant solution
-
-if (var === 'howdy') {...}
+You should use the strict equality and inequality operators to prevent type coercion, avoid unexpected outcomes when comparing values of different
+types, and provide more predictable results.
+
+function checkEqual(a, b) {
+ if (a === b) {
+ return "Equal";
+ } else {
+ return "Not equal";
+ }
+}
+
+console.log(checkEqual(0, false)); // Output: "Not equal
Exceptions
-Even if testing the equality of a variable against null doesn’t do exactly what most JavaScript developers believe, usage of ==
or
-!=
is tolerated in such context. In the following case, if foo
hasn’t been initialized, its default value is not
-null
but undefined
. Nevertheless undefined == null
, so JavaScript developers get the expected behavior.
-
-if(foo == null) {...}
-
+The rule does not report on these cases:
+
+ - Comparing two literal values
+ - Evaluating the value of
typeof
+ - Comparing against
null
+
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1472.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1472.html
index c6421235171..6123151f6a8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1472.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1472.html
@@ -70,11 +70,12 @@ Why is this an issue?
Resouces
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1481.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1481.html
index a4d8ca9b3c4..7ddc4890bad 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1481.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1481.html
@@ -33,7 +33,7 @@ Memory leaks
How to fix it
Usually, the fix for this issue is straightforward, you just need to remove the unused variable declaration, or its name from the declaration
-statement if it’s declared along with other variables.
+statement if it is declared along with other variables.
Code examples
Noncompliant code example
@@ -60,9 +60,8 @@ Compliant solution
Resources
Documentation
Articles & blog posts
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1488.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1488.html
index f000f094f3f..941f62b89b2 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1488.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1488.html
@@ -1,40 +1,36 @@
Why is this an issue?
-Declaring a variable only to immediately return or throw it is a bad practice.
-Some developers argue that the practice improves code readability, because it enables them to explicitly name what is being returned. However, this
-variable is an internal implementation detail that is not exposed to the callers of the method. The method name should be sufficient for callers to
-know exactly what will be returned.
-Noncompliant code example
+Declaring a variable only to immediately return or throw it is considered a bad practice because it adds unnecessary complexity to the code. This
+practice can make the code harder to read and understand, as it introduces an extra step that doesn’t add any value. Instead of declaring a variable
+and then immediately returning or throwing it, it is generally better to return or throw the value directly. This makes the code cleaner, simpler, and
+easier to understand.
+How to fix it
+Declaring a variable only to immediately return or throw it is considered a bad practice because it adds unnecessary complexity to the code. To fix
+the issue, return or throw the value directly.
+Code examples
+Noncompliant code example
function computeDurationInMilliseconds(hours, minutes, seconds) {
- let duration = (((hours * 60) + minutes) * 60 + seconds ) * 1000;
+ const duration = (((hours * 60) + minutes) * 60 + seconds) * 1000;
return duration;
}
-Compliant solution
+Compliant solution
function computeDurationInMilliseconds(hours, minutes, seconds) {
- return (((hours * 60) + minutes) * 60 + seconds ) * 1000;
+ return (((hours * 60) + minutes) * 60 + seconds) * 1000;
}
-Noncompliant code example
+Noncompliant code example
-async function foo () {
- try {
- const result = await bar();
- return result;
- } catch (e) {
- handleError(e);
- }
+function doSomething() {
+ const myError = new Error();
+ throw myError;
}
-Compliant solution
+Compliant solution
-async function foo () {
- try {
- return await bar();
- } catch (e) {
- handleError(e);
- }
+function doSomething() {
+ throw new Error();
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1515.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1515.html
index 40bd2889542..21e80e8fd0c 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1515.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1515.html
@@ -35,7 +35,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1516.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1516.html
index 58ddc0a4e85..d237c9e38f9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1516.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1516.html
@@ -30,7 +30,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1527.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1527.html
index 4611b9e3259..60fd014837f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1527.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1527.html
@@ -34,9 +34,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1529.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1529.html
index f795006883b..a6a5beec7d6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1529.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1529.html
@@ -29,13 +29,15 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1533.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1533.html
index f28148cec0a..3d17d974739 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1533.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1533.html
@@ -27,12 +27,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1534.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1534.html
index 6592a35677b..ca7bfd4f355 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1534.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1534.html
@@ -40,7 +40,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1536.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1536.html
index 53320881584..18aa34023c9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1536.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1536.html
@@ -36,8 +36,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1763.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1763.html
index 67ac26d9844..4c0f537c142 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1763.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1763.html
@@ -21,11 +21,11 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1774.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1774.html
index d72f51bd87e..60a91e028ae 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1774.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1774.html
@@ -1,15 +1,17 @@
Why is this an issue?
-While the ternary operator is pleasingly compact, its use can make code more difficult to read. It should therefore be avoided in favor of the more
-verbose if
/else
structure.
-Noncompliant code example
-
+Ternary expressions, while concise, can often lead to code that is difficult to read and understand, especially when they are nested or complex.
+Prioritizing readability fosters maintainability and reduces the likelihood of bugs. Therefore, they should be removed in favor of more explicit
+control structures, such as if
/else
statements, to improve the clarity and readability of the code.
+Code examples
+Noncompliant code example
+
function foo(a) {
var b = (a === 'A') ? 'is A' : 'is not A'; // Noncompliant
// ...
}
-Compliant solution
-
+Compliant solution
+
function foo(a) {
var b;
if (a === 'A') {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1788.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1788.html
index 1f0be0a9abd..6c5eea3c780 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1788.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1788.html
@@ -34,7 +34,9 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1848.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1848.html
index 9124eb07f58..9e99b9ba697 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1848.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1848.html
@@ -28,9 +28,9 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.html
index 0a1776d6f57..1a015129ce2 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.html
@@ -1,34 +1,55 @@
Why is this an issue?
-A dead store happens when a local variable is assigned a value that is not read by any subsequent instruction. Calculating or retrieving a value
-only to then overwrite it or throw it away, could indicate a serious error in the code. Even if it’s not an error, it is at best a waste of resources.
-Therefore all calculated values should be used.
-Noncompliant code example
-
-i = a + b; // Noncompliant; calculation result not used before value is overwritten
-i = compute();
-
-Compliant solution
-
-i = a + b;
-i += compute();
-
+Dead stores refer to assignments made to local variables that are subsequently never used or immediately overwritten. Such assignments are
+unnecessary and don’t contribute to the functionality or clarity of the code. They may even negatively impact performance. Removing them enhances code
+cleanliness and readability. Even if the unnecessary operations do not do any harm in terms of the program’s correctness, they are - at best - a waste
+of computing resources.
Exceptions
+The rule ignores
- - This rule ignores initializations to -1, 0, 1,
undefined
, [], {}, true
, false
and ""
.
- - Variables that start with an underscore (e.g. '
_unused
') are ignored.
+ - Initializations to
-1
, 0
, 1
, undefined
, []
, {}
,
+ true
, false
and ""
.
+ - Variables that start with an underscore (e.g. '`_unused’) are ignored.
- Assignment of
null
is ignored because it is sometimes used to help garbage collection
- Increment and decrement expressions are ignored because they are often used idiomatically instead of
x+1
- - This rule also ignores variables declared with object destructuring using rest syntax (used to exclude some properties from object):
+ - This rule also ignores variables declared with object destructuring using rest syntax (used to exclude some properties from object)
-let {a, b, ...rest} = obj; // 'a' and 'b' are ok
+let {a, b, ...rest} = obj; // 'a' and 'b' are compliant
doSomething(rest);
-let [x1, x2, x3] = arr; // but 'x1' is noncompliant, as omitting syntax can be used: "let [, x2, x3] = arr;"
+let [x1, x2, x3] = arr; // 'x1' is noncompliant, as omitting syntax can be used: "let [, x2, x3] = arr;"
doSomething(x2, x3);
+How to fix it
+Remove the unnecesarry assignment, then test the code to make sure that the right-hand side of a given assignment had no side effects (e.g. a
+method that writes certain data to a file and returns the number of written bytes).
+Code examples
+Noncompliant code example
+
+function foo(y) {
+ let x = 100; // Noncompliant: dead store
+ x = 150; // Noncompliant: dead store
+ x = 200;
+ return x + y;
+}
+
+Compliant solution
+
+function foo(y) {
+ let x = 200; // Compliant: no unnecessary assignment
+ return x + y;
+}
+
Resources
+Standards
+
+Related rules
- - MITRE, CWE-563 - Assignment to Variable without Use ('Unused Variable')
+ - {rule:javascript:S1763} - All code should be reachable
+ - {rule:javascript:S2589} - Boolean expressions should not be gratuitous
+ - {rule:javascript:S3516} - Function returns should not be invariant
+ - {rule:javascript:S3626} - Jump statements should not be redundant
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.json
index 8de8c745793..49080ab361a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1854.json
@@ -10,7 +10,7 @@
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
- "constantCost": "15min"
+ "constantCost": "1min"
},
"tags": [
"cwe",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1862.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1862.html
index eadf180dd5f..d0b771dbb92 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1862.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1862.html
@@ -57,8 +57,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1874.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1874.html
index 3e01933bd33..b09ac640370 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1874.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1874.html
@@ -1,19 +1,28 @@
Why is this an issue?
-Once deprecated, classes, and interfaces, and their members should be avoided, rather than used, inherited or extended. Deprecation is a warning
-that the class or interface has been superseded, and will eventually be removed. The deprecation period allows you to make a smooth transition away
-from the aging, soon-to-be-retired technology.
-Noncompliant code example
+Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming
+element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a
+better solution has been identified, or when the existing code presents potential errors or security risks.
+Deprecation is a good practice because it helps to phase out obsolete code in a controlled manner, without breaking existing software that may
+still depend on it. It is a way to warn other developers not to use the deprecated element in new code, and to replace it in existing code when
+possible.
+Deprecated classes, interfaces, and their members should not be used, inherited or extended because they will eventually be removed. The
+deprecation period allows you to make a smooth transition away from the aging, soon-to-be-retired technology.
+Check the documentation or the deprecation message to understand why the code was deprecated and what the recommended alternative is.
-export interface LanguageService {
- /**
- * @deprecated Use getEncodedSyntacticClassifications instead.
- */
- getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
+/**
+ * @deprecated Use newFunction instead.
+ */
+function oldFunction() {
+ console.log("This is the old function.");
}
-const syntacticClassifications = getLanguageService().getSyntacticClassifications(file, span); // Noncompliant
+function newFunction() {
+ console.log("This is the new function.");
+}
+oldFunction(); // Noncompliant: "oldFunction is deprecated"
Resources
+Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2068.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2068.html
index 6525d22034a..93d324d004d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2068.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2068.html
@@ -58,7 +58,6 @@ See
MITRE, CWE-798 - Use of Hard-coded Credentials
MITRE, CWE-259 - Use of Hard-coded Password
- SANS Top 25 - Porous Defenses
Derived from FindSecBugs rule Hard Coded Password
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2077.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2077.html
index 45aa22e325f..63b7b089155 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2077.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2077.html
@@ -58,7 +58,6 @@ See
MITRE, CWE-20 - Improper Input Validation
MITRE, CWE-89 - Improper Neutralization of Special Elements used in an SQL Command
- SANS Top 25 - Insecure Interaction Between Components
Derived from FindSecBugs rules Potential SQL/JPQL Injection
(JPA), Potential SQL/JDOQL Injection (JDO), Potential SQL/HQL Injection (Hibernate)
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2092.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2092.html
index b334cc477c0..d80d252135f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2092.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2092.html
@@ -94,6 +94,5 @@ See
MITRE, CWE-311 - Missing Encryption of Sensitive Data
MITRE, CWE-315 - Cleartext Storage of Sensitive Information in a Cookie
MITRE, CWE-614 - Sensitive Cookie in HTTPS Session Without 'Secure' Attribute
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2137.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2137.html
index af9fcb9944e..04a98dd008d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2137.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2137.html
@@ -48,9 +48,11 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2189.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2189.html
index 97f563ac14e..ff9d0ae8e88 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2189.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2189.html
@@ -51,11 +51,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2201.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2201.html
index 8871505fda9..b6f7a539534 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2201.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2201.html
@@ -22,11 +22,11 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2208.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2208.html
index 2cb62608c7a..f8d906988f4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2208.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2208.html
@@ -1,9 +1,14 @@
Why is this an issue?
On the principle that clearer code is better code, you should explicitly import
the things you want to use in a module. Using
-import *
imports everything in the module, and runs the risk of confusing maintainers. Similarly, export * from "module";
-imports and then re-exports everything in the module, and runs the risk of confusing not just maintainers but also users of the module.
-Noncompliant code example
-
+import *
imports everything in the module and risks confusing maintainers. Similarly, export * from "module";
imports and
+then re-exports everything in the module and risks confusing not just maintainers but also the module’s users.
+Code examples
+Noncompliant code example
+
import * as Imported from "aModule"; // Noncompliant
+Compliant solution
+
+import {aType, aFunction} from "aModule";
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2234.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2234.html
index 6a882d18c68..ff304d073f4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2234.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2234.html
@@ -50,6 +50,6 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2251.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2251.html
index 11e7e2d239e..864b9d7876e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2251.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2251.html
@@ -18,7 +18,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2259.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2259.html
index 59a339b1cb5..2536cc45543 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2259.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2259.html
@@ -22,14 +22,16 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2310.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2310.html
index 2fea0fb38ec..5529a6fa1aa 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2310.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2310.html
@@ -37,8 +37,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2392.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2392.html
index 96897d7b5ed..51e52ec816b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2392.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2392.html
@@ -50,10 +50,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2432.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2432.html
index 75fa5579fd4..713a8bc81a7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2432.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2432.html
@@ -28,6 +28,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2589.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2589.html
index 5c85ecf5018..d8c68567bcf 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2589.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2589.html
@@ -1,16 +1,32 @@
+Gratuitous boolean expressions are conditions that do not change the evaluation of a program. This issue can indicate logical errors and affect the
+correctness of an application, as well as its maintainability.
Why is this an issue?
-If a boolean expression doesn’t change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous
-because it does not match the programmer’s intent, then it’s a bug and the expression should be fixed.
-Noncompliant code example
-
+Control flow constructs like if
-statements allow the programmer to direct the flow of a program depending on a boolean expression.
+However, if the condition is always true or always false, only one of the branches will ever be executed. In that case, the control flow construct and
+the condition no longer serve a purpose; they become gratuitous.
+What is the potential impact?
+The presence of gratuitous conditions can indicate a logical error. For example, the programmer intended to have the program branch into
+different paths but made a mistake when formulating the branching condition. In this case, this issue might result in a bug and thus affect the
+reliability of the application. For instance, it might lead to the computation of incorrect results.
+Additionally, gratuitous conditions and control flow constructs introduce unnecessary complexity. The source code becomes harder to understand, and
+thus, the application becomes more difficult to maintain.
+How to fix it
+Gratuitous boolean expressions are suspicious and should be carefully removed from the code.
+First, the boolean expression in question should be closely inspected for logical errors. If a mistake was made, it can be corrected so the
+condition is no longer gratuitous.
+If it becomes apparent that the condition is actually unnecessary, it can be removed. The associated control flow construct (e.g., the
+if
-statement containing the condition) will be adapted or even removed, leaving only the necessary branches.
+Code examples
+Noncompliant code example
+
if (a) {
if (a) { // Noncompliant
doSomething();
}
}
-Compliant solution
-
+Compliant solution
+
if (a) {
if (b) {
doSomething();
@@ -23,6 +39,7 @@ Compliant solution
}
Resources
+Articles & blog posts
- MITRE, CWE-571 - Expression is Always True
- MITRE, CWE-570 - Expression is Always False
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2612.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2612.html
index ad5bd2882d5..94fcb6b3363 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2612.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2612.html
@@ -88,6 +88,5 @@ See
href="https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management_Testing/09-Test_File_Permission">OWASP File Permission
- MITRE, CWE-732 - Incorrect Permission Assignment for Critical Resource
- MITRE, CWE-266 - Incorrect Privilege Assignment
- - SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2639.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2639.html
index 10d3deb3bfe..ea26d9e85c0 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2639.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2639.html
@@ -15,7 +15,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2685.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2685.html
index ba2dd9e58dc..cd0e0aaaa31 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2685.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2685.html
@@ -27,14 +27,15 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2688.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2688.html
index bf0b9e7660d..aa38557c614 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2688.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2688.html
@@ -46,10 +46,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2692.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2692.html
index 9ffd1946615..ad1544a0fcf 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2692.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2692.html
@@ -20,6 +20,9 @@ Why is this an issue?
This rule raises an issue when an indexOf
value retrieved from an array is tested against > 0
.
Resources
Documentation
-MDN -
-Array.prototype.includes()
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2699.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2699.html
index 150b0de42f4..1f35e949e86 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2699.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2699.html
@@ -33,7 +33,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2703.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2703.html
index 50c0e9ea2ef..390c3ea589b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2703.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2703.html
@@ -37,12 +37,13 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2737.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2737.html
index 7af8690d733..b05e73e0f43 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2737.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2737.html
@@ -24,7 +24,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2870.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2870.html
index 094f82fc449..3e846f4850b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2870.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2870.html
@@ -29,14 +29,19 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2871.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2871.html
index f508857683f..e1af3364934 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2871.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2871.html
@@ -34,11 +34,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.html
index d10e07f48f2..ae884658bf5 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.html
@@ -1,24 +1,33 @@
Why is this an issue?
-readonly
properties can only be assigned in a class constructor or at the point of declaration. If a class has a property that’s not
-marked readonly
but is only set in the constructor, it could cause confusion about the property’s intended use. To avoid confusion, such
-properties should be marked readonly
to make their intended use explicit, and to prevent future maintainers from inadvertently changing
-their use.
-Noncompliant code example
-
+readonly
fields can only be assigned in a class constructor. If a class has a field that’s not marked readonly
but is
+only set in the constructor, it could cause confusion about the field’s intended use. To avoid confusion, such fields should be marked
+readonly
to make their intended use explicit, and to prevent future maintainers from inadvertently changing their use.
+How to fix it
+Mark the given field with the readonly
modifier.
+Code examples
+Noncompliant code example
+
class Person {
- private _birthYear: number; // Noncompliant
+ private birthYear: number; // Noncompliant
+
constructor(birthYear: number) {
- this._birthYear = birthYear;
+ this.birthYear = birthYear;
}
}
-Compliant solution
-
+Compliant solution
+
class Person {
- private readonly _birthYear: number;
+ private readonly birthYear: number;
+
constructor(birthYear: number) {
- this._birthYear = birthYear;
+ this.birthYear = birthYear;
}
}
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.json
index e8e8730abb7..07dfd6635dd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2933.json
@@ -1,5 +1,5 @@
{
- "title": "Private properties that are only assigned in the constructor or at declaration should be \"readonly\"",
+ "title": "Fields that are only assigned in the constructor should be \"readonly\"",
"type": "CODE_SMELL",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2970.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2970.html
index 22d19e6d8fc..52c66294ca4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2970.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2970.html
@@ -54,7 +54,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2990.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2990.html
index 4e28a9ab466..61c9976b2e7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2990.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2990.html
@@ -55,18 +55,19 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2999.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2999.html
index d02c873bf15..6611c355746 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2999.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S2999.html
@@ -35,9 +35,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3001.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3001.html
index 529fe95e028..c831516ec96 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3001.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3001.html
@@ -39,10 +39,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3257.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3257.html
index 7b9117ae27c..a0bbae5cc7d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3257.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3257.html
@@ -1,9 +1,13 @@
Why is this an issue?
-Unnecessarily verbose declarations and initializations make it harder to read the code, and should be simplified. Specifically, primitive
-(number
, string
, boolean
and others) types should be omitted from variable and parameter declaration when they
-can be easily inferred from the initialized or defaulted value.
-Noncompliant code example
-
+TypeScript supports type inference, a mechanism that automatically infers the type of a variable based on its initial value. This means that if you
+initialize a variable with a particular value, TypeScript will assume that this variable should always hold that type of value.
+Unnecessarily verbose declarations and initializations make it harder to read the code and should be simplified. Therefore, type annotations should
+be omitted from variable and parameter declarations when they can be easily inferred from the initialized or defaulted value.
+How to fix it
+Omit explicit type annotations in declarations whenever the type can be inferred from the context.
+Code examples
+Noncompliant code example
+
const n: number = 1; // Noncompliant, "number" can be omitted
function foo(s: string = "") {} // Noncompliant, "string" can be omitted
@@ -12,8 +16,8 @@ Noncompliant code example
b: boolean = true; // Noncompliant, "boolean" can be omitted
}
-Compliant solution
-
+Compliant solution
+
const n = 1;
function foo(s = "") {}
@@ -22,4 +26,9 @@ Compliant solution
b = true;
}
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3330.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3330.html
index 5b4102f589b..c242387fda9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3330.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3330.html
@@ -94,7 +94,6 @@ See
OWASP Top 10 2017 Category A7 - Cross-Site
Scripting (XSS)
MITRE, CWE-1004 - Sensitive Cookie Without 'HttpOnly' Flag
- SANS Top 25 - Insecure Interaction Between Components
Derived from FindSecBugs rule HTTPONLY_COOKIE
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.html
index c7a01aa63e5..e800cc5eafa 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.html
@@ -1,39 +1,54 @@
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
-
+If a variable that is not supposed to change is not marked as const
, it could be accidentally reassigned elsewhere in the code,
+leading to unexpected behavior and bugs that can be hard to track down.
+By declaring a variable as const
, you ensure that its value remains constant throughout the code. It also signals to other developers
+that this value is intended to remain constant. This can make the code easier to understand and maintain.
+In some cases, using const
can lead to performance improvements. The compiler might be able to make optimizations knowing that the
+value of a const
variable will not change.
+How to fix it
+Mark the given variable with the const
modifier.
+Code examples
+Noncompliant code example
+
function seek(input) {
let target = 32; // Noncompliant
- for (let i of input) { // Noncompliant
- if (i == target) {
+ for (const i of input) {
+ if (i === target) {
return true;
}
}
return false;
}
-
-function getUrl(query) {
- let url; // Noncompliant
- url = "http://example.com";
- return url;
-}
-Compliant solution
-
+Compliant solution
+
function seek(input) {
const target = 32;
for (const i of input) {
- if (i == target) {
+ if (i === target) {
return true;
}
}
return false;
}
-
-function getUrl(query) {
- const url = "http://example.com";
+
+
+function getUrl(protocol, domain, path) {
+ let url; // Noncompliant
+ url = `${protocol}/${domain}/${path}`;
+ return url;
+}
+
+Compliant solution
+
+function getUrl(protocol, domain, path) {
+ const url = `${protocol}/${domain}/${path}`;
return url;
}
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.json
index d1affe70808..21ff1d26096 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3353.json
@@ -1,5 +1,5 @@
{
- "title": "Unchanged variables should be marked \"const\"",
+ "title": "Unchanged variables should be marked as \"const\"",
"type": "CODE_SMELL",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3415.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3415.html
index 2f92d7b0cef..edf253f3ec2 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3415.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3415.html
@@ -3,11 +3,19 @@ Why is this an issue?
the expected outcomes. By using assertions, developers can ensure that their code behaves as intended and identify potential bugs or issues early in
the development process.
The convention for passing assertion arguments is to pass the expected value as the first argument and the actual value as the second argument.
-This convention is based on the idea that the expected value is what the code is supposed to produce, and the actual value is what the code actually
-produces. By passing the expected value first, it is easier to understand the intent of the assertion and to quickly identify any errors that may be
-present. Additionally, many testing frameworks and libraries expect assertion arguments to be passed in this order, so following the convention can
-help ensure that your code works correctly with these tools.
-This rule raises an issue when the "expected" argument of an assertion function is a hard-coded value and the "actual" argument is not.
+This convention is based on the idea that the expected value is what the code is supposed to produce, and the actual value is what the code produces.
+By passing the expected value first, it is easier to understand the intent of the assertion and to quickly identify any errors that may be present.
+Additionally, many testing frameworks and libraries expect assertion arguments to be passed in this order, so following the convention can help ensure
+that your code works correctly with these tools.
+What is the potential impact?
+Having the expected value and the actual value in the wrong order will not alter the outcome of tests, (succeed/fail when it should) but the error
+messages will contain misleading information.
+This rule raises an issue when the actual argument to an assertions library method is a hard-coded value and the expected argument is not.
+How to fix it
+You should provide the assertion methods with a hard-coded value as the expected value, while the actual value of the assertion should derive from
+the portion of code that you want to test.
+Code examples
+Noncompliant code example
const assert = require('chai').assert;
const expect = require('chai').expect;
@@ -19,6 +27,7 @@ Why is this an issue?
should.fail(42, aNumber); // Noncompliant: actual value is passed as first argument and expected as second argument
});
+Compliant solution
Swap the order of the assertion arguments so that the expected value is passed as the first argument and the actual value is passed as the second
argument.
@@ -35,8 +44,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3498.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3498.html
index b15fce32b55..f5887dd16a8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3498.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3498.html
@@ -1,8 +1,11 @@
Why is this an issue?
-When an already-defined variable is given the same name within a new object, object-shorthand syntax is preferred as being more compact. Similarly,
-object-shorthand is also preferred for the definition of functions in object literals.
-Noncompliant code example
-
+In JavaScript, object shorthand syntax is a more concise way to define properties on objects. It was introduced to make object literals more
+readable and expressive.
+In the shorthand syntax, if a variable exists in the scope with the same name as the object key you’re defining, you can omit the key-value pair
+and just write the variable name. The interpreter will automatically understand that the key and the variable are linked.
+Using object shorthand syntax can make your code cleaner and easier to read. It can also reduce the chance of making errors, as you don’t have to
+repeat yourself by writing the variable name twice.
+
let a = 1;
let myObj = {
@@ -12,8 +15,9 @@ Noncompliant code example
}
}
-Compliant solution
-
+You can omit the property name and the colon if it is the same as the local variable name. Similarly, you can omit the function
+keyword for method definitions.
+
let a = 1;
let myObj = {
@@ -23,4 +27,16 @@ Compliant solution
}
}
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3500.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3500.html
index c2939c57fed..92c2ce7acdb 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3500.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3500.html
@@ -18,10 +18,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3504.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3504.html
index 41526d8f3b5..a1d4502af06 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3504.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3504.html
@@ -34,12 +34,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3516.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3516.html
index 61ce07a2334..72a8d573689 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3516.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3516.html
@@ -37,7 +37,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3524.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3524.html
index 7fd7208f0fa..b196e8e9989 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3524.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3524.html
@@ -1,15 +1,36 @@
Why is this an issue?
-Shared coding conventions allow teams to collaborate effectively. This rule raises an issue when the use of parentheses with an arrow function does
-not conform to the configured requirements.
-Noncompliant code example
-With the configured defaults forbidding parentheses
-
-var foo = (a) => { /* ... */ }; // Noncompliant; remove parens from arg
-var bar = (a, b) => { return 0; }; // Noncompliant; remove curly braces from body
+Arrow functions in JavaScript provide a concise syntax to write function expressions. However, the use of braces {}
and parentheses
+()
should be consistent in arrow functions for the following reasons:
+
+ - Readability: Consistent use of braces and parentheses improves the readability of the code. It makes it easier for other developers to
+ understand the code quickly and reduces the chances of misinterpretation.
+ - Predictability: When braces and parentheses are used consistently, it makes the code more predictable. Developers can easily predict the
+ outcome of the function.
+ - Avoid Errors: Inconsistent use of braces and parentheses can lead to errors. For example, if braces are omitted for a function that has more
+ than one statement, it will result in a syntax error.
+ - Code Maintenance: Consistent use of braces and parentheses makes the code easier to maintain. It’s easier to add or remove code lines without
+ worrying about adjusting braces or parentheses.
+
+Shared coding conventions allow teams to collaborate effectively. This rule raises an issue when using parentheses and curly braces with an arrow
+function does not conform to the configured requirements.
+How to fix it
+Code examples
+Use parentheses and curly braces with arrow functions consistently. By default, the rule forbids arrow functions to have parentheses around single
+parameters and curly braces around single-return bodies.
+Noncompliant code example
+
+const foo = (a) => { /* ... */ }; // Noncompliant; remove the parentheses from the parameter
+const bar = (a, b) => { return 0; }; // Noncompliant; remove the curly braces from the body
-Compliant solution
-
-var foo = a => { /* ... */ };
-var bar = (a, b) => 0;
+Compliant solution
+
+const foo = a => { /* ... */ };
+const bar = (a, b) => 0;
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3531.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3531.html
index 27864ba8095..f4e9f3355a1 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3531.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3531.html
@@ -37,7 +37,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3579.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3579.html
index f501916e41a..cdfdb42977f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3579.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3579.html
@@ -30,8 +30,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3616.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3616.html
index d981e5db4bc..724de31d217 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3616.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3616.html
@@ -54,9 +54,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3626.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3626.html
index bc2b7d048ea..17249ea82ed 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3626.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3626.html
@@ -29,8 +29,8 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3686.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3686.html
index a9d6b37a0a8..b2dfa40a4e3 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3686.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3686.html
@@ -36,6 +36,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3696.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3696.html
index 88fbcdf3c15..b61d2b91fc4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3696.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3696.html
@@ -18,7 +18,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3699.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3699.html
index c347f47e25b..1a6a08abf02 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3699.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3699.html
@@ -26,8 +26,9 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3735.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3735.html
index c63504e0ec0..886b48053a1 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3735.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3735.html
@@ -47,8 +47,9 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3776.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3776.html
index be9d04d0c5a..554d55e3fe4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3776.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3776.html
@@ -6,4 +6,9 @@ Documentation
+Articles & blog posts
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3782.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3782.html
index e76923b597a..4f69790d127 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3782.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3782.html
@@ -16,7 +16,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3785.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3785.html
index 2c640d170d4..b57b7495d9e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3785.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3785.html
@@ -20,11 +20,13 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3796.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3796.html
index d12c02eacd4..3413b690cce 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3796.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3796.html
@@ -53,6 +53,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3799.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3799.html
index f282168b31d..beb288b7198 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3799.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3799.html
@@ -27,7 +27,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3800.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3800.html
index 29658b6bb18..ac320ca5723 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3800.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3800.html
@@ -37,6 +37,6 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3812.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3812.html
index 2e2fc34906e..c0e2d075531 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3812.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3812.html
@@ -29,11 +29,14 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3834.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3834.html
index 83bd162cb78..c5efb2ef25f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3834.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3834.html
@@ -20,8 +20,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3854.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3854.html
index 34fdc3df677..9684b47d81d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3854.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3854.html
@@ -34,9 +34,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3863.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3863.html
index d417d79d26f..c8b71a0ad15 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3863.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3863.html
@@ -14,7 +14,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3984.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3984.html
index 35b5b7a7130..cae243bc98e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3984.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S3984.html
@@ -16,9 +16,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4030.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4030.html
index f1e252bb6bf..be14f02d028 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4030.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4030.html
@@ -23,7 +23,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4043.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4043.html
index 25fce65d98e..bf01c2045c0 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4043.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4043.html
@@ -30,17 +30,20 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4123.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4123.html
index 1c3520e4f99..168bcc18d1e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4123.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4123.html
@@ -21,9 +21,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4124.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4124.html
index 8a519109deb..0d4b0feda1d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4124.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4124.html
@@ -34,9 +34,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4125.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4125.html
index 7b8684692a7..6ce4833eb2e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4125.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4125.html
@@ -25,7 +25,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4138.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4138.html
index 64d8ef8d551..6ecde80236e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4138.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4138.html
@@ -25,8 +25,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4140.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4140.html
index 02ca9f3cc06..d4df1ca2941 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4140.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4140.html
@@ -20,6 +20,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4156.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4156.html
index f96f55432c5..3216c457d09 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4156.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4156.html
@@ -24,8 +24,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4158.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4158.html
index 6e737c27083..3af32dc58fc 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4158.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4158.html
@@ -25,8 +25,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4204.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4204.html
index a45ab3283d7..4f0e2787071 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4204.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4204.html
@@ -1,20 +1,38 @@
Why is this an issue?
-Variables can be declared with or without types. Variables declared without a type will be implicitly typed if the declaration includes an
-initialization, and the compiler then type-checks every usage of typed variables. On the other hand, a variable declared with the any
-type explicitly instructs the compiler not to do any type-checking, which is risky.
-The unknown
type should be preferred over the any
type if it’s not possible to have a better typing. any
-fully disables type-checking allowing to do anything with the variable, while unknown
requires to narrow the type before doing something
-specific.
-Noncompliant code example
-
-let a = 42; // implicitly typed to number
-let b: number = 42; // explicitly typed to number
-let c: any = 42; // Noncompliant
+In TypeScript, any
is a type that is used when the type of a variable is unknown or could be of any type. It allows you to opt-out of
+type-checking and let the values pass through compile-time checks. In other words, it prevents the compiler from reporting type errors, which can lead
+to runtime errors.
+On the other hand, unknown
is a type-safe alternative to any
. It forces you to perform certain checks before performing
+operations on variables of type unknown
. This means you can’t accidentally perform arbitrary operations on variables of type
+unknown
, which helps prevent runtime errors.
+It’s generally recommended to avoid using any
when possible, and instead use more specific types or generics for better type safety.
+If you want to maintain type safety, it’s better to use unknown
instead of any
.
+
+function logValue(value: any) { // Noncompliant: 'value' is not type-checked
+ console.log(value);
+}
+
+logValue(123);
+logValue('Hello');
-Compliant solution
-
-let a = 42;
-let b: number = 42;
-let c: number = 42;
+You should use unknown
instead of any
and narrow it down with type guards.
+
+function logValue(value: unknown) {
+ if (typeof value === 'number') {
+ console.log(value.toFixed(2));
+ } else if (typeof value === 'string') {
+ console.log(value.trim());
+ }
+}
+
+logValue(123);
+logValue('Hello');
+Resources
+Documentation
+
+ - TypeScript Documentation -
unknown
+ - TypeScript Documentation -
any
+ - TypeScript Documentation - Narrowing
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4275.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4275.html
index 3481cb89d2e..2789c3651b7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4275.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4275.html
@@ -90,8 +90,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4323.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4323.html
index 1bfcf4e815c..3f2e4c9594d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4323.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4323.html
@@ -46,8 +46,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4325.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4325.html
index c4310b07e54..88231afd6b6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4325.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4325.html
@@ -45,8 +45,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4335.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4335.html
index 19a91805b46..a8eb5d8e9c9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4335.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4335.html
@@ -35,12 +35,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4423.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4423.html
index 723ca13ab88..5415b9ec004 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4423.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4423.html
@@ -209,6 +209,5 @@ Standards
OWASP Top 10 2017 Category A6 - Security
Misconfiguration
MITRE, CWE-327 - Use of a Broken or Risky Cryptographic Algorithm
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4502.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4502.html
index 7d890222755..b3504f1738b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4502.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4502.html
@@ -73,6 +73,5 @@ See
OWASP Top 10 2017 Category A6 - Security
Misconfiguration
OWASP: Cross-Site Request Forgery
- SANS Top 25 - Insecure Interaction Between Components
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4524.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4524.html
index 9bc56850c0c..ce159f1f28b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4524.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4524.html
@@ -20,6 +20,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4619.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4619.html
index a630cdbee3d..417f7aaecbf 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4619.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4619.html
@@ -31,9 +31,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4621.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4621.html
index c492c6f4a40..95b6fbd46a5 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4621.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4621.html
@@ -33,6 +33,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4622.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4622.html
index d2822c07ef6..a7806fbdb8f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4622.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4622.html
@@ -32,6 +32,6 @@ Exceptions
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4623.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4623.html
index b4e4a1fcce8..94e90b89504 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4623.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4623.html
@@ -35,6 +35,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4624.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4624.html
index 8a49529681f..8077912ab60 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4624.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4624.html
@@ -31,7 +31,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4634.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4634.html
index ec4749c0c70..86a7e43afea 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4634.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4634.html
@@ -76,11 +76,13 @@ How to fix it
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4721.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4721.html
index b4d3d2e655b..4e78bc6320f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4721.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4721.html
@@ -31,6 +31,5 @@ See
OWASP Top 10 2021 Category A3 - Injection
OWASP Top 10 2017 Category A1 - Injection
MITRE, CWE-78 - Improper Neutralization of Special Elements used in an OS Command
- SANS Top 25 - Insecure Interaction Between Components
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4782.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4782.html
index debf17b00c0..f94c3708369 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4782.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4782.html
@@ -43,7 +43,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4787.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4787.html
index f56032a3e1b..bcf8beeb5c6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4787.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4787.html
@@ -82,6 +82,5 @@ See
MITRE, CWE-325 - Missing Required Cryptographic Step
MITRE, CWE-326 - Inadequate Encryption Strength
MITRE, CWE-327 - Use of a Broken or Risky Cryptographic Algorithm
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4790.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4790.html
index 361b90e63d2..04af48b547f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4790.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4790.html
@@ -38,6 +38,5 @@ See
OWASP Mobile Top 10 2016 Category M5 -
Insufficient Cryptography
MITRE, CWE-1240 - Use of a Risky Cryptographic Primitive
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4818.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4818.html
index fa16f7009f4..b54c45b4650 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4818.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4818.html
@@ -47,7 +47,5 @@ See
MITRE, CWE-20 - Improper Input Validation
MITRE, CWE-400 - Uncontrolled Resource Consumption ('Resource Exhaustion')
MITRE, CWE-200 - Exposure of Sensitive Information to an Unauthorized Actor
- SANS Top 25 - Risky Resource Management
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4822.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4822.html
index cd5c88d2ee0..275820fb242 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4822.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4822.html
@@ -20,9 +20,9 @@ Why is this an issue?
runPromiseThatRejects().catch(e => console.log("Failed to run promise", e));
}
-Alternatively, wait for the Promise fulfillment value using await
. await
is used to unwrap promises. await
-pauses the execution of its surrounding async
function until the promise is settled (that is, fulfilled or rejected). Any errors that
-occur within the Promise will be thrown as exceptions.
+Alternatively, wait for the Promise fulfillment value using await
. It is used to unwrap promises and pauses the execution of its
+surrounding async
function until the promise is settled (that is, fulfilled or rejected). Any errors that occur within the Promise will
+be thrown as exceptions.
async function foo() {
try {
@@ -37,11 +37,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4823.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4823.html
index c965164359e..dbe196e137b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4823.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S4823.html
@@ -32,6 +32,5 @@ See
OWASP Top 10 2017 Category A1 - Injection
MITRE, CWE-88 - Argument Injection or Modification
MITRE, CWE-214 - Information Exposure Through Process Environment
- SANS Top 25 - Insecure Interaction Between Components
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5122.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5122.html
index 5c673c5b2d1..3cdfbafca70 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5122.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5122.html
@@ -97,6 +97,5 @@ See
Cheat Sheet - Cross Origin Resource Sharing
MITRE, CWE-346 - Origin Validation Error
MITRE, CWE-942 - Overly Permissive Cross-domain Whitelist
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5542.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5542.html
index 22142bab5dd..2ebb997ce1a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5542.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5542.html
@@ -79,6 +79,5 @@ Standards
OWASP Top 10 2017 Category A6 - Security
Misconfiguration
MITRE, CWE-327 - Use of a Broken or Risky Cryptographic Algorithm
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5547.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5547.html
index c1675cd82b1..098c1154d73 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5547.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5547.html
@@ -50,6 +50,5 @@ Standards
OWASP Top 10 2017 Category A3 - Sensitive Data
Exposure
MITRE, CWE-327 - Use of a Broken or Risky Cryptographic Algorithm
- SANS Top 25 - Porous Defenses
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5693.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5693.html
index bd9a781d8b9..01a9d0b8b48 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5693.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5693.html
@@ -1,5 +1,5 @@
Rejecting requests with significant content length is a good practice to control the network traffic intensity and thus resource consumption in
-order to prevents DoS attacks.
+order to prevent DoS attacks.
Ask Yourself Whether
- size limits are not defined for the different resources of the web application.
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5843.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5843.html
index 96a348fbddb..af2d43dcc82 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5843.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5843.html
@@ -39,17 +39,18 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5850.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5850.html
index 69e4e680dcc..392c236e755 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5850.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5850.html
@@ -30,11 +30,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5860.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5860.html
index 129e4fee4a2..f6c831a9518 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5860.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5860.html
@@ -48,8 +48,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5863.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5863.html
index ef2ced94d6e..bb58d9341c3 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5863.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5863.html
@@ -34,6 +34,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5876.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5876.html
index 8401f37ab81..6ef30a6d5ac 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5876.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5876.html
@@ -76,7 +76,7 @@ How does this work?
Resources
Documentation
Articles & blog posts
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5958.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5958.html
index ed1a2d32679..be44f40701d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5958.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5958.html
@@ -73,8 +73,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6079.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6079.html
index 8d1a1789784..c8734c5ee26 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6079.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6079.html
@@ -41,6 +41,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6080.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6080.html
index ac0cabfa17d..49f6ca85be9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6080.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6080.html
@@ -30,8 +30,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6092.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6092.html
index aacfaf02f94..bc002173282 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6092.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6092.html
@@ -113,15 +113,15 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6324.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6324.html
index a92dd585e35..02f6f0b5f06 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6324.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6324.html
@@ -13,8 +13,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6325.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6325.html
index 825bf34a2d2..f337708e082 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6325.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6325.html
@@ -22,7 +22,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6328.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6328.html
index f01ea145554..f349ea39b65 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6328.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6328.html
@@ -39,12 +39,13 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6351.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6351.html
index d4130e5e642..877f81cc9fd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6351.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6351.html
@@ -53,11 +53,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6353.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6353.html
index 6ec59f306e0..264f51204c8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6353.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6353.html
@@ -1,7 +1,14 @@
Why is this an issue?
-With regular expressions syntax, it’s possible to express the same thing in many ways. For example, to match a two-digit number, one could write
-[0-9]{2,2}
or \d{2}
. Latter is not only shorter in terms of expression length, but also easier to read and thus to maintain.
-This rule recommends to replace some bulky quantifiers and character classes with more concise equivalents:
+A regular expression is a sequence of characters that specifies a match pattern in text. Among the most important concepts are:
+
+ - Character classes: defines a set of characters, any one of which can occur in an input string for a match to succeed.
+ - Quantifiers: used to specify how many instances of a character, group, or character class must be present in the input for a match.
+ - Wildcard (
.
): matches all characters except line terminators (also matches them if the s
flag is set).
+
+Many of these features include shortcuts of widely used expressions, so there is more than one way to construct a regular expression to achieve the
+same results. For example, to match a two-digit number, one could write [0-9]{2,2}
or \d{2}
. The latter is not only shorter
+but easier to read and thus to maintain.
+This rule recommends replacing some quantifiers and character classes with more concise equivalents:
-
\d
for [0-9]
and \D
for [^0-9]
-
\w
for [A-Za-z0-9_]
and \W
for [^A-Za-z0-9_]
@@ -10,13 +17,12 @@ Why is this an issue?
-
x?
for x{0,1}
, x*
for x{0,}
, x+
for x{1,}
, x{N}
for
x{N,N}
-Noncompliant code example
-
-/a{1,}/; // Noncompliant, '{1,}' quantifier is the same as '+'
+
+/a{1,}/; // Noncompliant, '{1,}' quantifier is the same as '+'
/[A-Za-z0-9_]/; // Noncompliant, '\w' is equivalent
-Compliant solution
-
+Use the more concise version to make the regex expression more readable.
+
/a+/;
/\w/;
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6426.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6426.html
index 9585c589c40..a8e885d5129 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6426.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6426.html
@@ -20,8 +20,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6435.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6435.html
index 55838a0822b..aca61a06838 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6435.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6435.html
@@ -33,7 +33,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6438.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6438.html
index 511a734608e..ffe94862f86 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6438.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6438.html
@@ -34,6 +34,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6439.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6439.html
index 6b9fe34446a..ad612f94b8f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6439.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6439.html
@@ -38,6 +38,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6440.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6440.html
index 2e821a65897..c25f9f36896 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6440.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6440.html
@@ -37,7 +37,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6441.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6441.html
index a577f4240f6..c1f4c868267 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6441.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6441.html
@@ -30,8 +30,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6442.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6442.html
index c6ca39c14dc..d99f5553f06 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6442.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6442.html
@@ -37,8 +37,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6443.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6443.html
index b19fb4d9713..33438bb1742 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6443.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6443.html
@@ -39,8 +39,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6477.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6477.html
index b615a05fdcb..ac415a01592 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6477.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6477.html
@@ -35,10 +35,10 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6479.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6479.html
index 61f5472ccde..68aced62d4d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6479.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6479.html
@@ -33,10 +33,10 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6481.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6481.html
index bf0e9bd3122..effd10e2342 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6481.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6481.html
@@ -27,9 +27,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6486.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6486.html
index 616ac12bdbe..5711d318786 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6486.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6486.html
@@ -35,10 +35,10 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6509.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6509.html
index 7b09a89db11..a7642b48a76 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6509.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6509.html
@@ -24,11 +24,11 @@ Why is this an issue?
Resources
Documentation
Articles & blog posts
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6522.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6522.html
index 022d4b21827..66a6e7eb914 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6522.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6522.html
@@ -48,11 +48,12 @@ Default imports
moduleDefault.newAttribute = 'hello world!'; // module.default now contains newAttribute and can be seen from all other modules importing it
Resources
+Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6523.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6523.html
index 983d7d3aacf..0344521264a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6523.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6523.html
@@ -33,11 +33,12 @@ How to fix it
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6534.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6534.html
index 625887e5a4c..88c9e71fcf4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6534.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6534.html
@@ -62,10 +62,10 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6535.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6535.html
index 5f025e57060..edf2334468b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6535.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6535.html
@@ -22,8 +22,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6544.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6544.html
index d1e9884bcc8..e1de30b9a83 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6544.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6544.html
@@ -109,9 +109,9 @@ How does this work?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6550.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6550.html
index 4f66a1a1cb0..f9ba5b6f6ae 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6550.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6550.html
@@ -38,6 +38,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6551.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6551.html
index e67f95c9f02..6a627cd1b91 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6551.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6551.html
@@ -49,7 +49,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6557.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6557.html
index daffa41738d..b5667208205 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6557.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6557.html
@@ -45,7 +45,9 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6565.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6565.html
index ae9763c3ab6..2c1ad6773e7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6565.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6565.html
@@ -101,7 +101,7 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6568.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6568.html
index a4c2da3b829..3bccc815d64 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6568.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6568.html
@@ -34,7 +34,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6569.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6569.html
index dc1e2c4e2bc..d644255150b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6569.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6569.html
@@ -23,7 +23,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6571.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6571.html
index 0de92248292..c742ad966a6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6571.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6571.html
@@ -38,7 +38,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6572.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6572.html
index db361841abd..b4ad7089db4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6572.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6572.html
@@ -52,6 +52,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6578.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6578.html
index ab0b85c87b2..e0ce935bbae 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6578.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6578.html
@@ -22,6 +22,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6582.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6582.html
index 9af7e3b1e9f..7227916e207 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6582.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6582.html
@@ -26,6 +26,7 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6583.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6583.html
index b2f1b6390a5..40279b027dd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6583.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6583.html
@@ -40,6 +40,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6590.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6590.html
index 6a3e3d549ba..dd190a8aa6f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6590.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6590.html
@@ -37,6 +37,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6594.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6594.html
index d9ea47deb38..1a37a3d4272 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6594.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6594.html
@@ -14,9 +14,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6598.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6598.html
index 32b96feb908..685fbd035cd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6598.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6598.html
@@ -33,7 +33,7 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6635.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6635.html
index 06fc2d758e2..a3bca3b4199 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6635.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6635.html
@@ -35,6 +35,6 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6637.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6637.html
index 647c88e9f02..5f57affce7b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6637.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6637.html
@@ -30,7 +30,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6643.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6643.html
index da349081a0f..30f62190da0 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6643.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6643.html
@@ -12,8 +12,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6644.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6644.html
index 9370bcf52d8..e41b99703e8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6644.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6644.html
@@ -17,8 +17,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6645.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6645.html
index c9b433fd52c..74a660a04c4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6645.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6645.html
@@ -8,9 +8,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6647.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6647.html
index 14b751a09b9..3f60a842724 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6647.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6647.html
@@ -21,6 +21,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6650.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6650.html
index 4d190425181..d026bf5d97a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6650.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6650.html
@@ -15,9 +15,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6653.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6653.html
index a52262aa1c1..138ef88c1cf 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6653.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6653.html
@@ -19,8 +19,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6654.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6654.html
index 8767a695217..c6e8047aa28 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6654.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6654.html
@@ -20,12 +20,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6657.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6657.html
index 701c17380d1..e562780251f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6657.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6657.html
@@ -12,8 +12,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6660.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6660.html
index a2514a23577..53bf3be4055 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6660.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6660.html
@@ -43,6 +43,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6661.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6661.html
index fc9f72292a4..c24e2838fe2 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6661.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6661.html
@@ -19,9 +19,10 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6666.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6666.html
index 74eff2545ef..2edbb601490 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6666.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6666.html
@@ -15,8 +15,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6671.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6671.html
index 467f9449261..e05554a092b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6671.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6671.html
@@ -27,8 +27,8 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6676.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6676.html
index 0e05bf7ae1d..464e260ec89 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6676.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6676.html
@@ -38,12 +38,12 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6679.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6679.html
index dce05046095..87457ad9f7a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6679.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6679.html
@@ -38,11 +38,11 @@ Why is this an issue?
Resources
Documentation
Related rules
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.html
index 75fdee0d41f..af00e7aaae1 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.html
@@ -62,7 +62,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.json
index a4a4d4913e1..aaf256fcf9f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6746.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "MEDIUM",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.html
index cc1adeba3c2..1175f55d430 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.html
@@ -34,11 +34,11 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.json
index 92089113d93..9f685727aad 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6747.json
@@ -16,11 +16,10 @@
"quickfix": "covered",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.html
index 085d2f6eaaa..1e23786e1c8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.html
@@ -20,6 +20,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.json
index d248f56d93a..ed4fdd6a6bc 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6748.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "MEDIUM",
+ "RELIABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.html
index 605f595c65a..03d7e4877da 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.html
@@ -14,6 +14,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.json
index ce0c37b7819..13ca797011c 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6749.json
@@ -16,11 +16,9 @@
"quickfix": "covered",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "DISTINCT"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.html
index cb2946b28c0..9a8ee8495e1 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.html
@@ -18,7 +18,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.json
index 3804730846e..5461c2561de 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6750.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.html
index ec59eff0014..bbe5450e17a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.html
@@ -31,6 +31,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.json
index 469987731d5..b2d9dcab4e3 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6754.json
@@ -14,11 +14,9 @@
"quickfix": "covered",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "IDENTIFIABLE"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.html
index 4e0d9bb1163..c892f6c5fdd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.html
@@ -19,7 +19,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.json
index 6b84f35843d..8df22668aff 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6756.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "MEDIUM",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.html
index aae3a919c74..27ab27cc538 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.html
@@ -32,8 +32,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.json
index 81e4b79fc45..15747a6c53c 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6757.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.html
index b129878664a..affc4ca1cb4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.html
@@ -39,8 +39,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.json
index f33510235f2..6a107fdd4be 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6759.json
@@ -16,9 +16,7 @@
"quickfix": "covered",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
},
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.html
index ebf9823fd56..724e0c6ca79 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.html
@@ -23,8 +23,8 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.json
index 82c244b99c3..9dd2b51546a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6761.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "DISTINCT"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.html
index f221ecab43a..e1bb441f5b4 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.html
@@ -35,7 +35,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.json
index 2e74b301d12..b1811e7a3fd 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6763.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "MEDIUM",
+ "RELIABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "EFFICIENT"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.html
index 52f6a8d5a4d..baa2da661b9 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.html
@@ -29,7 +29,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.json
index 7d0790bd37f..dad92b14aa6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6766.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.html
index 4a2863df876..e06781bd939 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.html
@@ -74,8 +74,8 @@ Compliant solution
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.json
index 231070b73a5..a7ebfe91244 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6767.json
@@ -16,9 +16,7 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
},
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.html
index e593eec2064..75e3d79746c 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.html
@@ -14,6 +14,6 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.json
index e2357376be6..81bf54f7fce 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6770.json
@@ -16,11 +16,9 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "IDENTIFIABLE"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.html
index 48900fbea9c..30158709d6e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.html
@@ -32,9 +32,9 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.json
index d0965e9cc80..c5392d2a755 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6772.json
@@ -16,11 +16,10 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "LOW"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "FORMATTED"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.html
index 7ba464efbef..28151602c66 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.html
@@ -4,6 +4,9 @@ Why is this an issue?
By defining types for component props, developers can enforce type safety and provide clear documentation for the expected props of a component.
This helps catch potential errors at compile-time. It also improves code maintainability by making it easier to understand how components should be
used and what props they accept.
+How to fix it
+Code examples
+Noncompliant code example
import PropTypes from 'prop-types';
@@ -25,6 +28,7 @@ Why is this an issue?
firstname: PropTypes.string.isRequired,
};
+Compliant solution
import PropTypes from 'prop-types';
@@ -51,7 +55,7 @@ Why is this an issue?
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.json
index 4d2970850ca..6e77d34086a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6774.json
@@ -16,9 +16,8 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW",
+ "RELIABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
},
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.html
index a2a1c754fcb..b9c9ac87195 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.html
@@ -70,9 +70,9 @@ How to fix it in TypeScript
Resources
Documentation
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.json
index e0f224e8a9e..5695703f7de 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6775.json
@@ -16,9 +16,7 @@
"quickfix": "infeasible",
"code": {
"impacts": {
- "MAINTAINABILITY": "HIGH",
- "RELIABILITY": "MEDIUM",
- "SECURITY": "LOW"
+ "MAINTAINABILITY": "LOW"
},
"attribute": "CONVENTIONAL"
},
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.html
index 25c017f54f2..a0521d83870 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.html
@@ -1,30 +1,26 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.
-Each role in ARIA has a set of required attributes that must be included for the role to be properly understood by assistive technologies. These
-attributes are known as "required aria-* properties".
-For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox
-is checked (true), unchecked (false), or in a mixed state (mixed).
-This rules checks that each element with a defined ARIA role also has all required attributes.
+This rule checks that the values of ARIA attributes "aria-*" in DOM elements are valid.
How to fix it in JSX
-Check that each element with a defined ARIA role also has all required attributes.
+Check that each element with a defined ARIA attribute has a valid value.
-<div role="checkbox">Unchecked</div> {/* Noncompliant: aria-checked is missing */}
+<span aria-hidden="ok">foo</span>
-To fix the code add missing aria-* attributes.
+To fix the code use a valid value for the aria-* attribute.
-<div role="checkbox" aria-checked={isChecked}>Unchecked</div>
+<span aria-hidden="true">foo</span>
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.json
index 5dce940e59c..7e0ecb9d2f0 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6793.json
@@ -8,13 +8,12 @@
},
"tags": [
"react",
- "a11y"
+ "accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6793",
"sqKey": "S6793",
"scope": "All",
- "defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.html
index 25c017f54f2..304dd7cba71 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.html
@@ -5,7 +5,7 @@ Why is this an issue?
attributes are known as "required aria-* properties".
For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox
is checked (true), unchecked (false), or in a mixed state (mixed).
-This rules checks that each element with a defined ARIA role also has all required attributes.
+This rule checks that each element with a defined ARIA role also has all required attributes.
How to fix it in JSX
Check that each element with a defined ARIA role also has all required attributes.
@@ -18,13 +18,14 @@ How to fix it in JSX
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.json
index 80a1d8120cf..cb04c5fd45e 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6807.json
@@ -7,7 +7,7 @@
"constantCost": "5min"
},
"tags": [
- "a11y",
+ "accessibility",
"react"
],
"defaultSeverity": "Major",
@@ -22,8 +22,8 @@
},
"attribute": "CONVENTIONAL"
},
- "compatibleLanguages": [
- "JAVASCRIPT",
- "TYPESCRIPT"
- ]
+ "compatibleLanguages": [
+ "JAVASCRIPT",
+ "TYPESCRIPT"
+ ]
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.html
index a7f29b54ed2..cb70fc6a5af 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.html
@@ -19,13 +19,14 @@ How to fix it in JSX
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.json
index cf05e808262..07341f73209 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6811.json
@@ -7,7 +7,7 @@
"constantCost": "5min"
},
"tags": [
- "a11y",
+ "accessibility",
"react"
],
"defaultSeverity": "Major",
@@ -22,8 +22,8 @@
},
"attribute": "CONVENTIONAL"
},
- "compatibleLanguages": [
- "JAVASCRIPT",
- "TYPESCRIPT"
- ]
+ "compatibleLanguages": [
+ "JAVASCRIPT",
+ "TYPESCRIPT"
+ ]
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.html
index f1bf75579bb..661cdc09d36 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.html
@@ -1,9 +1,9 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) roles are used to make web content and web applications more accessible to people with disabilities.
-However, you should not use ARIA role on a generic element (like span
or div
) if there is a semantic HTML tag with similar
-functionality, just use that tag instead.
-For example, instead of using a div element with a role of button (<div role="button">Click me</div>
), you should just use
-a button element (<button>Click me</button>
).
+However, you should not use an ARIA role on a generic element (like span
or div
) if there is a semantic HTML tag with
+similar functionality, just use that tag instead.
+For example, instead of using a div element with a button role (<div role="button">Click me</div>
), you should just use a
+button element (<button>Click me</button>
).
Semantic HTML tags are generally preferred over ARIA roles for accessibility due to their built-in functionality, universal support by browsers and
assistive technologies, simplicity, and maintainability. They come with inherent behaviors and keyboard interactions, reducing the need for additional
JavaScript. Semantic HTML also enhances SEO by helping search engines better understand the content and structure of web pages. While ARIA roles are
@@ -13,7 +13,7 @@
How to fix it in JSX
Code examples
Noncompliant code example
-<div role="button" tabindex="0" onClick={handleClick}>Click me</div>
+<div role="button" onClick={handleClick}>Click me</div>
Compliant solution
@@ -22,12 +22,12 @@ Compliant solution
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.json
index d9ca4850f1c..607d20b7616 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6819.json
@@ -7,7 +7,7 @@
"constantCost": "5min"
},
"tags": [
- "a11y",
+ "accessibility",
"react"
],
"defaultSeverity": "Major",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.html
index 25c017f54f2..b47026920f8 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.html
@@ -1,30 +1,30 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.
-Each role in ARIA has a set of required attributes that must be included for the role to be properly understood by assistive technologies. These
-attributes are known as "required aria-* properties".
-For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox
-is checked (true), unchecked (false), or in a mixed state (mixed).
-This rules checks that each element with a defined ARIA role also has all required attributes.
+This rule checks that when using the role
property in DOM elements, its value is a valid non-abstract ARIA role.
+This rule does not cover non-DOM elements, such as custom components.
How to fix it in JSX
-Check that each element with a defined ARIA role also has all required attributes.
+Check that each element with a defined ARIA role has a valid non-abstract value.
-<div role="checkbox">Unchecked</div> {/* Noncompliant: aria-checked is missing */}
+<div role="meth" aria-label="a^{2} + b^{2} = c^{2}">
+ a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>
+</div>
-To fix the code add missing aria-* attributes.
+To fix the code use a valid value for the ARIA role attribute.
-<div role="checkbox" aria-checked={isChecked}>Unchecked</div>
+<div role="math" aria-label="a^{2} + b^{2} = c^{2}">
+ a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup>
+</div>
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.json
index 9b5d5b90a23..92115881a3a 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6821.json
@@ -8,13 +8,12 @@
},
"tags": [
"react",
- "a11y"
+ "accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6821",
"sqKey": "S6821",
"scope": "All",
- "defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.html
index e013f1c1578..1a52f9c205d 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.html
@@ -20,12 +20,12 @@ Compliant solution
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.json
index 813fe29bb86..50c13f347c6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6822.json
@@ -7,14 +7,14 @@
"constantCost": "5min"
},
"tags": [
- "a11y",
+ "accessibility",
"react"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6822",
"sqKey": "S6822",
"scope": "All",
- "quickfix": "infeasible",
+ "quickfix": "targeted",
"code": {
"impacts": {
"MAINTAINABILITY": "LOW",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.html
index 25c017f54f2..a83d561e508 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.html
@@ -1,30 +1,41 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.
-Each role in ARIA has a set of required attributes that must be included for the role to be properly understood by assistive technologies. These
-attributes are known as "required aria-* properties".
-For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox
-is checked (true), unchecked (false), or in a mixed state (mixed).
-This rules checks that each element with a defined ARIA role also has all required attributes.
+The aria-activedescendant
attribute is used to enhance the accessibility of composite widgets by managing focus within them. It allows
+a parent element to retain active document focus while indicating which of its child elements has secondary focus. This attribute is particularly
+useful in interactive components like search typeahead select lists, where the user can navigate through a list of options while continuing to type in
+the input field.
+This rule checks that DOM elements with the aria-activedescendant
property either have an inherent tabIndex or declare one.
How to fix it in JSX
-Check that each element with a defined ARIA role also has all required attributes.
+Make sure that DOM elements with the aria-activedescendant
property have a tabIndex
property, or use an element with an
+inherent one.
+Code examples
+Noncompliant code example
-<div role="checkbox">Unchecked</div> {/* Noncompliant: aria-checked is missing */}
+<div aria-activedescendant={descendantId}>
+ {content}
+</div>
-To fix the code add missing aria-* attributes.
+Compliant solution
-<div role="checkbox" aria-checked={isChecked}>Unchecked</div>
+<div aria-activedescendant={descendantId} tabIndex={0}>
+ {content}
+</div>
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.json
index 95a0d3a0a19..26ae58a31bc 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6823.json
@@ -1,5 +1,5 @@
{
- "title": "DOM elements with the `aria-activedescendant` property must be tabbable",
+ "title": "DOM elements with the `aria-activedescendant` property should be accessible via the tab key",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
@@ -8,19 +8,18 @@
},
"tags": [
"react",
- "a11y"
+ "accessibility"
],
"defaultSeverity": "Minor",
"ruleSpecification": "RSPEC-6823",
"sqKey": "S6823",
"scope": "All",
- "defaultQualityProfiles": ["Sonar way"],
"quickfix": "targeted",
"code": {
"impacts": {
"RELIABILITY": "MEDIUM"
},
- "attribute": "CONVENTIONAL"
+ "attribute": "LOGICAL"
},
"compatibleLanguages": [
"JAVASCRIPT",
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.html
index 25c017f54f2..4bdd2b6e514 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.html
@@ -1,30 +1,26 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) attributes are used to enhance the accessibility of web content and web applications. These attributes
provide additional information about an element’s role, state, properties, and values to assistive technologies like screen readers.
-Each role in ARIA has a set of required attributes that must be included for the role to be properly understood by assistive technologies. These
-attributes are known as "required aria-* properties".
-For example, if an element has a role of "checkbox", it must also include the aria-checked property. This property indicates whether the checkbox
-is checked (true), unchecked (false), or in a mixed state (mixed).
-This rules checks that each element with a defined ARIA role also has all required attributes.
+This rule checks that ARIA roles or aria-*
attributes are not used in unsupported DOM elements, which are mostly invisible such as
+meta
, html
or head
.
How to fix it in JSX
-Check that each element with a defined ARIA role also has all required attributes.
+Check if you are using ARIA roles or aria-*
attributes in unsupported DOM elements.
-<div role="checkbox">Unchecked</div> {/* Noncompliant: aria-checked is missing */}
+<title aria-hidden="false">My beautiful web page</title>
-To fix the code add missing aria-* attributes.
+To fix the code, remove the extra ARIA role or aria-*
attributes from the unsupported DOM elements.
-<div role="checkbox" aria-checked={isChecked}>Unchecked</div>
+<title>My beautiful web page</title>
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.json
index e0b8c4da2c9..eb316a539d7 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6824.json
@@ -8,13 +8,12 @@
},
"tags": [
"react",
- "a11y"
+ "accessibility"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6824",
"sqKey": "S6824",
"scope": "All",
- "defaultQualityProfiles": ["Sonar way"],
"quickfix": "targeted",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.html
index 35a5a50e684..1fc358afdd1 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.html
@@ -1,19 +1,19 @@
Why is this an issue?
ARIA (Accessible Rich Internet Applications) is a set of attributes that define ways to make web content and web applications more accessible to
-people with disabilities. The 'aria-hidden' attribute is used to indicate that an element and all of its descendants are not visible or perceivable to
-any user as implemented by assistive technologies.
-However, when 'aria-hidden' is used on a focusable element, it can create a confusing and inaccessible experience for screen reader users. This is
-because the element will still be included in the tab order, so a screen reader user can navigate to it, but it will not be announced by the screen
-reader due to the 'aria-hidden' attribute.
-This rule ensures that focusable elements are not hidden from screen readers using the 'aria-hidden' attribute.
+people with disabilities. The aria-hidden
attribute is used to indicate that an element and all of its descendants are not visible or
+perceivable to any user as implemented by assistive technologies.
+However, when aria-hidden
is used on a focusable element, it can create a confusing and inaccessible experience for screen reader
+users. This is because the element will still be included in the tab order, so a screen reader user can navigate to it, but it will not be announced
+by the screen reader due to the aria-hidden
attribute.
+This rule ensures that focusable elements are not hidden from screen readers using the aria-hidden
attribute.
How to fix it
-Check if the element is focusable. Focusable elements should not have 'aria-hidden' attribute.
+Check if the element is focusable. Focusable elements should not have aria-hidden
attribute.
Code examples
Noncompliant code example
<button aria-hidden="true">Click me</button>
-Remove 'aria-hidden' attribute.
+Remove aria-hidden
attribute.
Compliant solution
<button>Click me</button>
@@ -21,13 +21,13 @@ Compliant solution
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.json
index def288517d5..444bf58272f 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6825.json
@@ -7,7 +7,7 @@
"constantCost": "5min"
},
"tags": [
- "a11y",
+ "accessibility",
"react"
],
"defaultSeverity": "Major",
@@ -21,8 +21,8 @@
},
"attribute": "CONVENTIONAL"
},
- "compatibleLanguages": [
- "JAVASCRIPT",
- "TYPESCRIPT"
- ]
+ "compatibleLanguages": [
+ "JAVASCRIPT",
+ "TYPESCRIPT"
+ ]
}
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.html
index 35a5a50e684..f16a9c62d73 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.html
@@ -1,33 +1,32 @@
Why is this an issue?
-ARIA (Accessible Rich Internet Applications) is a set of attributes that define ways to make web content and web applications more accessible to
-people with disabilities. The 'aria-hidden' attribute is used to indicate that an element and all of its descendants are not visible or perceivable to
-any user as implemented by assistive technologies.
-However, when 'aria-hidden' is used on a focusable element, it can create a confusing and inaccessible experience for screen reader users. This is
-because the element will still be included in the tab order, so a screen reader user can navigate to it, but it will not be announced by the screen
-reader due to the 'aria-hidden' attribute.
-This rule ensures that focusable elements are not hidden from screen readers using the 'aria-hidden' attribute.
-How to fix it
-Check if the element is focusable. Focusable elements should not have 'aria-hidden' attribute.
+Anchors, represented by the a
tag in HTML, usually contain a hyperlink that users can click to navigate to different sections of a
+website or different websites altogether.
+However, when anchors do not have content or when the content is hidden from screen readers using the aria-hidden
property, it creates
+a significant accessibility issue. If an anchor’s content is hidden or non-existent, visually impaired users may not be able to understand the purpose
+of the anchor or navigate the website effectively.
+This rule checks that anchors do not use the aria-hidden
property and have content provided either between the tags or as
+aria-label
or title
property.
+How to fix it in JSX
+Ensure that anchors either have content or an aria-label
or title
attribute, and they should not use the
+aria-hidden
property.
Code examples
Noncompliant code example
-<button aria-hidden="true">Click me</button>
+<a aria-hidden>link to my site</a>
-Remove 'aria-hidden' attribute.
Compliant solution
-<button>Click me</button>
+<a>link to my site</a>
Resources
Documentation
Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.json b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.json
index f2d80f5cf68..5c56a9e1a80 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.json
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S6827.json
@@ -14,7 +14,6 @@
"ruleSpecification": "RSPEC-6827",
"sqKey": "S6827",
"scope": "All",
- "defaultQualityProfiles": ["Sonar way"],
"quickfix": "infeasible",
"code": {
"impacts": {
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S878.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S878.html
index 1fdcb178570..ef037c8232c 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S878.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S878.html
@@ -1,24 +1,32 @@
Why is this an issue?
-The comma operator takes two expressions, executes them from left to right and returns the result of the second one. Use of this operator is
+
The comma operator takes two expressions, executes them from left to right, and returns the result of the second one. The use of this operator is
generally detrimental to the readability and reliability of code, and the same effect can be achieved by other means.
-Noncompliant code example
-i = a += 2, a + b; // What's the value of i ?
+i = a += 2, a + b; // Noncompliant: What's the value of i ?
-Compliant solution
+Writing each expression on its own line will improve readability and might fix misunderstandings.
-a += 2;
-i = a + b;
+a += 2;
+i = a + b; // We probably expected to assign the result of the addition to i, although the previous code wasn't doing it.
Exceptions
-Use of comma operator is tolerated:
+The comma operator is tolerated:
- - in initialization and increment expressions of
for
loops.
+ - In initializations and increment expressions of
for
loops.
-for(i = 0, j = 5; i < 6; i++, j++) { ... }
+for (i = 0, j = 5; i < 6; i++, j++) { ... }
- If the expression sequence is explicitly wrapped in parentheses.
+
+i = (a += 2, a + b); // Compliant by exception
+
+Resources
+Documentation
+
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S905.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S905.html
index 9e47a428c68..9c61f6ee4c6 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S905.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S905.html
@@ -1,3 +1,5 @@
+Statements with no side effects and no change of control flow do not contribute to the functionality of the code and can indicate a programming
+error.
Why is this an issue?
When writing code, it is important to ensure that each statement serves a purpose and contributes to the overall functionality of the program. When
they have no side effects or do not change the control flow, they can either indicate a programming error or be redundant:
@@ -7,18 +9,42 @@ Why is this an issue?
The statements are residual after a refactoring.
Exceptions
-The rule does not raise an issue:
-
- - Statements containing only a semicolon (
;
)
-
-Noncompliant code example
-
-a == 1; // Noncompliant; was assignment intended?
+The rule does not raise an issue on statements containing only a semicolon (;
).
+How to fix it
+Identify statements that do not contribute to the functionality of the code and verify if they are intended to be part of the logic. If they are,
+there is a bug to be fixed. If they are not, then they are redundant and should be removed.
+Code examples
+Noncompliant code example
+
+function getResult() {
+ let result = 42;
+ if (shouldBeZero()) {
+ result == 0; // Noncompliant: no side effect, was an assignment intended?
+ }
+ return result;
+}
+
+
var msg = "Hello, "
"World!"; // Noncompliant; have we forgotten '+' operator on previous line?
+Compliant solution
+
+function getResult() {
+ let result = 42;
+ if (shouldBeZero()) {
+ result = 0; // Compliant
+ }
+ return result;
+}
+
+
+var msg = "Hello, " +
+ "World!"; // Compliant
+
Resources
+Standards
diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S930.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S930.html
index aca6c861b16..3bd78f83e5b 100644
--- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S930.html
+++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S930.html
@@ -53,10 +53,10 @@ Exceptions
Resources
Documentation
diff --git a/sonarpedia.json b/sonarpedia.json
index b12a817bdd2..d534221375e 100644
--- a/sonarpedia.json
+++ b/sonarpedia.json
@@ -3,7 +3,7 @@
"languages": [
"JS"
],
- "latest-update": "2023-09-22T12:30:07.391291Z",
+ "latest-update": "2023-10-20T14:01:03.080659Z",
"options": {
"no-language-in-filenames": true,
"preserve-filenames": true