Skip to content

Commit d7e333b

Browse files
mstachniuksonartech
authored andcommitted
SONARGO-776 Update RSPECs (#710)
GitOrigin-RevId: 3f9cf9be0e0c2da1ade4cb0baceabe57ce62fed7
1 parent 5e0cf1c commit d7e333b

File tree

15 files changed

+61
-54
lines changed

15 files changed

+61
-54
lines changed

sonar-go-plugin/sonarpedia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"languages": [
44
"GO"
55
],
6-
"latest-update": "2026-02-09T11:56:11.341919Z",
6+
"latest-update": "2026-04-01T12:18:54.069660Z",
77
"options": {
88
"no-language-in-filenames": true,
99
"preserve-filenames": true

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S103.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ <h2>Why is this an issue?</h2>
22
<p>Scrolling horizontally to see a full line of code lowers the code readability.</p>
33
<h3>Exceptions</h3>
44
<ul>
5-
<li> The rule ignores comments that contains only URL links. </li>
6-
<li> The rule ignores import statements as there is no way to break them into multiple lines. </li>
5+
<li>The rule ignores comments that contains only URL links.</li>
6+
<li>The rule ignores import statements as there is no way to break them into multiple lines.</li>
77
</ul>
88

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S107.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h2>Why is this an issue?</h2>
88
</pre>
99
<p>The solution can be to:</p>
1010
<ul>
11-
<li> Split the function into smaller ones </li>
11+
<li>Split the function into smaller ones</li>
1212
</ul>
1313
<pre>
1414
// Each function does a part of what the original setCoordinates function was doing, so confusion risks are lower
@@ -21,7 +21,7 @@ <h2>Why is this an issue?</h2>
2121
}
2222
</pre>
2323
<ul>
24-
<li> Find a better data structure for the parameters that group data in a way that makes sense for the specific application domain </li>
24+
<li>Find a better data structure for the parameters that group data in a way that makes sense for the specific application domain</li>
2525
</ul>
2626
<pre>
2727
type point struct { // In geometry, Point is a logical structure to group data

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S108.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2>Why is this an issue?</h2>
1212
<h3>Exceptions</h3>
1313
<p>The rule ignores:</p>
1414
<ul>
15-
<li> code blocks that contain comments. </li>
16-
<li> <code>for</code> without <code>init</code> and <code>post</code> statements with empty blocks </li>
15+
<li>code blocks that contain comments.</li>
16+
<li><code>for</code> without <code>init</code> and <code>post</code> statements with empty blocks</li>
1717
</ul>
1818

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S1134.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ <h2>Why is this an issue?</h2>
1010
<h2>Resources</h2>
1111
<h3>Documentation</h3>
1212
<ul>
13-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a> </li>
13+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a></li>
1414
</ul>
1515

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S1135.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ <h3>Noncompliant code example</h3>
2323
</pre>
2424
<h2>Resources</h2>
2525
<ul>
26-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a> </li>
26+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/546">CWE-546 - Suspicious Comment</a></li>
2727
</ul>
2828

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S1145.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ <h2>Why is this an issue?</h2>
33
statements with conditions that are always true are completely redundant, and make the code less readable.</p>
44
<p>There are three possible causes for the presence of such code:</p>
55
<ul>
6-
<li> An if statement was changed during debugging and that debug code has been committed. </li>
7-
<li> Some value was left unset. </li>
8-
<li> Some logic is not doing what the programmer thought it did. </li>
6+
<li>An if statement was changed during debugging and that debug code has been committed.</li>
7+
<li>Some value was left unset.</li>
8+
<li>Some logic is not doing what the programmer thought it did.</li>
99
</ul>
1010
<p>In any of these cases, unconditional <code>if</code> statements should be removed.</p>
1111
<h3>Noncompliant code example</h3>
@@ -25,8 +25,8 @@ <h3>Compliant solution</h3>
2525
</pre>
2626
<h2>Resources</h2>
2727
<ul>
28-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/489">CWE-489 - Active Debug Code</a> </li>
29-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/570">CWE-570 - Expression is Always False</a> </li>
30-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/571">CWE-571 - Expression is Always True</a> </li>
28+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/489">CWE-489 - Active Debug Code</a></li>
29+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/570">CWE-570 - Expression is Always False</a></li>
30+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/571">CWE-571 - Expression is Always True</a></li>
3131
</ul>
3232

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
<p>Local variables and function parameters should be named consistently to communicate intent and improve maintainability. Rename your local variable
22
or function parameter to follow your project’s naming convention to address this issue.</p>
33
<h2>Why is this an issue?</h2>
4-
<p>A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.<br> Local
5-
variables and function parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily
6-
recognizable pattern.<br> Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to
7-
maintain and debug. It also ensures consistency in the code, especially when multiple developers are working on the same project.</p>
4+
<p>A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
5+
<br>
6+
Local variables and function parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily
7+
recognizable pattern.
8+
<br>
9+
Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to maintain and debug. It
10+
also ensures consistency in the code, especially when multiple developers are working on the same project.</p>
811
<p>This rule checks that local variable and function parameter names match a provided regular expression.</p>
912
<h3>What is the potential impact?</h3>
1013
<p>Inconsistent naming of local variables and function parameters can lead to several issues in your code:</p>
1114
<ul>
12-
<li> <strong>Reduced Readability</strong>: Inconsistent local variable and function parameter names make the code harder to read and understand;
13-
consequently, it is more difficult to identify the purpose of each variable, spot errors, or comprehend the logic. </li>
14-
<li> <strong>Difficulty in Identifying Variables</strong>: The local variables and function parameters that don’t adhere to a standard naming
15-
convention are challenging to identify; thus, the coding process slows down, especially when dealing with a large codebase. </li>
16-
<li> <strong>Increased Risk of Errors</strong>: Inconsistent or unclear local variable and function parameter names lead to misunderstandings about
17-
what the variable represents. This ambiguity leads to incorrect assumptions and, consequently, bugs in the code. </li>
18-
<li> <strong>Collaboration Difficulties</strong>: In a team setting, inconsistent naming conventions lead to confusion and miscommunication among
19-
team members. </li>
20-
<li> <strong>Difficulty in Code Maintenance</strong>: Inconsistent naming leads to an inconsistent codebase. The code is difficult to understand,
21-
and making changes feels like refactoring constantly, as you face different naming methods. Ultimately, it makes the codebase harder to maintain.
22-
</li>
15+
<li><strong>Reduced Readability</strong>: Inconsistent local variable and function parameter names make the code harder to read and understand;
16+
consequently, it is more difficult to identify the purpose of each variable, spot errors, or comprehend the logic.</li>
17+
<li><strong>Difficulty in Identifying Variables</strong>: The local variables and function parameters that don’t adhere to a standard naming
18+
convention are challenging to identify; thus, the coding process slows down, especially when dealing with a large codebase.</li>
19+
<li><strong>Increased Risk of Errors</strong>: Inconsistent or unclear local variable and function parameter names lead to misunderstandings about
20+
what the variable represents. This ambiguity leads to incorrect assumptions and, consequently, bugs in the code.</li>
21+
<li><strong>Collaboration Difficulties</strong>: In a team setting, inconsistent naming conventions lead to confusion and miscommunication among
22+
team members.</li>
23+
<li><strong>Difficulty in Code Maintenance</strong>: Inconsistent naming leads to an inconsistent codebase. The code is difficult to understand, and
24+
making changes feels like refactoring constantly, as you face different naming methods. Ultimately, it makes the codebase harder to maintain.</li>
2325
</ul>
2426
<p>In summary, not adhering to a naming convention for local variables and function parameters can lead to confusion, errors, and inefficiencies,
2527
making the code harder to read, understand, and maintain.</p>
@@ -45,11 +47,11 @@ <h4>Compliant solution</h4>
4547
<h2>Resources</h2>
4648
<h3>Documentation</h3>
4749
<ul>
48-
<li> Go documentation - <a href="https://go.dev/doc/effective_go#names">Effective Go - Names</a> </li>
49-
<li> Wikipedia - <a href="https://en.wikipedia.org/wiki/Naming_convention_(programming)">Naming Convention (programming)</a> </li>
50+
<li>Go documentation - <a href="https://go.dev/doc/effective_go#names">Effective Go - Names</a></li>
51+
<li>Wikipedia - <a href="https://en.wikipedia.org/wiki/Naming_convention_(programming)">Naming Convention (programming)</a></li>
5052
</ul>
5153
<h3>Related rules</h3>
5254
<ul>
53-
<li> {rule:go:S100} - Function names should comply with a naming convention </li>
55+
<li>{rule:go:S100} - Function names should comply with a naming convention</li>
5456
</ul>
5557

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S1186.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ <h2>Why is this an issue?</h2>
33
functionality and are misleading to others as they might think the function implementation fulfills a specific and identified requirement.</p>
44
<p>There are several reasons for a function not to have a body:</p>
55
<ul>
6-
<li> It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production. </li>
7-
<li> It is not yet, or never will be, supported. In this case an exception should be thrown. </li>
8-
<li> The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override. </li>
6+
<li>It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.</li>
7+
<li>It is not yet, or never will be, supported. In this case an exception should be thrown.</li>
8+
<li>The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.</li>
99
</ul>
1010
<h2>How to fix it</h2>
1111
<h3>Code examples</h3>

sonar-go-plugin/src/main/resources/org/sonar/l10n/go/rules/go/S131.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ <h3>Compliant solution</h3>
2323
</pre>
2424
<h2>Resources</h2>
2525
<ul>
26-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/478">CWE-478 - Missing Default Case in Switch Statement</a> </li>
26+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/478">CWE-478 - Missing Default Case in Switch Statement</a></li>
2727
</ul>
2828

0 commit comments

Comments
 (0)