[doc] Update release notes (#3382)
This commit is contained in:
@ -18,7 +18,9 @@ This is a {{ site.pmd.release_type }} release.
|
||||
|
||||
This release ships with 1 new Java rule.
|
||||
|
||||
* {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %} suggests returning empty collections / arrays instead of null.
|
||||
* {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %} suggests returning empty collections / arrays
|
||||
instead of null.
|
||||
|
||||
```xml
|
||||
<rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull" />
|
||||
```
|
||||
@ -27,14 +29,16 @@ This release ships with 1 new Java rule.
|
||||
|
||||
#### Deprecated rules
|
||||
|
||||
The following Java rules are deprecated and removed from the quickstart ruleset,
|
||||
as the new rule {% rule java/errorprone.xml/ReturnEmptyCollectionRatherThanNull %} supersedes it:
|
||||
* {% rule java/errorprone.xml/ReturnEmptyArrayRatherThanNull %}
|
||||
The rule {% rule java/errorprone.xml/ReturnEmptyArrayRatherThanNull %} is deprecated and removed from
|
||||
the quickstart ruleset, as the new rule {% rule java/errorprone.xml/ReturnEmptyCollectionRatherThanNull %}
|
||||
supersedes it.
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* apex
|
||||
* [#3329](https://github.com/pmd/pmd/issues/3329): \[apex] ApexCRUDViolation doesn't report SOQL for loops
|
||||
* java-errorprone
|
||||
* [#3382](https://github.com/pmd/pmd/pull/3382): \[java] New rule ReturnEmptyCollectionRatherThanNull
|
||||
|
||||
### API Changes
|
||||
|
||||
|
@ -2852,18 +2852,19 @@ public class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ReturnEmptyCollectionRatherThanNull"
|
||||
<rule name="ReturnEmptyArrayRatherThanNull"
|
||||
language="java"
|
||||
since="6.37.0"
|
||||
since="4.2"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
message="Return an empty collection rather than 'null'."
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull">
|
||||
deprecated="true"
|
||||
message="Return an empty array rather than 'null'."
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptyarrayratherthannull">
|
||||
<description>
|
||||
For any method that returns an collection (such as an array, Collection or Map), it is a better to return an empty one rather than a
|
||||
For any method that returns an array, it is a better to return an empty array rather than a
|
||||
null reference. This removes the need for null checking all results and avoids inadvertent
|
||||
NullPointerExceptions.
|
||||
|
||||
See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays instead of null
|
||||
Deprecated since PMD 6.37.0, use {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %} instead.
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<properties>
|
||||
@ -2873,7 +2874,7 @@ See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays ins
|
||||
<![CDATA[
|
||||
//MethodDeclaration
|
||||
[
|
||||
(./ResultType/Type[pmd-java:typeIs('java.util.Collection') or pmd-java:typeIs('java.util.Map') or @ArrayType=true()])
|
||||
(./ResultType/Type[@ArrayType= true()])
|
||||
and
|
||||
(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
|
||||
]
|
||||
@ -2900,19 +2901,18 @@ public class Example {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="ReturnEmptyArrayRatherThanNull"
|
||||
<rule name="ReturnEmptyCollectionRatherThanNull"
|
||||
language="java"
|
||||
since="4.2"
|
||||
since="6.37.0"
|
||||
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||
deprecated="true"
|
||||
message="Return an empty array rather than 'null'."
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptyarrayratherthannull">
|
||||
message="Return an empty collection rather than 'null'."
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#returnemptycollectionratherthannull">
|
||||
<description>
|
||||
For any method that returns an array, it is a better to return an empty array rather than a
|
||||
null reference. This removes the need for null checking all results and avoids inadvertent
|
||||
NullPointerExceptions.
|
||||
For any method that returns an collection (such as an array, Collection or Map), it is better to return
|
||||
an empty one rather than a null reference. This removes the need for null checking all results and avoids
|
||||
inadvertent NullPointerExceptions.
|
||||
|
||||
Deprecated since PMD 6.37.0, use {% rule java/errorprone/ReturnEmptyCollectionRatherThanNull %} instead.
|
||||
See Effective Java, 3rd Edition, Item 54: Return empty collections or arrays instead of null
|
||||
</description>
|
||||
<priority>1</priority>
|
||||
<properties>
|
||||
@ -2922,7 +2922,7 @@ Deprecated since PMD 6.37.0, use {% rule java/errorprone/ReturnEmptyCollectionRa
|
||||
<![CDATA[
|
||||
//MethodDeclaration
|
||||
[
|
||||
(./ResultType/Type[@ArrayType= true()])
|
||||
(./ResultType/Type[pmd-java:typeIs('java.util.Collection') or pmd-java:typeIs('java.util.Map') or @ArrayType=true()])
|
||||
and
|
||||
(./Block/BlockStatement/Statement/ReturnStatement/Expression/PrimaryExpression/PrimaryPrefix/Literal/NullLiteral)
|
||||
]
|
||||
|
Reference in New Issue
Block a user