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