Skip to content

Commit eabac12

Browse files
authored
Update rule metadata (#4731)
1 parent e98e481 commit eabac12

25 files changed

Lines changed: 150 additions & 118 deletions

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1120.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ <h2>Why is this an issue?</h2>
55
control systems, making code reviews easier.</p>
66
<p>This rule raises an issue when the indentation does not match the configured value. Only the first line of a badly indented section is
77
reported.</p>
8+
<p>The rule behaves consistently when the indentation settings of the IDE use <em>spaces</em> instead of <em>tabs</em>. Using <em>tabs</em> can lead
9+
to inconsistent indentation because the width of a <em>tab</em> can be configured differently in different environments.</p>
810
<h3>What is the potential impact?</h3>
911
<p>The readability is decreased. It becomes more tedious to review and modify the code.</p>
1012
<h2>How to fix it</h2>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S117.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ <h2>Why is this an issue?</h2>
99
<h3>What is the potential impact?</h3>
1010
<p>Inconsistent naming of local variables and method parameters can lead to several issues in your code:</p>
1111
<ul>
12-
<li> Reduced Readability: inconsistent local variable and method parameter names make the code harder to read and understand; consequently, it is
13-
more difficult to identify the purpose of each variable, spot errors, or comprehend the logic. </li>
14-
<li> Difficulty in Identifying Variables: local variables and method parameters that don’t adhere to a standard naming convention are challenging to
15-
identify; thus, the coding process slows down, especially when dealing with a large codebase. </li>
16-
<li> Increased Risk of Errors: inconsistent or unclear local variable and method parameter names lead to misunderstandings about what the variable
17-
represents. This ambiguity leads to incorrect assumptions and, consequently, bugs in the code. </li>
18-
<li> Collaboration Difficulties: in a team setting, inconsistent naming conventions lead to confusion and miscommunication among team members. </li>
19-
<li> Difficulty in Code Maintenance: inconsistent naming leads to an inconsistent codebase. The code is difficult to understand, and making changes
20-
feels like refactoring constantly, as you face different naming methods. Ultimately, it makes the codebase harder to maintain. </li>
12+
<li> <strong>Reduced Readability</strong>: Inconsistent local variable and method 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 method 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 method 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>
2123
</ul>
2224
<p>In summary, not adhering to a naming convention for local variables and method parameters can lead to confusion, errors, and inefficiencies, making
2325
the code harder to read, understand, and maintain.</p>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1171.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>Non-static initializers, also known as instance initializers, are blocks of code within a class that is executed when an instance of the class is
2+
<p>Non-static initializers, also known as instance initializers, are blocks of code within a class that are executed when an instance of the class is
33
created. They are executed when an object of the class is created just before the constructor is called. Non-static initializers are useful when you
44
want to perform some common initialization logic for all objects of a class. They allow you to initialize instance variables in a concise and
55
centralized manner, without having to repeat the same initialization code in each constructor.</p>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1192.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ <h2>Why is this an issue?</h2>
44
<h3>Exceptions</h3>
55
<p>To prevent generating some false-positives, literals having less than 5 characters are excluded.</p>
66
<h2>How to fix it</h2>
7-
<p>Instead, use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a
8-
single place.</p>
7+
<p>Use constants to replace the duplicated string literals. Constants can be referenced from many places, but only need to be updated in a single
8+
place.</p>
99
<h3>Code examples</h3>
1010
<h4>Noncompliant code example</h4>
1111
<p>With the default threshold of 3:</p>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1193.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h2>Why is this an issue?</h2>
66
to manually check the types using <code>instanceof</code> because Java automatically matches the exception type to the appropriate catch block based
77
on the declared exception type in the catch clauses.</p>
88
<h2>How to fix it</h2>
9-
<p>Replace <code>if</code> statements that check the exception type using <code>instaceof</code> with corresponding <code>catch</code> blocks.</p>
9+
<p>Replace <code>if</code> statements that check the exception type using <code>instanceof</code> with corresponding <code>catch</code> blocks.</p>
1010
<h3>Code examples</h3>
1111
<h4>Noncompliant code example</h4>
1212
<pre data-diff-id="1" data-diff-type="noncompliant">

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1312.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"constantCost": "5min"
1414
},
1515
"tags": [
16-
"convention"
16+
"convention",
17+
"logging"
1718
],
1819
"defaultSeverity": "Minor",
1920
"ruleSpecification": "RSPEC-1312",

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1481.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ <h2>Why is this an issue?</h2>
55
<h3>What is the potential impact?</h3>
66
<p>Having unused local variables in your code can lead to several issues:</p>
77
<ul>
8-
<li> Decreased Readability: Unused variables can make your code more difficult to read. They add extra lines and complexity, which can distract from
9-
the main logic of the code. </li>
10-
<li> Misunderstanding: When other developers read your code, they may wonder why a variable is declared but not used. This can lead to confusion and
11-
misinterpretation of the code’s intent. </li>
12-
<li> Potential for Bugs: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you declared a variable
13-
intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14-
<li> Maintenance Issues: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they might think it is
15-
a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16-
<li> Memory Usage: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases, unused variables
17-
take up memory space, leading to inefficient use of resources. </li>
8+
<li> <strong>Decreased Readability</strong>: Unused variables can make your code more difficult to read. They add extra lines and complexity, which
9+
can distract from the main logic of the code. </li>
10+
<li> <strong>Misunderstanding</strong>: When other developers read your code, they may wonder why a variable is declared but not used. This can lead
11+
to confusion and misinterpretation of the code’s intent. </li>
12+
<li> <strong>Potential for Bugs</strong>: If a variable is declared but not used, it might indicate a bug or incomplete code. For example, if you
13+
declared a variable intending to use it in a calculation, but then forgot to do so, your program might not work as expected. </li>
14+
<li> <strong>Maintenance Issues</strong>: Unused variables can make code maintenance more difficult. If a programmer sees an unused variable, they
15+
might think it is a mistake and try to 'fix' the code, potentially introducing new bugs. </li>
16+
<li> <strong>Memory Usage</strong>: Although modern compilers are smart enough to ignore unused variables, not all compilers do this. In such cases,
17+
unused variables take up memory space, leading to inefficient use of resources. </li>
1818
</ul>
1919
<p>In summary, unused local variables can make your code less readable, more confusing, and harder to maintain, and they can potentially lead to bugs
2020
or inefficient memory use. Therefore, it is best to remove them.</p>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S1696.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
395
3030
]
3131
},
32-
"quickfix": "unknown"
32+
"quickfix": "infeasible"
3333
}

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S2053.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ <h3>What is the potential impact?</h3>
1919
of password hashes with identical salt that can then be attacked as explained before.</p>
2020
<p>With short salts, the probability of a collision between two users' passwords and salts couple might be low depending on the salt size. The shorter
2121
the salt, the higher the collision probability. In any case, using longer, cryptographically secure salt should be preferred.</p>
22+
<h3>Exceptions</h3>
23+
<p>To securely store password hashes, it is a recommended to rely on key derivation functions that are computationally intensive. Examples of such
24+
functions are:</p>
25+
<ul>
26+
<li> Argon2 </li>
27+
<li> PBKDF2 </li>
28+
<li> Scrypt </li>
29+
<li> Bcrypt </li>
30+
</ul>
31+
<p>When they are used for password storage, using a secure, random salt is required.</p>
32+
<p>However, those functions can also be used for other purposes such as master key derivation or password-based pre-shared key generation. In those
33+
cases, the implemented cryptographic protocol might require using a fixed salt to derive keys in a deterministic way. In such cases, using a fixed
34+
salt is safe and accepted.</p>
2235
<h2>How to fix it in Java SE</h2>
2336
<h3>Code examples</h3>
2437
<p>The following code contains examples of hard-coded salts.</p>
@@ -46,7 +59,7 @@ <h4>Compliant solution</h4>
4659
</pre>
4760
<h3>How does this work?</h3>
4861
<p>This code ensures that each user’s password has a unique salt value associated with it. It generates a salt randomly and with a length that
49-
provides the required security level. It uses a salt length of at least 16 bytes (128 bits), as recommended by industry standards.</p>
62+
provides the required security level. It uses a salt length of at least 32 bytes (256 bits), as recommended by industry standards.</p>
5063
<p>Here, the compliant code example ensures the salt is random and has a sufficient length by calling the <code>nextBytes</code> method from the
5164
<code>SecureRandom</code> class with a salt buffer of 16 bytes. This class implements a cryptographically secure pseudo-random number generator.</p>
5265
<h2>Resources</h2>

sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S2053.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Hashes should include an unpredictable salt",
2+
"title": "Password hashing functions should use an unpredictable salt",
33
"type": "VULNERABILITY",
44
"code": {
55
"impacts": {

0 commit comments

Comments
 (0)