Skip to content

Commit

Permalink
Merge branch 'pr-79'
Browse files Browse the repository at this point in the history
Closes #79
  • Loading branch information
adangel committed Jan 7, 2016
2 parents efbea80 + 985ed57 commit a200fd2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pmd-java/src/main/resources/rulesets/java/design.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,15 @@ having to deal with the creation of an array.
[not (./Type/ReferenceType[@Array='true'][PrimitiveType[@Image='byte']])]
[not (./Type/ReferenceType[ClassOrInterfaceType[@Image='Byte']])]
[not (./Type/PrimitiveType[@Image='byte'])]
[not (ancestor::MethodDeclaration/preceding-sibling::Annotation/*/Name[@Image='Override'])]
[not(
ancestor::MethodDeclaration
[@Public='true' and @Static='true']
[child::ResultType[@Void='true']] and
ancestor::MethodDeclarator[@Image='main'] and
..[@ParameterCount='1'] and
./Type/ReferenceType[ClassOrInterfaceType[@Image='String']]
)]
]]></value>
</property>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@ method, do not varargs, allow Byte[] as not varargs
public class Foo {
public void bar(File file, Byte[] data) { }
public void bar2(File file, Byte data[]) { }
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
method, do not varargs, allow @Override
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
@Override
protected void bar(String[] args) { }
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
method, do not varargs, allow public static void main(String[]) as not varargs
]]></description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class Foo {
public static void main(String[] args) { }
}
]]></code>
</test-code>
<test-code>
<description><![CDATA[
method, use varargs, deviation from exact main signature flagged
]]></description>
<expected-problems>1</expected-problems>
<code><![CDATA[
public class Foo {
public static void main(int i, String[] args) { }
}
]]></code>
</test-code>
Expand Down
3 changes: 3 additions & 0 deletions src/site/markdown/overview/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
Check for invalid message format in slf4j loggers.
* java-comments/CommentRequired: New property `serialVersionUIDCommentRequired` which controls the comment requirements
for *serialVersionUID* fields. By default, no comment is required for this field.
* java-design/UseVargs: public static void main method is ignored now and so are methods, that are annotated
with Override. See [PR#79](https://github.com/pmd/pmd/pull/79).

**Pull Requests:**

Expand All @@ -26,6 +28,7 @@
* [#76](https://github.com/pmd/pmd/pull/76): fix formatting typos in an example of the DoNotCallGarbageCollectionExplicitly rule
* [#77](https://github.com/pmd/pmd/pull/77): Fix various typos
* [#78](https://github.com/pmd/pmd/pull/78): Add Builder pattern check to the MissingStaticMethodInNonInstantiatableClass rule
* [#79](https://github.com/pmd/pmd/pull/79): do not flag public static void main(String[]) as UseVarargs; ignore @Override for UseVarargs

**Bugfixes:**

Expand Down

0 comments on commit a200fd2

Please sign in to comment.