Fix tests
This commit is contained in:
@ -95,15 +95,7 @@ public abstract class AbstractJUnitRule extends AbstractJavaRule {
|
||||
|
||||
private boolean isJUnit3Class(ASTCompilationUnit node) {
|
||||
ASTClassOrInterfaceDeclaration cid = node.getFirstDescendantOfType(ASTClassOrInterfaceDeclaration.class);
|
||||
if (cid == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TypeTestUtil.isA(JUNIT3_CLASS_NAME, node)) {
|
||||
return true;
|
||||
} else {
|
||||
return cid.getSimpleName().endsWith("Test");
|
||||
}
|
||||
return TypeTestUtil.isA(JUNIT3_CLASS_NAME, cid);
|
||||
}
|
||||
|
||||
private boolean isJUnit4Class(ASTCompilationUnit node) {
|
||||
|
@ -71,10 +71,10 @@ public class MoreThanOneLoggerRule extends AbstractJavaRule {
|
||||
Node classOrIntType = reftypeNode.getChild(0);
|
||||
if (classOrIntType instanceof ASTClassOrInterfaceType) {
|
||||
ASTClassOrInterfaceType classType = (ASTClassOrInterfaceType) classOrIntType;
|
||||
if ((TypeTestUtil.isA(LOG4J_LOGGER_NAME, classType)
|
||||
if (TypeTestUtil.isA(LOG4J_LOGGER_NAME, classType)
|
||||
|| TypeTestUtil.isA(LOG4J2_LOGGER_NAME, classType)
|
||||
|| TypeTestUtil.isA(JAVA_LOGGER_NAME, classType)
|
||||
|| TypeTestUtil.isA(SLF4J_LOGGER_NAME, classType))
|
||||
|| TypeTestUtil.isA(SLF4J_LOGGER_NAME, classType)
|
||||
|| "Logger".equals(classOrIntType.getImage())) {
|
||||
++count;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public final class TypeTestUtil {
|
||||
|
||||
if (n instanceof ASTAnyTypeDeclaration) {
|
||||
ASTAnyTypeDeclaration decl = (ASTAnyTypeDeclaration) n;
|
||||
if ((decl).getBinaryName().equals(canonicalName)) {
|
||||
if (decl.getBinaryName().equals(canonicalName)) {
|
||||
return true;
|
||||
} else if (!considerSubtype) { // otherwise fallthrough
|
||||
return false;
|
||||
|
@ -135,6 +135,7 @@ class Foo {
|
||||
<description>Consider iterators</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.util.Iterator;
|
||||
class Foo {
|
||||
void loop() {
|
||||
Iterable<DataFlowNode> path = null;
|
||||
@ -225,6 +226,7 @@ class StringPropertyTest {
|
||||
<description>Consider iterators only if safe</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.util.Iterator;
|
||||
class Foo {
|
||||
void loop() {
|
||||
Iterable<DataFlowNode> path = null;
|
||||
@ -245,6 +247,7 @@ class Foo {
|
||||
<description>Do not report iterator loop if we can't find iterator decl</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.util.Iterator;
|
||||
class Foo {
|
||||
void loop() {
|
||||
for (Iterator<DataFlowNode> i = path.iterator(); i.hasNext();) {
|
||||
@ -284,6 +287,7 @@ class Foo<T> implements Iterable<T> {
|
||||
<description>Iterating on multiple iterators should whitelist the loop, refs #784</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import java.util.Iterator;
|
||||
class Foo {
|
||||
void loop() {
|
||||
Iterable<E> it;
|
||||
|
Reference in New Issue
Block a user