aboutsummaryrefslogtreecommitdiffstats
path: root/build/src/test/java/org
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 /build/src/test/java/org
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 'build/src/test/java/org')
-rw-r--r--build/src/test/java/org/aspectj/build/BuildModuleTests.java33
-rw-r--r--build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java69
-rw-r--r--build/src/test/java/org/aspectj/internal/build/ModulesTest.java35
-rw-r--r--build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java35
4 files changed, 84 insertions, 88 deletions
diff --git a/build/src/test/java/org/aspectj/build/BuildModuleTests.java b/build/src/test/java/org/aspectj/build/BuildModuleTests.java
index 7f7550279..042548d3f 100644
--- a/build/src/test/java/org/aspectj/build/BuildModuleTests.java
+++ b/build/src/test/java/org/aspectj/build/BuildModuleTests.java
@@ -114,8 +114,8 @@ public class BuildModuleTests extends TestCase {
public void testLicense_org_eclipse_jdt_core() {
final String mod = "org.eclipse.jdt.core";
final String pre = BASE_DIR + mod + File.separator;
- for (int i = 0; i < JDT_SOURCE_DIRS.length; i++) {
- checkSourceDirectory(new File(pre + JDT_SOURCE_DIRS[i]), mod);
+ for (String jdtSourceDir : JDT_SOURCE_DIRS) {
+ checkSourceDirectory(new File(pre + jdtSourceDir), mod);
}
}
@@ -167,10 +167,10 @@ public class BuildModuleTests extends TestCase {
void checkLicense(String module) {
File moduleDir = new File(Util.path("..", module));
File[] srcDirs = findSourceRoots(moduleDir);
- for (int i = 0; i < srcDirs.length; i++) {
- System.out.println(srcDirs[i]);
- checkSourceDirectory(srcDirs[i], module);
- }
+ for (File srcDir : srcDirs) {
+ System.out.println(srcDir);
+ checkSourceDirectory(srcDir, module);
+ }
}
void checkSourceDirectory(File srcDir, String module) {
@@ -294,17 +294,16 @@ public class BuildModuleTests extends TestCase {
}
void unknownFiles(File dir, ArrayList<File> results) {
File[] files = dir.listFiles(this);
- for (int j = 0; j < files.length; j++) {
- File file = files[j];
- if (file.isDirectory()) {
- String name = file.getName();
- if (!("CVS".equals(name))) {
- unknownFiles(file, results);
- }
- } else {
- results.add(file);
- }
- }
+ for (File file : files) {
+ if (file.isDirectory()) {
+ String name = file.getName();
+ if (!("CVS".equals(name))) {
+ unknownFiles(file, results);
+ }
+ } else {
+ results.add(file);
+ }
+ }
}
}
diff --git a/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java
index 4a949b447..81600ca94 100644
--- a/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java
+++ b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java
@@ -106,24 +106,23 @@ public class BuildModuleTest extends TestCase {
}
protected void deleteTempFiles() {
- for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
- if (!Util.delete(file)) {
- File[] list = file.listFiles();
- if (!Util.isEmpty(list)) {
- StringBuffer sb = new StringBuffer();
- sb.append("warning: BuildModuleTest unable to delete ");
- sb.append(file.toString());
- sb.append("\n"); // XXX platform
- for (int i = 0; i < list.length; i++) {
- sb.append(" ");
- sb.append(list[i].toString());
- sb.append("\n"); // XXX platform
- }
- System.err.println(sb.toString());
- }
- }
- }
+ for (File file : tempFiles) {
+ if (!Util.delete(file)) {
+ File[] list = file.listFiles();
+ if (!Util.isEmpty(list)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("warning: BuildModuleTest unable to delete ");
+ sb.append(file.toString());
+ sb.append("\n"); // XXX platform
+ for (File value : list) {
+ sb.append(" ");
+ sb.append(value.toString());
+ sb.append("\n"); // XXX platform
+ }
+ System.err.println(sb.toString());
+ }
+ }
+ }
}
public void testAllJunitTests() {
@@ -318,21 +317,21 @@ public class BuildModuleTest extends TestCase {
printedMessage = true;
}
if (debugging()) {
- for (int i = 0; i < DEBUGS.length; i++) {
- if (target.equals(DEBUGS[i])) {
- return true;
- }
- }
+ for (String debug : DEBUGS) {
+ if (target.equals(debug)) {
+ return true;
+ }
+ }
return false;
} else {
- for (int i = 0; i < SKIPS.length; i++) {
- if (SKIPS[i].equals(target)) {
- if (printInfoMessages) {
- System.err.println(target + " skipped build test [" + getClass().getName() + ".shouldBuild(..)]");
- }
- return false;
- }
- }
+ for (String skip : SKIPS) {
+ if (skip.equals(target)) {
+ if (printInfoMessages) {
+ System.err.println(target + " skipped build test [" + getClass().getName() + ".shouldBuild(..)]");
+ }
+ return false;
+ }
+ }
}
return building;
}
@@ -419,10 +418,10 @@ public class BuildModuleTest extends TestCase {
java.setClasspath(cp);
java.setClassname(classname);
if (null != args) {
- for (int i = 0; i < args.length; i++) {
- Argument arg = java.createArg();
- arg.setValue(args[i]);
- }
+ for (String s : args) {
+ Argument arg = java.createArg();
+ arg.setValue(s);
+ }
}
try {
java.execute();
diff --git a/build/src/test/java/org/aspectj/internal/build/ModulesTest.java b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java
index 496cde051..383b3859d 100644
--- a/build/src/test/java/org/aspectj/internal/build/ModulesTest.java
+++ b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java
@@ -62,12 +62,12 @@ public class ModulesTest extends TestCase {
} else {
File[] files = file.listFiles();
boolean result = true;
- for (int i = 0; i < files.length; i++) {
- if (!ModulesTest.delete(files[i])
- && result) {
- result = false;
- }
- }
+ for (File value : files) {
+ if (!ModulesTest.delete(value)
+ && result) {
+ result = false;
+ }
+ }
return (file.delete() && result);
}
}
@@ -80,11 +80,10 @@ public class ModulesTest extends TestCase {
protected void tearDown() throws Exception {
super.tearDown();
- for (Iterator<File> iter = tempFiles.iterator(); iter.hasNext();) {
- File file = (File) iter.next();
- if (!ModulesTest.delete(file)) {
- System.err.println("warning: ModulesTest unable to delete " + file);
- }
+ for (File file : tempFiles) {
+ if (!ModulesTest.delete(file)) {
+ System.err.println("warning: ModulesTest unable to delete " + file);
+ }
}
}
@@ -270,13 +269,13 @@ public class ModulesTest extends TestCase {
File libDir = new File(distDir, "tools/lib");
String[] jars = { "tools", "rt", "weaver", "lib"};
- for (int i = 0; i < jars.length; i++) {
- File jar = new File(libDir, "aspectj" + jars[i] + ".jar");
- assertTrue(jar.getPath(), jar.canRead());
- if (10 > jar.length()) {
- assertTrue(jar + " too small", false);
- }
- }
+ for (String s : jars) {
+ File jar = new File(libDir, "aspectj" + s + ".jar");
+ assertTrue(jar.getPath(), jar.canRead());
+ if (10 > jar.length()) {
+ assertTrue(jar + " too small", false);
+ }
+ }
}
/**
* Show messages from the task.
diff --git a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java
index 4926d42e8..e044afc01 100644
--- a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java
+++ b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java
@@ -49,21 +49,20 @@ public class UtilsTest extends TestCase {
"aspectjrt" }) {
void checkOthers(OSGIBundle osgiBundle, StringBuffer sb) {
RequiredBundle[] bundles = osgiBundle.getRequiredBundles();
- for (int i = 0; i < bundles.length; i++) {
- RequiredBundle bundle = bundles[i];
- if ("aspectjrt".equals(bundle.name)) {
- if (!bundle.optional) {
- sb
- .append("expected required bundle aspectjrt to be optional");
- }
- String version = "[1.5.0,1.5.5]";
- if (!(version.equals(bundle.versions))) {
- sb.append("expected version " + version
- + " got " + bundle.versions
- + " for required bundle aspectjrt");
- }
- }
- }
+ for (RequiredBundle bundle : bundles) {
+ if ("aspectjrt".equals(bundle.name)) {
+ if (!bundle.optional) {
+ sb
+ .append("expected required bundle aspectjrt to be optional");
+ }
+ String version = "[1.5.0,1.5.5]";
+ if (!(version.equals(bundle.versions))) {
+ sb.append("expected version " + version
+ + " got " + bundle.versions
+ + " for required bundle aspectjrt");
+ }
+ }
+ }
}
} };
@@ -140,9 +139,9 @@ public class UtilsTest extends TestCase {
/** disabled pending research */
public void skip_testOSGIManifests() throws Exception {
StringBuffer sb = new StringBuffer();
- for (int i = 0; i < TESTS.length; i++) {
- TESTS[i].run(sb);
- }
+ for (ManifestTest test : TESTS) {
+ test.run(sb);
+ }
if (0 < sb.length()) {
fail(sb.toString());
}