Skip to content

Commit a82667f

Browse files
SONARJAVA-6159 Update rule metadata: change formatting with new rule-api.jar (#5490)
Co-authored-by: tomasz-tylenda-sonarsource <tomasz-tylenda-sonarsource@users.noreply.github.com> Co-authored-by: Tomasz Tylenda <tomasz.tylenda@sonarsource.com>
1 parent b20b62d commit a82667f

File tree

444 files changed

+4843
-3657
lines changed

Some content is hidden

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

444 files changed

+4843
-3657
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ <h2>Why is this an issue?</h2>
22
<p>In software development, logs serve as a record of events within an application, providing crucial insights for debugging. When logging, it is
33
essential to ensure that the logs are:</p>
44
<ul>
5-
<li> easily accessible </li>
6-
<li> uniformly formatted for readability </li>
7-
<li> properly recorded </li>
8-
<li> securely logged when dealing with sensitive data </li>
5+
<li>easily accessible</li>
6+
<li>uniformly formatted for readability</li>
7+
<li>properly recorded</li>
8+
<li>securely logged when dealing with sensitive data</li>
99
</ul>
1010
<p>Those requirements are not met if a program directly writes to the standard outputs (e.g., System.out, System.err, IO). That is why defining and
1111
using a dedicated logger is highly recommended.</p>
@@ -36,12 +36,11 @@ <h3>Code examples</h3>
3636
<h2>Resources</h2>
3737
<h3>Documentation</h3>
3838
<ul>
39-
<li> <a href="https://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html">Java SE 7 API Specification: java.util.logging.Logger</a>
40-
</li>
41-
<li> OWASP - <a href="https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/">Top 10 2021 Category A9 - Security Logging and
42-
Monitoring Failures</a> </li>
43-
<li> OWASP - <a href="https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure">Top 10 2017 Category A3 - Sensitive Data
44-
Exposure</a> </li>
45-
<li> <a href="https://wiki.sei.cmu.edu/confluence/x/nzdGBQ">CERT, ERR02-J.</a> - Prevent exceptions while logging data </li>
39+
<li><a href="https://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html">Java SE 7 API Specification: java.util.logging.Logger</a></li>
40+
<li>OWASP - <a href="https://owasp.org/Top10/A09_2021-Security_Logging_and_Monitoring_Failures/">Top 10 2021 Category A9 - Security Logging and
41+
Monitoring Failures</a></li>
42+
<li>OWASP - <a href="https://owasp.org/www-project-top-ten/2017/A3_2017-Sensitive_Data_Exposure">Top 10 2017 Category A3 - Sensitive Data
43+
Exposure</a></li>
44+
<li><a href="https://wiki.sei.cmu.edu/confluence/x/nzdGBQ">CERT, ERR02-J.</a> - Prevent exceptions while logging data</li>
4645
</ul>
4746

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ <h3>Compliant solution</h3>
2020
</pre>
2121
<h2>Resources</h2>
2222
<ul>
23-
<li> <a href="https://wiki.sei.cmu.edu/confluence/x/5dUxBQ">CERT, MSC12-C.</a> - Detect and remove code that has no effect or is never executed
24-
</li>
23+
<li><a href="https://wiki.sei.cmu.edu/confluence/x/5dUxBQ">CERT, MSC12-C.</a> - Detect and remove code that has no effect or is never executed</li>
2524
</ul>
2625

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2>Why is this an issue?</h2>
1717
<h3>Exceptions</h3>
1818
<p>The rule admits 3 exceptions:</p>
1919
<ul>
20-
<li> Serialization ID fields </li>
20+
<li>Serialization ID fields</li>
2121
</ul>
2222
<p>The Java serialization runtime associates with each serializable class a version number called <code>serialVersionUID</code>, which is used during
2323
deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible for
@@ -30,7 +30,7 @@ <h3>Exceptions</h3>
3030
}
3131
</pre>
3232
<ul>
33-
<li> Annotated fields and classes annotated with Lombok annotations </li>
33+
<li>Annotated fields and classes annotated with Lombok annotations</li>
3434
</ul>
3535
<p>The unused field in this class will not be reported by the rule as it is annotated, except if annotation class <code>SomeAnnotation</code> is
3636
listed in the <code>ignoreAnnotations</code> parameter (see Parameters).</p>
@@ -41,7 +41,7 @@ <h3>Exceptions</h3>
4141
}
4242
</pre>
4343
<ul>
44-
<li> Fields from classes with native methods </li>
44+
<li>Fields from classes with native methods</li>
4545
</ul>
4646
<p>The unused field in this class will not be reported by the rule as it might be used by native code.</p>
4747
<pre>

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

