indexOf to contains
This commit is contained in:
@ -79,7 +79,7 @@ public class ParametricRuleViolation<T extends Node> implements RuleViolation {
|
||||
|
||||
protected String expandVariables(String message) {
|
||||
|
||||
if (message.indexOf("${") < 0) {
|
||||
if (!message.contains("${")) {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
@ -131,21 +131,21 @@ public class SourceObject {
|
||||
LOG.entering(CLASS_NAME, "getSuffixFromType", this);
|
||||
if (null == type || type.isEmpty()) {
|
||||
return "";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("JAVA") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("JAVA")) {
|
||||
return ".java";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("TRIGGER") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("TRIGGER")) {
|
||||
return ".trg";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("FUNCTION") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("FUNCTION")) {
|
||||
return ".fnc";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("PROCEDURE") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("PROCEDURE")) {
|
||||
return ".prc";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("PACKAGE_BODY") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("PACKAGE_BODY")) {
|
||||
return ".pkb";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("PACKAGE") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("PACKAGE")) {
|
||||
return ".pks";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("TYPE_BODY") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("TYPE_BODY")) {
|
||||
return ".tpb";
|
||||
} else if (type.toUpperCase(Locale.ROOT).indexOf("TYPE") >= 0) {
|
||||
} else if (type.toUpperCase(Locale.ROOT).contains("TYPE")) {
|
||||
return ".tps";
|
||||
} else {
|
||||
return "";
|
||||
|
@ -75,7 +75,7 @@ public abstract class AbstractPoorMethodCall extends AbstractJavaRule {
|
||||
String[] methodNames = methodNames();
|
||||
|
||||
for (String element : methodNames) {
|
||||
if (methodCall.indexOf(element) != -1) {
|
||||
if (methodCall.contains(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public class JUnitTestsShouldIncludeAssertRule extends AbstractJUnitRule {
|
||||
Node name = pe.getFirstDescendantOfType(ASTName.class);
|
||||
if (name != null) {
|
||||
String img = name.getImage();
|
||||
if (img.indexOf(".") == -1) {
|
||||
if (!img.contains(".")) {
|
||||
return false;
|
||||
}
|
||||
String[] tokens = img.split("\\.");
|
||||
|
@ -18,14 +18,14 @@ public class PositionalIteratorRule extends AbstractJavaRule {
|
||||
public Object visit(ASTWhileStatement node, Object data) {
|
||||
if (hasNameAsChild(node.getChild(0))) {
|
||||
String exprName = getName(node.getChild(0));
|
||||
if (exprName.indexOf(".hasNext") != -1 && node.getNumChildren() > 1) {
|
||||
if (exprName.contains(".hasNext") && node.getNumChildren() > 1) {
|
||||
|
||||
Node loopBody = node.getChild(1);
|
||||
List<String> names = new ArrayList<>();
|
||||
collectNames(getVariableName(exprName), names, loopBody);
|
||||
int nextCount = 0;
|
||||
for (String name : names) {
|
||||
if (name.indexOf(".next") != -1) {
|
||||
if (name.contains(".next")) {
|
||||
nextCount++;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class SignatureDeclareThrowsExceptionRule extends AbstractJavaRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTImportDeclaration node, Object o) {
|
||||
if (node.getImportedName().indexOf("junit") != -1) {
|
||||
if (node.getImportedName().contains("junit")) {
|
||||
junitImported = true;
|
||||
}
|
||||
return super.visit(node, o);
|
||||
|
@ -46,7 +46,7 @@ public class InefficientEmptyStringCheckRule extends AbstractInefficientZeroChec
|
||||
@Override
|
||||
public boolean isTargetMethod(JavaNameOccurrence occ) {
|
||||
if (occ.getNameForWhichThisIsAQualifier() != null
|
||||
&& occ.getNameForWhichThisIsAQualifier().getImage().indexOf("trim") != -1) {
|
||||
&& occ.getNameForWhichThisIsAQualifier().getImage().contains("trim")) {
|
||||
Node pExpression = occ.getLocation().getParent().getParent();
|
||||
if (pExpression.getNumChildren() > 2 && "length".equals(pExpression.getChild(2).getImage())) {
|
||||
return true;
|
||||
|
@ -181,7 +181,7 @@ public class InefficientStringBufferingRule extends AbstractJavaRule {
|
||||
return false;
|
||||
}
|
||||
ASTName n = s.getFirstDescendantOfType(ASTName.class);
|
||||
if (n == null || n.getImage().indexOf(methodName) == -1
|
||||
if (n == null || !n.getImage().contains(methodName)
|
||||
|| !(n.getNameDeclaration() instanceof VariableNameDeclaration)) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user