diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
commit | c1c373f4278426308689db61f7758185e8f0401b (patch) | |
tree | 9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /build | |
parent | a508fd5315c6330f2057c219aebc35b15d0ea497 (diff) | |
download | aspectj-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 'build')
4 files changed, 7 insertions, 7 deletions
diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java index bef3fb0aa..12286748e 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/AntBuilder.java @@ -61,10 +61,10 @@ public class AntBuilder extends Builder { boolean useEclipseCompiles = false; boolean verbose = false; if (null != config) { - if (-1 != config.indexOf("useEclipseCompiles")) { + if (config.contains("useEclipseCompiles")) { useEclipseCompiles = true; } - if (-1 != config.indexOf("verbose")) { + if (config.contains("verbose")) { verbose = true; } } diff --git a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java index afa3c71d3..aa0c35e35 100644 --- a/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java +++ b/build/src/main/java/org/aspectj/internal/tools/ant/taskdefs/Checklics.java @@ -422,7 +422,7 @@ public class Checklics extends MatchingTask { if ((null == line) || (0 == line.length())) { return; } - if (!gotLicense && (null != license) && (-1 != line.indexOf(license))) { + if (!gotLicense && (null != license) && (line.contains(license))) { gotLicense = true; } if (!gotCopyright && (null != copyright)) { @@ -670,7 +670,7 @@ class Header { start = loc + 4; } - return (-1 != line.indexOf("*/")); + return (line.contains("*/")); } } // class Header diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java index 1d7bfa7d8..fe80190ad 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.java @@ -251,7 +251,7 @@ public abstract class Builder { */ protected Result specifyResultFor(BuildSpec buildSpec) { if (buildSpec.trimTesting - && (-1 != buildSpec.module.indexOf("testing"))) { // XXXNameLiteral + && (buildSpec.module.contains("testing"))) { // XXXNameLiteral String warning = "Warning - cannot trimTesting for testing modules: "; handler.log(warning + buildSpec.module); } diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Module.java b/build/src/main/java/org/aspectj/internal/tools/build/Module.java index acc8fd90b..65d929707 100644 --- a/build/src/main/java/org/aspectj/internal/tools/build/Module.java +++ b/build/src/main/java/org/aspectj/internal/tools/build/Module.java @@ -444,7 +444,7 @@ public class Module { if (path.equals("org.eclipse.ajdt.core.ASPECTJRT_CONTAINER")) { classpathVariables.add("ASPECTJRT_LIB"); } else { - if (-1 == path.indexOf("JRE")) { // warn non-JRE containers + if (!path.contains("JRE")) { // warn non-JRE containers messager.log("cannot handle con yet: " + toString); } } @@ -614,7 +614,7 @@ public class Module { boolean inQuote = false; while (st.hasMoreTokens()) { String s = st.nextToken(); - if ((1 == s.length()) && (-1 != DELIM.indexOf(s))) { + if ((1 == s.length()) && (DELIM.contains(s))) { if ("\"".equals(s)) { // end quote (or escaped) if (inQuote) { inQuote = false; |