Skip to content

Commit

Permalink
Update release notes, refs pmd#1534, fixes pmd#1517
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Dec 27, 2018
1 parent e00b0b8 commit db25def
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 38 deletions.
8 changes: 8 additions & 0 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ This is a {{ site.pmd.release_type }} release.

### New and noteworthy

#### New Rules

* The new Java rule {% rule "java/codestyle/UseDiamondOperator" %} (`java-codestyle`) looks for constructor
calls with explicit type parameters. Since Java 1.7, these type parameters are not necessary anymore, as they
can be inferred now.

#### Modified Rules

* The Java rule {% rule "java/codestyle/LocalVariableCouldBeFinal" %} (`java-codestyle`) has a new
Expand All @@ -26,6 +32,7 @@ This is a {{ site.pmd.release_type }} release.
* [#658](https://github.com/pmd/pmd/issues/658): \[java] OneDeclarationPerLine: False positive for loops
* java-codestyle
* [#1513](https://github.com/pmd/pmd/issues/1513): \[java] LocalVariableCouldBeFinal: allow excluding the variable in a for-each loop
* [#1517](https://github.com/pmd/pmd/issues/1517): \[java] New Rule: UseDiamondOperator
* java-errorprone
* [#1035](https://github.com/pmd/pmd/issues/1035): \[java] ReturnFromFinallyBlock: False positive on lambda expression in finally block

Expand All @@ -37,6 +44,7 @@ This is a {{ site.pmd.release_type }} release.
* [#1514](https://github.com/pmd/pmd/pull/1514): \[java] LocalVariableCouldBeFinal: allow excluding the variable in a for-each loop - [Kris Scheibe](https://github.com/kris-scheibe)
* [#1516](https://github.com/pmd/pmd/pull/1516): \[java] OneDeclarationPerLine: Don't report multiple variables in a for statement. - [Kris Scheibe](https://github.com/kris-scheibe)
* [#1521](https://github.com/pmd/pmd/pull/1521): \[java] Upgrade to ASM7 for JDK 11 support - [Mark Pritchard](https://github.com/markpritchard)
* [#1534](https://github.com/pmd/pmd/pull/1534): \[java] This is the change regarding the usediamondoperator #1517 - [hemanshu070](https://github.com/hemanshu070)

{% endtocmaker %}

77 changes: 39 additions & 38 deletions pmd-java/src/main/resources/category/java/codestyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1809,44 +1809,6 @@ public class Foo {
</example>
</rule>


<rule name="UseDiamondOperator"
language="java"
since="6.11.0"
message="Explicit type arguments can be replaced by Diamond Operator"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#usediamondoperator"
minimumLanguageVersion="1.7">
<description>Use the diamond operator to let the type be inferred With the Diamond operator it is possible to avoid duplication of the type parameters.
Instead, the compiler is now able to infer the parameter types for constructor calls,
which makes the code also more readable.
</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//VariableInitializer
//PrimaryExpression[not(PrimarySuffix)]
[not(ancestor::ArgumentList)]
/PrimaryPrefix/AllocationExpression[ClassOrInterfaceType[@AnonymousClass='false']/TypeArguments//ReferenceType[not(.//TypeArguments)]]
|
//StatementExpression[AssignmentOperator][PrimaryExpression/PrimaryPrefix[not(Expression)]]
//PrimaryExpression[not(PrimarySuffix)]
[not(ancestor::ArgumentList)]
/PrimaryPrefix/AllocationExpression[ClassOrInterfaceType[@AnonymousClass='false']/TypeArguments//ReferenceType[not(.//TypeArguments)]]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
List<String> strings = new ArrayList<String>(); // unnecessary duplication of type parameters
List<String> stringsWithDiamond = new ArrayList<>(); // using the diamond operator is more concise
]]>
</example>
</rule>

<rule name="UnnecessaryFullyQualifiedName"
language="java"
since="5.0"
Expand Down Expand Up @@ -1950,6 +1912,45 @@ public class Foo {
</example>
</rule>

<rule name="UseDiamondOperator"
language="java"
since="6.11.0"
message="Explicit type arguments can be replaced by Diamond Operator"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#usediamondoperator"
minimumLanguageVersion="1.7">
<description>
Use the diamond operator to let the type be inferred automatically. With the Diamond operator it is possible
to avoid duplication of the type parameters.
Instead, the compiler is now able to infer the parameter types for constructor calls,
which makes the code also more readable.
</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//VariableInitializer
//PrimaryExpression[not(PrimarySuffix)]
[not(ancestor::ArgumentList)]
/PrimaryPrefix/AllocationExpression[ClassOrInterfaceType[@AnonymousClass='false']/TypeArguments//ReferenceType[not(.//TypeArguments)]]
|
//StatementExpression[AssignmentOperator][PrimaryExpression/PrimaryPrefix[not(Expression)]]
//PrimaryExpression[not(PrimarySuffix)]
[not(ancestor::ArgumentList)]
/PrimaryPrefix/AllocationExpression[ClassOrInterfaceType[@AnonymousClass='false']/TypeArguments//ReferenceType[not(.//TypeArguments)]]
]]>
</value>
</property>
</properties>
<example>
<![CDATA[
List<String> strings = new ArrayList<String>(); // unnecessary duplication of type parameters
List<String> stringsWithDiamond = new ArrayList<>(); // using the diamond operator is more concise
]]>
</example>
</rule>

<rule name="UselessParentheses"
language="java"
since="5.0"
Expand Down

0 comments on commit db25def

Please sign in to comment.