Merge branch 'pr-111'
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.sourceforge.pmd.lang.java.rule.basic;
|
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.ASTAllocationExpression;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
|
import net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits;
|
||||||
import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
|
import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
|
||||||
@ -63,7 +64,9 @@ public class BooleanInstantiationRule extends AbstractJavaRule {
|
|||||||
if (node.hasDescendantOfType(ASTArrayDimsAndInits.class)) {
|
if (node.hasDescendantOfType(ASTArrayDimsAndInits.class)) {
|
||||||
return super.visit(node, data);
|
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);
|
super.addViolation(data, node);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -158,4 +158,16 @@ public class Foo {
|
|||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-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>
|
||||||
</test-data>
|
</test-data>
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
* [#106](https://github.com/pmd/pmd/pull/106): \[java] CPD: Keep constructor names under ignoreIdentifiers
|
* [#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
|
* [#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)
|
* [#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:**
|
**Bugfixes:**
|
||||||
|
|
||||||
* Java
|
* Java
|
||||||
* [#1530](https://sourceforge.net/p/pmd/bugs/1530/): \[java] Parser exception on Java code
|
* [#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
|
* java-comments
|
||||||
* [#1522](https://sourceforge.net/p/pmd/bugs/1522/): \[java] CommentRequired: false positive
|
* [#1522](https://sourceforge.net/p/pmd/bugs/1522/): \[java] CommentRequired: false positive
|
||||||
* java-imports/UnusedImports
|
* java-imports/UnusedImports
|
||||||
|
Reference in New Issue
Block a user