Merge branch 'pr-111'
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
*/
|
||||
package net.sourceforge.pmd.lang.java.rule.basic;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
|
||||
@ -63,7 +64,9 @@ public class BooleanInstantiationRule extends AbstractJavaRule {
|
||||
if (node.hasDescendantOfType(ASTArrayDimsAndInits.class)) {
|
||||
return super.visit(node, data);
|
||||
}
|
||||
if (TypeHelper.isA((ASTClassOrInterfaceType) node.jjtGetChild(0), Boolean.class)) {
|
||||
|
||||
Node n1 = node.getFirstChildOfType(ASTClassOrInterfaceType.class);
|
||||
if (TypeHelper.isA((ASTClassOrInterfaceType) n1, Boolean.class)) {
|
||||
super.addViolation(data, node);
|
||||
return data;
|
||||
}
|
||||
|
@ -155,6 +155,18 @@ Test for failure after rule with custom Boolean, should report failure if rule r
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
Boolean b = Boolean.valueOf("true");
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#1533 [java] BooleanInstantiation: ClassCastException with Annotation</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
public void bar() {
|
||||
Object o = new @Interned MyObject();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
@ -15,11 +15,14 @@
|
||||
* [#106](https://github.com/pmd/pmd/pull/106): \[java] CPD: Keep constructor names under ignoreIdentifiers
|
||||
* [#107](https://github.com/pmd/pmd/pull/107): \[groovy] Initial support for CPD Groovy
|
||||
* [#110](https://github.com/pmd/pmd/pull/110): \[java] Fix parser error (issue 1530)
|
||||
* [#111](https://github.com/pmd/pmd/pull/111): \[java] Fix BooleanInstantiationRule for Java 8
|
||||
|
||||
**Bugfixes:**
|
||||
|
||||
* Java
|
||||
* [#1530](https://sourceforge.net/p/pmd/bugs/1530/): \[java] Parser exception on Java code
|
||||
* java-basic/BooleanInstantiation
|
||||
* [#1533](https://sourceforge.net/p/pmd/bugs/1533/): \[java] BooleanInstantiation: ClassCastException with Annotation
|
||||
* java-comments
|
||||
* [#1522](https://sourceforge.net/p/pmd/bugs/1522/): \[java] CommentRequired: false positive
|
||||
* java-imports/UnusedImports
|
||||
|
Reference in New Issue
Block a user