aboutsummaryrefslogtreecommitdiffstats
path: root/taskdefs
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
commitc1c373f4278426308689db61f7758185e8f0401b (patch)
tree9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /taskdefs
parenta508fd5315c6330f2057c219aebc35b15d0ea497 (diff)
downloadaspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz
aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer. Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'taskdefs')
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java2
-rw-r--r--taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java6
-rw-r--r--taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java8
3 files changed, 8 insertions, 8 deletions
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
index 9aea9ae6d..84f661cd5 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
@@ -498,7 +498,7 @@ public class Ajc2 extends Javac {
}
// If there are stars we'll try to resolve the file here
- else if (line.indexOf("*") != -1) {
+ else if (line.contains("*")) {
log("The argfile line '" + line + "' is invalid",
Project.MSG_WARN);
}
diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
index c68a1eb59..8a7c8a511 100644
--- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
+++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
@@ -207,7 +207,7 @@ public class AjcTask extends MatchingTask {
int loc = path.lastIndexOf(prefix);
if ((-1 != loc) && ((loc + minLength) <= path.length())) {
String rest = path.substring(loc + prefixLength);
- if (-1 != rest.indexOf(File.pathSeparator)) {
+ if (rest.contains(File.pathSeparator)) {
return null;
}
if (rest.startsWith(infix) || rest.startsWith(altInfix)) {
@@ -827,7 +827,7 @@ public class AjcTask extends MatchingTask {
*/
public void setInpathDirCopyFilter(String filter) {
if (null != filter) {
- if (-1 == filter.indexOf("**/*.class")) {
+ if (!filter.contains("**/*.class")) {
filter = "**/*.class," + filter;
}
}
@@ -1344,7 +1344,7 @@ public class AjcTask extends MatchingTask {
String message = fail.getMessage();
if (LangUtil.isEmpty(message)) {
message = "<no message>";
- } else if (-1 != message.indexOf(USAGE_SUBSTRING)) {
+ } else if (message.contains(USAGE_SUBSTRING)) {
continue;
}
Throwable t = fail.getThrown();
diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
index b1f7c7b4f..4b387c21b 100644
--- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
+++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
@@ -178,7 +178,7 @@ public class AjcTaskTest extends TestCase {
String m = e.getMessage();
if (null == m) {
assertTrue("not " + exceptionString, false);
- } else if (-1 == m.indexOf(exceptionString)) {
+ } else if (!m.contains(exceptionString)) {
assertEquals(exceptionString, e.getMessage());
}
}
@@ -218,7 +218,7 @@ public class AjcTaskTest extends TestCase {
if (NOFILE.equals(input)) {
// add nothing
} else if (input.endsWith(".lst")) {
- if (-1 != input.indexOf(",")) {
+ if (input.contains(",")) {
throw new IllegalArgumentException(
"lists not supported: " + input);
} else if (null == testdataDir) {
@@ -695,7 +695,7 @@ public class AjcTaskTest extends TestCase {
}
assertTrue(
"expecting aspectj in classpath",
- (-1 != classpath.indexOf("aspectjrt.jar")));
+ (classpath.contains("aspectjrt.jar")));
}
CompilerArg createCompilerArg(String value) {
@@ -792,7 +792,7 @@ public class AjcTaskTest extends TestCase {
boolean matched = false;
for (int i = 0; !matched && (i < results.length); i++) {
String s = results[i];
- matched = (null != s) && (-1 != s.indexOf(DEFAULT));
+ matched = (null != s) && (s.contains(DEFAULT));
}
if (!matched) {
fail(DEFAULT + " not found in " + Arrays.asList(results));