Skip to content

Commit 05c0394

Browse files
committed
Update java version specific rules descriptions
1 parent 40984c8 commit 05c0394

10 files changed

Lines changed: 48 additions & 5 deletions

File tree

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1602.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<p>There are two ways to write lambdas that contain single statement, but one is definitely more compact and readable than the other.</p>
2+
3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
27
<h2>Noncompliant Code Example</h2>
38

49
<pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1604.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
<p>With Java 8, most uses of anonymous inner classes should be replaced by lambdas to highly increase the readability of the source code.</p>
44

5+
<p>
6+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
7+
</p>
8+
59
<h2>Noncompliant Code Example</h2>
610
<pre>
7-
myCollection.map(new Mapper<String,String>() {
11+
myCollection.map(new Mapper&lt;String,String&gt;() {
812
public String map(String input) {
913
return new StringBuilder(input).reverse().toString();
1014
}
@@ -13,5 +17,5 @@ <h2>Noncompliant Code Example</h2>
1317

1418
<h2>Compliant Solution</h2>
1519
<pre>
16-
myCollection.map(element -> new StringBuilder(element).reverse().toString());
20+
myCollection.map(element -&gt; new StringBuilder(element).reverse().toString());
1721
</pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1609.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<p>A Single Abstract Method (SAM) interface is a Java interface containing only one method. The Java API is full of SAM interfaces, such as <code>java.lang.Runnable</code>, <code>java.awt.event.ActionListener</code>, <code>java.util.Comparator</code> and <code>java.util.concurrent.Callable</code>. SAM interfaces have a special place in Java 8 because they can be implemented using Lambda expressions or Method references. </p>
22
<p>Using <code>@FunctionalInterface</code> forces a compile break when an additional, non-overriding abstract method is added to a SAM, which would break the use of Lambda implementations.</p>
3+
4+
<p>
5+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
6+
</p>
7+
38
<h2>Noncompliant Code Example</h2>
49

510
<pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1610.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<p>With Java 8's "default method" feature, any abstract class without direct or inherited field should be converted into an interface.</p>
22

3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
37
<h2>Noncompliant Code Example</h2>
48
<pre>
59
public abstract class Car {
@@ -20,4 +24,4 @@ <h2>Compliant Solution</h2>
2024
c.freeze(this);
2125
}
2226
}
23-
</pre>
27+
</pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1611.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<p>There are two possible syntaxes for a lambda having only one input parameter with an inferred type: with and without parentheses around that single parameter. The simpler syntax, without parentheses, is more compact and readable than the one with parentheses, and is therefore preferred.</p>
22

3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
37
<h2>Noncompliant Code Example</h2>
48
<pre>
59
(x) -> x * 2

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1612.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<p>Method/constructor references are more compact and readable than using lambdas, and are therefore preferred.</p>
22

3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
37
<h2>Noncompliant Code Example</h2>
48
<pre>
59
List<Integer> list = new ArrayList<Integer>();
@@ -18,4 +22,4 @@ <h2>Compliant Solution</h2>
1822
list.add(2);
1923

2024
list.forEach(System.out::println);
21-
</pre>
25+
</pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S1710.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<p>Before Java 8 if you needed to use multiple instances of the same annotation, they had to be wrapped in a container annotation. With Java 8, that's no longer necessary, allowing for cleaner, more readable code.</p>
22

3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
37
<h2>Noncompliant Code Example</h2>
48
<pre>
59
@SomeAnnotations({

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S2293.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<p>Java 7 introduced the diamond operator (<code>&lt;&gt;</code>) to reduce the verbosity of generics code. For instance, instead of having to declare a <code>List</code>'s type in both its declaration and its constructor, you can now simplify the constructor declaration with <code>&lt;&gt;</code>, and the compiler will infer the type.</p>
2+
3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>7</code>.
5+
</p>
6+
27
<h2>Noncompliant Code Example</h2>
38

49
<pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S2718.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<p>The use of the <code>Instant</code> class introduced in Java 8 to truncate a date can be significantly faster than the <code>DateUtils</code> class from Commons Lang.</p>
22

3+
<p>
4+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>8</code>.
5+
</p>
6+
37
<h2>Noncompliant Code Example</h2>
48

59
<pre>
@@ -16,4 +20,4 @@ <h2>Compliant Solution</h2>
1620
instant = instant.truncatedTo(ChronoUnit.SECONDS);
1721
return Date.from(instant);
1822
}
19-
</pre>
23+
</pre>

java-checks/src/main/resources/org/sonar/l10n/java/rules/squid/S2976.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<li>call <code>mkdir</code> on the File object</li>
1111
</ul>
1212

13+
<p>
14+
<em>Note</em> that this rule is automatically disabled when the project's <code>java.source.version</code> is lower than <code>7</code>.
15+
</p>
16+
1317
<h2>Noncompliant Code Example</h2>
1418
<pre>
1519
File tempDir;

0 commit comments

Comments
 (0)