Lines changed: 8 additions & 8 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 method into smaller ones </li>
11+
<li>Split the method 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
class Point // In geometry, Point is a logical structure to group data
@@ -39,12 +39,12 @@ <h2>Why is this an issue?</h2>
3939
<h3>Exceptions</h3>
4040
<p>Methods annotated with :</p>
4141
<ul>
42-
<li> Spring’s <code>@RequestMapping</code> (and related shortcut annotations, like <code>@GetRequest</code>) </li>
43-
<li> JAX-RS API annotations (like <code>@javax.ws.rs.GET</code>) </li>
44-
<li> Bean constructor injection with <code>@org.springframework.beans.factory.annotation.Autowired</code> </li>
45-
<li> CDI constructor injection with <code>@javax.inject.Inject</code> </li>
46-
<li> <code>@com.fasterxml.jackson.annotation.JsonCreator</code> </li>
47-
<li> Micronaut’s annotations (like <code>@io.micronaut.http.annotation.Get</code>) </li>
42+
<li>Spring’s <code>@RequestMapping</code> (and related shortcut annotations, like <code>@GetRequest</code>)</li>
43+
<li>JAX-RS API annotations (like <code>@javax.ws.rs.GET</code>)</li>
44+
<li>Bean constructor injection with <code>@org.springframework.beans.factory.annotation.Autowired</code></li>
45+
<li>CDI constructor injection with <code>@javax.inject.Inject</code></li>
46+
<li><code>@com.fasterxml.jackson.annotation.JsonCreator</code></li>
47+
<li>Micronaut’s annotations (like <code>@io.micronaut.http.annotation.Get</code>)</li>
4848
</ul>
4949
<p>may have a lot of parameters, encapsulation being possible. Therefore the rule ignores such methods.</p>
5050
<p>Also, if a class annotated as a Spring component (like <code>@org.springframework.stereotype.Component</code>) has a single constructor, that

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<h2>Why is this an issue?</h2>
22
<p>Hard-coding a URI makes it difficult to test a program for a variety of reasons:</p>
33
<ul>
4-
<li> path literals are not always portable across operating systems </li>
5-
<li> a given absolute path may not exist in a specific test environment </li>
6-
<li> a specified Internet URL may not be available when executing the tests </li>
7-
<li> production environment filesystems usually differ from the development environment </li>
4+
<li>path literals are not always portable across operating systems</li>
5+
<li>a given absolute path may not exist in a specific test environment</li>
6+
<li>a specified Internet URL may not be available when executing the tests</li>
7+
<li>production environment filesystems usually differ from the development environment</li>
88
</ul>
99
<p>In addition, hard-coded URIs can contain sensitive information, like IP addresses, and they should not be stored in the code.</p>
1010
<p>For all those reasons, a URI should never be hard coded. Instead, it should be replaced by a customizable parameter.</p>
@@ -13,9 +13,9 @@ <h2>Why is this an issue?</h2>
1313
<h3>Exceptions</h3>
1414
<p>This rule does not raise an issue when:</p>
1515
<ul>
16-
<li> A constant path is relative and contains at most two parts. </li>
17-
<li> A constant path is used in an annotation </li>
18-
<li> A path is annotated </li>
16+
<li>A constant path is relative and contains at most two parts.</li>
17+
<li>A constant path is used in an annotation</li>
18+
<li>A path is annotated</li>
1919
</ul>
2020
<h2>How to fix it</h2>
2121
<h3>Code examples</h3>

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ <h2>Why is this an issue?</h2>
66
<p>This rule raises an issue when the inheritance tree, starting from <code>Object</code>, has a greater depth than is allowed.</p>
77
<p>The rule has one parameter to filter out classes of the count of inheritance. The following rules apply to define this parameter:</p>
88
<ul>
9-
<li> <code>?</code> matches a single character </li>
10-
<li> <code>*</code> matches zero or more characters </li>
11-
<li> <code>**</code> matches zero or more packages </li>
9+
<li><code>?</code> matches a single character</li>
10+
<li><code>*</code> matches zero or more characters</li>
11+
<li><code>**</code> matches zero or more packages</li>
1212
</ul>
1313
<p>Examples:</p>
1414
<ul>
15-
<li> <code>java.fwk.AbstractFwkClass</code>: the count stops when AbstractFwkClass class is reached. </li>
16-
<li> <code>java.fwk.*</code>: any member of java.fwkPackage package is reached. </li>
17-
<li> <code>java.fwk.**</code>: same as above, but including sub-packages. </li>
15+
<li><code>java.fwk.AbstractFwkClass</code>: the count stops when AbstractFwkClass class is reached.</li>
16+
<li><code>java.fwk.*</code>: any member of java.fwkPackage package is reached.</li>
17+
<li><code>java.fwk.**</code>: same as above, but including sub-packages.</li>
1818
</ul>
1919
<h2>Exceptions:</h2>
2020
<p>The rule stops counting when it encounters a class from one of the following packages (or sub-packages):</p>
2121
<ul>
22-
<li> <code>android.**</code> </li>
23-
<li> <code>com.intellij.**</code> </li>
24-
<li> <code>com.persistit.**</code> </li>
25-
<li> <code>javax.swing.**</code> </li>
26-
<li> <code>org.eclipse.**</code> </li>
27-
<li> <code>org.springframework.**</code> </li>
22+
<li><code>android.**</code></li>
23+
<li><code>com.intellij.**</code></li>
24+
<li><code>com.persistit.**</code></li>
25+
<li><code>javax.swing.**</code></li>
26+
<li><code>org.eclipse.**</code></li>
27+
<li><code>org.springframework.**</code></li>
2828
</ul>
2929
<h2>Resources</h2>
3030
<h3>Documentation</h3>

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<h2>Why is this an issue?</h2>
22
<p>Public fields in public classes do not respect the encapsulation principle and have three main disadvantages:</p>
33
<ul>
4-
<li> Additional behavior such as validation cannot be added. </li>
5-
<li> The internal representation is exposed, and cannot be changed afterwards. </li>
6-
<li> Member values are subject to change from anywhere in the code and may not meet the programmer’s assumptions. </li>
4+
<li>Additional behavior such as validation cannot be added.</li>
5+
<li>The internal representation is exposed, and cannot be changed afterwards.</li>
6+
<li>Member values are subject to change from anywhere in the code and may not meet the programmer’s assumptions.</li>
77
</ul>
88
<p>To prevent unauthorized modifications, private attributes and accessor methods (set and get) should be used.</p>
99
<h3>What is the potential impact?</h3>
@@ -17,14 +17,15 @@ <h3>Exceptions</h3>
1717
<h2>How to fix it</h2>
1818
<p>Depending on your need there are multiple options:</p>
1919
<ul>
20-
<li> Encapsulate the field
20+
<li>Encapsulate the field
2121
<ol>
22-
<li> Make the field private. </li>
23-
<li> Define methods to get and set the value of the field.<br> These methods are commonly known as getter and setter methods and are prefixed by
24-
<code>get</code> and <code>set</code> followed by the name of the field. <em>Note:</em> as a bonus it is now possible to monitor value changes
25-
using breakpoints. </li>
26-
</ol> </li>
27-
<li> Mark the field as <code>public final</code> if it is not supposed to change. </li>
22+
<li>Make the field private.</li>
23+
<li>Define methods to get and set the value of the field.
24+
<br>
25+
These methods are commonly known as getter and setter methods and are prefixed by <code>get</code> and <code>set</code> followed by the name
26+
of the field. <em>Note:</em> as a bonus it is now possible to monitor value changes using breakpoints.</li>
27+
</ol></li>
28+
<li>Mark the field as <code>public final</code> if it is not supposed to change.</li>
2829
</ul>
2930
<h3>Code examples</h3>
3031
<h4>Noncompliant code example</h4>
@@ -62,6 +63,6 @@ <h3>How does this work?</h3>
6263
value.</p>
6364
<h2>Resources</h2>
6465
<ul>
65-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/493">CWE-493 - Critical Public Variable Without Final Modifier</a> </li>
66+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/493">CWE-493 - Critical Public Variable Without Final Modifier</a></li>
6667
</ul>
6768

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ <h3>Noncompliant code example</h3>
1616
</pre>
1717
<h2>Resources</h2>
1818
<ul>
19-
<li> <a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-12.html#jls-12.6">docs.oracle.com</a> - Finalization of Class Instances </li>
20-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/586">CWE-586 - Explicit Call to Finalize()</a> </li>
21-
<li> <a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers </li>
19+
<li><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-12.html#jls-12.6">docs.oracle.com</a> - Finalization of Class Instances</li>
20+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/586">CWE-586 - Explicit Call to Finalize()</a></li>
21+
<li><a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers</li>
2222
</ul>
2323

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ <h2>Why is this an issue?</h2>
77
<h3>What is the potential impact?</h3>
88
<p>More unexpected issues can be caused by relying on the <code>finalize()</code> method to perform important operations on the application state:</p>
99
<ul>
10-
<li> The JVM might terminate without ever calling this method on a particular object, leaving an unexpected or incomplete state of the program </li>
11-
<li> Uncaught exceptions will be ignored inside this method, making it harder to detect issues that could have been logged otherwise </li>
12-
<li> Finalizer methods can also be invoked concurrently, even on single-threaded applications, making it hard to maintain desired program invariants
13-
</li>
10+
<li>The JVM might terminate without ever calling this method on a particular object, leaving an unexpected or incomplete state of the program</li>
11+
<li>Uncaught exceptions will be ignored inside this method, making it harder to detect issues that could have been logged otherwise</li>
12+
<li>Finalizer methods can also be invoked concurrently, even on single-threaded applications, making it hard to maintain desired program
13+
invariants</li>
1414
</ul>
1515
<h3>Noncompliant code example</h3>
1616
<pre>
@@ -28,7 +28,7 @@ <h3>Exceptions</h3>
2828
attack</em> as described in <em>MET12-J-EX1</em>.</p>
2929
<h2>Resources</h2>
3030
<ul>
31-
<li> <a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-12.html#jls-12.6">docs.oracle.com</a> - Finalization of Class Instances </li>
32-
<li> <a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers </li>
31+
<li><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-12.html#jls-12.6">docs.oracle.com</a> - Finalization of Class Instances</li>
32+
<li><a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers</li>
3333
</ul>
3434

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h3>Compliant solution</h3>
2323
</pre>
2424
<h2>Resources</h2>
2525
<ul>
26-
<li> CWE - <a href="https://cwe.mitre.org/data/definitions/568">CWE-568 - finalize() Method Without super.finalize()</a> </li>
27-
<li> <a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers </li>
26+
<li>CWE - <a href="https://cwe.mitre.org/data/definitions/568">CWE-568 - finalize() Method Without super.finalize()</a></li>
27+
<li><a href="https://wiki.sei.cmu.edu/confluence/x/4jZGBQ">CERT, MET12-J.</a> - Do not use finalizers</li>
2828
</ul>
2929

0 commit comments

Comments
 (0)