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 /ajde.core/src | |
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 'ajde.core/src')
4 files changed, 8 insertions, 8 deletions
diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java index eafa22f04..c692d6d50 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/AjdeCoreTestCase.java @@ -125,7 +125,7 @@ public abstract class AjdeCoreTestCase extends TestCase { public boolean checkFor(String what) { List<TestMessage> ll = ((TestMessageHandler) compiler.getMessageHandler()).getMessages(); for (TestMessage element: ll) { - if (element.toString().indexOf(what) != -1) + if (element.toString().contains(what)) return true; } return false; diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java index 2a293b626..e214faeae 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestBuildProgressMonitor.java @@ -52,7 +52,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -76,7 +76,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { public boolean containsMessage(String prefix,String distinguishingMarks) { for (String element: messagesReceived) { if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks)!=-1) return true; + element.contains(distinguishingMarks)) return true; } return false; } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java index 0696aa908..2d1b3fd7c 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/InpathTest.java @@ -242,7 +242,7 @@ public class InpathTest extends AjdeCoreTestCase { while (null != (entry = outjar.getNextEntry())) { String fileName = entry.getName(); fileName = fileName.replace('\\', '/'); - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutputJarContents.remove(fileName); assertTrue("Unexpectedly found : " + fileName + " in outjar", b); } @@ -295,7 +295,7 @@ public class InpathTest extends AjdeCoreTestCase { File binBase = openFile(outdirName); String[] toResources = FileUtil.listFiles(binBase); for (String fileName : toResources) { - if (fileName.indexOf("CVS") == -1) { + if (!fileName.contains("CVS")) { boolean b = expectedOutdirContents.remove(fileName); assertTrue("Extraneous resources: " + fileName, b); } @@ -310,7 +310,7 @@ public class InpathTest extends AjdeCoreTestCase { for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); // System.err.println("Checking "+name); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java index b6f44ae7d..889e2e5ce 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ResourceCopyTest.java @@ -169,7 +169,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter); for (File fromResource : fromResources) { String name = FileUtil.normalizedPath(fromResource, srcBase); - if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) { + if (!name.startsWith("CVS/") && (!name.contains("/CVS/")) && !name.endsWith("/CVS")) { resources.add(name); } } @@ -179,7 +179,7 @@ public class ResourceCopyTest extends AjdeCoreTestCase { @Override public boolean accept(File pathname) { String name = pathname.getName().toLowerCase(); - boolean isCVSRelated = name.indexOf("/cvs/") != -1; + boolean isCVSRelated = name.contains("/cvs/"); return (!isCVSRelated && !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj")); } }; |