aboutsummaryrefslogtreecommitdiffstats
path: root/testing-util
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:06:37 +0200
commit72194b7982ddfa8e9864d0a9934905bb76b90f33 (patch)
treeebed806c358c1a3960c5d6be4c13b26ca41809df /testing-util
parentc3289ab86bfb2c97cf34147239b3dde46de92a7c (diff)
downloadaspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.tar.gz
aspectj-72194b7982ddfa8e9864d0a9934905bb76b90f33.zip
'for' loop replaceable with enhanced 'for' loop
Reports for loops which iterate over collections or arrays, and can be replaced with an enhanced for loop (i.e. the foreach iteration syntax). Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'testing-util')
-rw-r--r--testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java16
-rw-r--r--testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java12
2 files changed, 14 insertions, 14 deletions
diff --git a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
index ef6109e37..6be6cc61e 100644
--- a/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
+++ b/testing-util/src/main/java/org/aspectj/testing/util/TestUtil.java
@@ -126,8 +126,8 @@ public final class TestUtil {
// TODO support others loaded dynamically
Map<String,Object> map = new HashMap<>();
- for (Iterator<Object> iter = LIB_RPATHS.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
+ for (Object o : LIB_RPATHS.keySet()) {
+ String key = (String) o;
String path = LIB_RPATHS.getProperty(key);
File file = null;
URL url = null;
@@ -206,14 +206,14 @@ public final class TestUtil {
}
StringBuffer path = new StringBuffer();
boolean started = false;
- for (int i = 0; i < entries.length; i++) {
- if (null != entries[i]) {
+ for (Object entry : entries) {
+ if (null != entry) {
if (started) {
path.append(File.pathSeparator);
} else {
started = true;
}
- path.append(entries[i].toString());
+ path.append(entry.toString());
}
}
return path.toString();
@@ -476,11 +476,11 @@ public final class TestUtil {
}
String[] paths = FileUtil.listFiles(expectedBaseDir);
boolean result = true;
- for (int i = 0; i < paths.length; i++) {
- if (-1 != paths[i].indexOf("CVS")) {
+ for (String path : paths) {
+ if (-1 != path.indexOf("CVS")) {
continue;
}
- if (!sameFiles(handler, expectedBaseDir, actualBaseDir, paths[i]) && result) {
+ if (!sameFiles(handler, expectedBaseDir, actualBaseDir, path) && result) {
result = false;
if (fastFail) {
break;
diff --git a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java
index 3a514a0ed..0807bd2a3 100644
--- a/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java
+++ b/testing-util/src/test/java/org/aspectj/testingutil/TestUtilTest.java
@@ -96,15 +96,15 @@ public class TestUtilTest extends TestCase {
public void testParseBoolean() {
{
String[] trues = {"true", "TRUE", "on", "ON" };
- for (int i = 0; i < trues.length; i++) {
- assertTrue(trues[i], TestUtil.parseBoolean(trues[i]));
- }
+ for (String aTrue : trues) {
+ assertTrue(aTrue, TestUtil.parseBoolean(aTrue));
+ }
}
{
String[] falses = {"false", "FALSE", "off", "off" };
- for (int i = 0; i < falses.length; i++) {
- assertTrue(falses[i], !TestUtil.parseBoolean(falses[i]));
- }
+ for (String fals : falses) {
+ assertTrue(fals, !TestUtil.parseBoolean(fals));
+ }
}
String[] errors = {"fals", "tru", "T", "on of" };
boolean fail = false;