java/design/UseVargs - update changelog, extend test case

This commit is contained in:
Andreas Dangel
2014-12-12 19:26:36 +01:00
parent bdf454a967
commit aea6c74a8f
3 changed files with 22 additions and 5 deletions

View File

@ -1766,9 +1766,13 @@ having to deal with the creation of an array.
<priority>4</priority> <priority>4</priority>
<properties> <properties>
<property name="xpath"> <property name="xpath">
<value><![CDATA[ <value><![CDATA[
//FormalParameters/FormalParameter[position()=last() and @Array='true' and @Varargs='false' and not (./Type/ReferenceType/PrimitiveType[@Image='byte']) and not (./Type/PrimitiveType[@Image='byte'])] //FormalParameters/FormalParameter
]]></value> [position()=last()]
[@Array='true']
[@Varargs='false']
[not (./Type/ReferenceType[@Array='true'][PrimitiveType[@Image='byte']] or ./Type/ReferenceType[@Array='true'][ClassOrInterfaceType[@Image='Byte']])]
]]></value>
</property> </property>
</properties> </properties>
<example><![CDATA[ <example><![CDATA[

View File

@ -63,7 +63,7 @@ public class Foo implements InvocationHandler {
<test-code> <test-code>
<description><![CDATA[ <description><![CDATA[
method, do not varargs, allow byte[] as not vargars method, do not varargs, allow byte[] as not varargs
]]></description> ]]></description>
<expected-problems>0</expected-problems> <expected-problems>0</expected-problems>
<code><![CDATA[ <code><![CDATA[
@ -72,5 +72,15 @@ public class Foo {
} }
]]></code> ]]></code>
</test-code> </test-code>
<test-code>
<description><![CDATA[
method, do not varargs, allow Byte[] as not varargs
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public void bar(File file, Byte[] data) { }
}
]]></code>
</test-code>
</test-data> </test-data>

View File

@ -6,9 +6,12 @@
**New/Modified Rules:** **New/Modified Rules:**
* [Java / Design / UseVarargs](http://pmd.sourceforge.net/pmd-java/rules/java/design.html#UseVarargs): if `byte[]` is used as the last argument, it is ignored and no violation will be reported.
**Pull requests:** **Pull requests:**
* [#45](https://github.com/pmd/pmd/pull/45): #1290 RuleSetReferenceId does not process HTTP(S) correctly. * [#45](https://github.com/pmd/pmd/pull/45): #1290 RuleSetReferenceId does not process HTTP(S) correctly.
* [#46](https://github.com/pmd/pmd/pull/46): Allow byte[] as no-vargars last argument
**Bugfixes:** **Bugfixes:**