Skip to content

Commit 005476c

Browse files
SONARFLEX-187 Update rule metadata (#197)
1 parent bae5be0 commit 005476c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+348
-194
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Programmers should not comment out code as it bloats programs and reduces readability.</p>
3-
<p>Unused code should be deleted and can be retrieved from source control history if required.</p>
2+
<p>Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never
3+
executed, it quickly becomes out of date and invalid.</p>
4+
<p>Commented-out code should be deleted and can be retrieved from source control history if required.</p>
45

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/NonEmptyCaseWithoutBreak.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ <h3>Exceptions</h3>
4848
</pre>
4949
<h2>Resources</h2>
5050
<ul>
51-
<li> <a href="https://cwe.mitre.org/data/definitions/484">MITRE, CWE-484</a> - Omitted Break Statement in Switch </li>
51+
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/484">CWE-484 - Omitted Break Statement in Switch</a> </li>
5252
</ul>
5353

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/NonEmptyCaseWithoutBreak.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "CODE_SMELL",
44
"code": {
55
"impacts": {
6-
"MAINTAINABILITY": "HIGH"
6+
"MAINTAINABILITY": "BLOCKER"
77
},
88
"attribute": "CLEAR"
99
},

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/ParsingError.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"ruleSpecification": "RSPEC-2260",
1414
"sqKey": "S2260",
1515
"scope": "All",
16-
"quickfix": "unknown"
16+
"quickfix": "infeasible"
1717
}

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1066.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Merging collapsible <code>if</code> statements increases the code’s readability.</p>
3-
<h3>Noncompliant code example</h3>
2+
<p>Nested code - blocks of code inside blocks of code - is eventually necessary, but increases complexity. This is why keeping the code as flat as
3+
possible, by avoiding unnecessary nesting, is considered a good practice.</p>
4+
<p>Merging <code>if</code> statements when possible will decrease the nesting of the code and improve its readability.</p>
5+
<p>Code like</p>
46
<pre>
57
if (condition1) {
6-
if (condition2) { // NonCompliant
8+
if (condition2) { // Noncompliant
79
...
810
}
911
}
1012
</pre>
11-
<h3>Compliant solution</h3>
13+
<p>Is more readable as</p>
1214
<pre>
1315
if (condition1 &amp;&amp; condition2) {
1416
...

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1066.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Collapsible \"if\" statements should be merged",
2+
"title": "Mergeable \"if\" statements should be combined",
33
"type": "CODE_SMELL",
44
"code": {
55
"impacts": {

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1068.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
<h2>Why is this an issue?</h2>
2-
<p>If a <code>private</code> field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will
3-
improve maintainability because developers will not wonder what the variable is used for.</p>
4-
<h3>Noncompliant code example</h3>
5-
<pre>
6-
public class MyClass {
7-
private var foo:int = 4; //foo is unused
8-
9-
public function compute(a:int):int{
10-
return a * 4;
11-
}
12-
}
13-
</pre>
14-
<h3>Compliant solution</h3>
2+
<p>If a <code>private</code> field is declared but not used locally, its limited visibility makes it dead code.</p>
3+
<p>This is either a sign that some logic is missing or that the code should be cleaned.</p>
4+
<p>Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand and preventing bugs from being introduced.</p>
155
<pre>
166
public class MyClass {
7+
private var foo:int = 4; // Noncompliant: foo is unused and should be removed
178

189
public function compute(a:int):int{
1910
return a * 4;

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S107.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h2>Why is this an issue?</h2>
2-
<p>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
2+
<p>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
33
position.</p>
44
<pre>
55
function setCoordinates(var x1, var y1, var z1, var x2, var y2, var z2) { // Noncompliant

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1116.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Empty statements, i.e. <code>;</code>, are usually introduced by mistake, for example because:</p>
3-
<ul>
4-
<li> It was meant to be replaced by an actual statement, but this was forgotten. </li>
5-
<li> There was a typo which lead the semicolon to be doubled, i.e. <code>;;</code>. </li>
6-
</ul>
2+
<p>Empty statements represented by a semicolon <code>;</code> are statements that do not perform any operation. They are often the result of a typo or
3+
a misunderstanding of the language syntax. It is a good practice to remove empty statements since they don’t add value and lead to confusion and
4+
errors.</p>
75
<h3>Noncompliant code example</h3>
86
<pre>
97
function doSomething():void {

flex-checks/src/main/resources/org/sonar/l10n/flex/rules/flex/S1117.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<h2>Why is this an issue?</h2>
2-
<p>Overriding or shadowing a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of
3-
code. Further, it could lead maintainers to introduce bugs because they think they’re using one variable but are really using another.</p>
2+
<p>Shadowing occurs when a local variable has the same name as a variable or a field in an outer scope.</p>
3+
<p>This can lead to three main problems:</p>
4+
<ul>
5+
<li> Confusion: The same name can refer to different variables in different parts of the scope, making the code hard to read and understand. </li>
6+
<li> Unintended Behavior: You might accidentally use the wrong variable, leading to hard-to-detect bugs. </li>
7+
<li> Maintenance Issues: If the inner variable is removed or renamed, the code’s behavior might change unexpectedly because the outer variable is
8+
now being used. </li>
9+
</ul>
10+
<p>To avoid these problems, rename the shadowing, shadowed, or both identifiers to accurately represent their purpose with unique and meaningful
11+
names.</p>
12+
<p>This rule focuses on variables in methods that shadow a field.</p>
13+
<h3>Noncompliant code example</h3>
414
<pre>
515
class Foo {
616
public var myField:int;
717

818
public function doSomething():String {
9-
var myField:int = 0; /* Noncompliant */
10-
...
19+
var myField:int = 0; // Noncompliant
20+
//...
1121
}
1222
}
1323
</pre>

0 commit comments

Comments
 (0)