From 42659d297db1920888a076e80ecf5f2b8544a0a5 Mon Sep 17 00:00:00 2001 From: zglicz Date: Thu, 28 Mar 2024 14:05:24 +0100 Subject: [PATCH] Update for release (#4644) --- README.md | 2 +- css-sonarpedia/sonarpedia.json | 2 +- .../javascript/rules/javascript/S106.html | 8 +-- .../javascript/rules/javascript/S107.html | 2 +- .../javascript/rules/javascript/S1121.html | 2 +- .../javascript/rules/javascript/S1125.html | 2 +- .../javascript/rules/javascript/S1126.html | 2 +- .../javascript/rules/javascript/S1134.html | 2 +- .../javascript/rules/javascript/S1135.html | 12 ++-- .../javascript/rules/javascript/S117.html | 20 ++++--- .../javascript/rules/javascript/S1192.html | 4 +- .../javascript/rules/javascript/S128.html | 2 +- .../javascript/rules/javascript/S131.html | 2 +- .../javascript/rules/javascript/S1313.html | 6 +- .../javascript/rules/javascript/S1442.html | 6 +- .../javascript/rules/javascript/S1444.html | 7 ++- .../javascript/rules/javascript/S1523.html | 8 +-- .../javascript/rules/javascript/S1525.html | 6 +- .../javascript/rules/javascript/S1854.html | 2 +- .../javascript/rules/javascript/S1874.html | 2 +- .../javascript/rules/javascript/S2068.html | 10 ++-- .../javascript/rules/javascript/S2077.html | 9 ++- .../javascript/rules/javascript/S2092.html | 14 ++--- .../javascript/rules/javascript/S2245.html | 20 +++---- .../javascript/rules/javascript/S2255.html | 8 +-- .../javascript/rules/javascript/S2486.html | 10 ++-- .../javascript/rules/javascript/S2589.html | 4 +- .../javascript/rules/javascript/S2598.html | 6 +- .../javascript/rules/javascript/S2612.html | 10 ++-- .../javascript/rules/javascript/S2681.html | 2 +- .../javascript/rules/javascript/S2755.html | 10 ++-- .../javascript/rules/javascript/S2817.html | 8 +-- .../javascript/rules/javascript/S2819.html | 6 +- .../javascript/rules/javascript/S2819.json | 3 +- .../javascript/rules/javascript/S3271.html | 4 +- .../javascript/rules/javascript/S3330.html | 8 +-- .../javascript/rules/javascript/S3523.html | 2 +- .../javascript/rules/javascript/S3735.html | 2 +- .../javascript/rules/javascript/S3776.html | 20 +++++-- .../javascript/rules/javascript/S3923.html | 2 +- .../javascript/rules/javascript/S4036.html | 10 ++-- .../javascript/rules/javascript/S4323.html | 7 +++ .../javascript/rules/javascript/S4423.html | 12 ++-- .../javascript/rules/javascript/S4426.html | 55 +++++++++++++------ .../javascript/rules/javascript/S4502.html | 8 +-- .../javascript/rules/javascript/S4507.html | 10 ++-- .../javascript/rules/javascript/S4721.html | 6 +- .../javascript/rules/javascript/S4784.html | 6 +- .../javascript/rules/javascript/S4787.html | 22 ++++---- .../javascript/rules/javascript/S4790.html | 20 +++---- .../javascript/rules/javascript/S4817.html | 4 +- .../javascript/rules/javascript/S4818.html | 10 ++-- .../javascript/rules/javascript/S4823.html | 6 +- .../javascript/rules/javascript/S4829.html | 2 +- .../javascript/rules/javascript/S4830.html | 35 ++++++------ .../javascript/rules/javascript/S5042.html | 11 ++-- .../javascript/rules/javascript/S5122.html | 14 ++--- .../javascript/rules/javascript/S5148.html | 8 +-- .../javascript/rules/javascript/S5247.html | 10 ++-- .../javascript/rules/javascript/S5332.html | 18 +++--- .../javascript/rules/javascript/S5443.html | 12 ++-- .../javascript/rules/javascript/S5527.html | 26 ++++----- .../javascript/rules/javascript/S5542.html | 23 +++++--- .../javascript/rules/javascript/S5547.html | 10 ++-- .../javascript/rules/javascript/S5604.html | 10 ++-- .../javascript/rules/javascript/S5659.html | 8 +-- .../javascript/rules/javascript/S5689.html | 8 +-- .../javascript/rules/javascript/S5691.html | 8 +-- .../javascript/rules/javascript/S5693.html | 10 ++-- .../javascript/rules/javascript/S5725.html | 10 ++-- .../javascript/rules/javascript/S5728.html | 6 +- .../javascript/rules/javascript/S5730.html | 6 +- .../javascript/rules/javascript/S5732.html | 10 ++-- .../javascript/rules/javascript/S5734.html | 6 +- .../javascript/rules/javascript/S5736.html | 8 +-- .../javascript/rules/javascript/S5739.html | 6 +- .../javascript/rules/javascript/S5742.html | 6 +- .../javascript/rules/javascript/S5743.html | 6 +- .../javascript/rules/javascript/S5757.html | 10 ++-- .../javascript/rules/javascript/S5759.html | 6 +- .../javascript/rules/javascript/S5852.html | 6 +- .../javascript/rules/javascript/S5876.html | 10 ++-- .../javascript/rules/javascript/S6245.html | 7 --- .../javascript/rules/javascript/S6249.html | 8 +-- .../javascript/rules/javascript/S6252.html | 3 - .../javascript/rules/javascript/S6265.html | 7 +-- .../javascript/rules/javascript/S6268.html | 10 ++-- .../javascript/rules/javascript/S6270.html | 7 +-- .../javascript/rules/javascript/S6275.html | 8 +-- .../javascript/rules/javascript/S6281.html | 6 +- .../javascript/rules/javascript/S6299.html | 10 ++-- .../javascript/rules/javascript/S6302.html | 7 +-- .../javascript/rules/javascript/S6303.html | 2 +- .../javascript/rules/javascript/S6304.html | 7 +-- .../javascript/rules/javascript/S6308.html | 9 +-- .../javascript/rules/javascript/S6317.html | 5 +- .../javascript/rules/javascript/S6319.html | 9 +-- .../javascript/rules/javascript/S6321.html | 5 +- .../javascript/rules/javascript/S6327.html | 9 +-- .../javascript/rules/javascript/S6329.html | 7 +-- .../javascript/rules/javascript/S6330.html | 9 +-- .../javascript/rules/javascript/S6332.html | 9 +-- .../javascript/rules/javascript/S6333.html | 5 +- .../javascript/rules/javascript/S6654.html | 21 ++++--- .../javascript/rules/javascript/S6661.html | 7 +-- .../javascript/rules/javascript/S6793.html | 2 +- .../javascript/rules/javascript/S6827.html | 2 +- .../javascript/rules/javascript/S6840.json | 8 +-- .../javascript/rules/javascript/S6844.html | 18 ++++-- .../javascript/rules/javascript/S6846.json | 2 +- .../javascript/rules/javascript/S6850.json | 8 +-- .../javascript/rules/javascript/S888.html | 2 +- .../javascript/rules/javascript/S905.html | 2 +- sonarpedia.json | 2 +- 114 files changed, 470 insertions(+), 495 deletions(-) diff --git a/README.md b/README.md index 8ea8e7cd50..47e1c3292c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This SonarSource project is a [static code analyzer](https://en.wikipedia.org/wi # Features - Advanced rules based on pattern matching and control flow analysis -- [389 JS rules](https://rules.sonarsource.com/javascript) and [393 TS rules](https://rules.sonarsource.com/typescript) +- [397 JS rules](https://rules.sonarsource.com/javascript) and [402 TS rules](https://rules.sonarsource.com/typescript) - [26 CSS rules](https://rules.sonarsource.com/css) - Compatible with ECMAScript 2015-2020 - React JSX, Flow, Vue, and AWS lambda functions support for JavaScript and TypeScript diff --git a/css-sonarpedia/sonarpedia.json b/css-sonarpedia/sonarpedia.json index 60bb012a4f..f28dbb4c4a 100644 --- a/css-sonarpedia/sonarpedia.json +++ b/css-sonarpedia/sonarpedia.json @@ -3,7 +3,7 @@ "languages": [ "CSS" ], - "latest-update": "2023-12-21T17:13:56.851986Z", + "latest-update": "2024-03-28T12:39:07.731724Z", "options": { "no-language-in-filenames": true } 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 d4c024db05..8b943c1c52 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 @@ -37,9 +37,9 @@

Code examples

Resources

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S107.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S107.html index 74ec63f7dc..f2e1bb1031 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S107.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S107.html @@ -1,5 +1,5 @@

Why is this an issue?

-

Functions with a long parameter list are difficult to use, as maintainers must figure out the role of each parameter and keep track of their +

Functions with a long parameter list are difficult to use because maintainers must figure out the role of each parameter and keep track of their position.

 function setCoordinates(x1, y1, z1, x2, y2, z2) { // Noncompliant
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 95ee4e4f30..630f29eb0f 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
@@ -36,6 +36,6 @@ 

Compliant solution

Resources

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 55b296bd32..67d49e2e0e 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 @@ -4,7 +4,7 @@

Why is this an issue?

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

+

How to fix it

Remove redundant boolean literals from expressions to improve readability and make the code more maintainable.

 if (someValue == true) { /* ... */ } // Noncompliant: Redundant comparison
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 9c2dea00dd..f26f038d4d 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
@@ -1,6 +1,6 @@
 

Why is this an issue?

The if...else statement is used to make decisions based on the truthiness of a boolean expression, and the if block -executes when the expression is true, while the else block executes when the expression is false.

+executes when the expression is truthy, while the else block executes when the expression is falsy.

Wrapping a boolean expression in an if...else statement and returning true or false in the respective blocks is redundant and unnecessary. It can also make the code harder to maintain, as it adds unnecessary lines of code that need to be read and understood.

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1134.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1134.html index 03e6cdca63..4f6912ed97 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1134.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1134.html @@ -10,6 +10,6 @@

Why is this an issue?

Resources

Documentation

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 cc6d0f8331..3af845982b 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,8 +1,8 @@

Why is this an issue?

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.

+immediately. However, these TODO tags sometimes get overlooked or forgotten, leading to incomplete or unfinished code. This rule aims to +identify and address unattended TODO tags to ensure a clean and maintainable codebase. This description explores why this is a problem +and how it can be fixed to improve the overall code quality.

What is the potential impact?

Unattended TODO tags in code can have significant implications for the development process and the overall codebase.

Incomplete Functionality: When developers leave TODO tags without implementing the corresponding code, it results in incomplete @@ -11,8 +11,8 @@

What is the potential impact?

Delayed bug fixes can result in more severe issues and increase the effort required to resolve them later.

Impact on Collaboration: In team-based development environments, unattended TODO tags can hinder collaboration. Other team members might not be aware of the intended changes, leading to conflicts or redundant efforts in the codebase.

-

Codebase Bloat: Accumulation of unattended TODO tags over time can clutter the codebase and make it difficult to distinguish between -work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.

+

Codebase Bloat: The accumulation of unattended TODO tags over time can clutter the codebase and make it difficult to distinguish +between work in progress and completed code. This bloat can make it challenging to maintain an organized and efficient codebase.

Addressing this code smell is essential to ensure a maintainable, readable, reliable codebase and promote effective collaboration among developers.

Noncompliant code example

@@ -23,6 +23,6 @@

Noncompliant code example

Resources

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 922dd76e68..42c04995a7 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 @@ -9,15 +9,17 @@

Why is this an issue?

What is the potential impact?

Inconsistent naming of variables, properties, and parameters can lead to several issues in your code:

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.

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 b0fe1ee2ef..a6dabf0d72 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 @@ -6,8 +6,8 @@

Exceptions

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.

+

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:

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S128.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S128.html index 3e585eec70..74eb5fcc7e 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S128.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S128.html @@ -51,6 +51,6 @@

Exceptions

Resources

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S131.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S131.html index 0ace60aa5a..f5d31e4020 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S131.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S131.html @@ -78,6 +78,6 @@

Exceptions

Resources

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1313.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1313.html index 0aa5b23f9e..4a83be595f 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1313.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1313.html @@ -60,8 +60,8 @@

Exceptions

See

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1442.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1442.html index 54ef6916f9..ef9b6405f8 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1442.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1442.html @@ -10,8 +10,8 @@

Noncompliant code example

Resources

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1444.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1444.html index c2082a52a3..ed60185335 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1444.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1444.html @@ -1,13 +1,13 @@

Why is this an issue?

Public static fields in TypeScript should be declared as readonly to prevent them from being modified after their initial assignment. This is a good practice because it makes the code safer by preventing accidental changes to these fields, which could lead to bugs that -are hard to detect and fix.

+are hard to detect.

 class MyClass {
     static myField = 42; // Noncompliant
 }
 
-

To fix this, declare you static field with the readonly qualifier .

+

To fix this, declare your static field with the readonly qualifier.

 class MyClass {
     static readonly myField = 42;
@@ -16,6 +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/S1523.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1523.html index dfebb91c7b..4851ee8bf0 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1523.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1523.html @@ -37,9 +37,9 @@

Exceptions

safe.

See

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1525.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1525.html index 478aee4b52..ce334ad759 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1525.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S1525.html @@ -21,8 +21,8 @@

Compliant solution

Resources

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 89fd0618d1..552c7e97e3 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 @@ -43,7 +43,7 @@

Compliant solution

Resources

Standards

Related rules

Standards

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 94225ace16..76d55f9f2a 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 @@ -46,9 +46,11 @@

Use a secure algorithm

Resources

Standards

diff --git a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5604.html b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5604.html index 55d9288d84..e7eece7de1 100644 --- a/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5604.html +++ b/sonar-plugin/javascript-checks/src/main/resources/org/sonar/l10n/javascript/rules/javascript/S5604.html @@ -46,11 +46,11 @@

Compliant Solution

See