diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:06:37 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:06:37 +0200 |
commit | 72194b7982ddfa8e9864d0a9934905bb76b90f33 (patch) | |
tree | ebed806c358c1a3960c5d6be4c13b26ca41809df /util/src/test | |
parent | c3289ab86bfb2c97cf34147239b3dde46de92a7c (diff) | |
download | aspectj-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 'util/src/test')
-rw-r--r-- | util/src/test/java/org/aspectj/util/FileUtilTest.java | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/util/src/test/java/org/aspectj/util/FileUtilTest.java b/util/src/test/java/org/aspectj/util/FileUtilTest.java index 2d61a6a79..367c0ea5e 100644 --- a/util/src/test/java/org/aspectj/util/FileUtilTest.java +++ b/util/src/test/java/org/aspectj/util/FileUtilTest.java @@ -166,13 +166,13 @@ public class FileUtilTest extends TestCase { return; } File[] files = dir.listFiles(); - for (int i = 0; i < files.length; i++) { - String path = files[i].getPath(); - if (!files[i].getName().startsWith(".")) { - if (files[i].isFile()) { + for (File file : files) { + String path = file.getPath(); + if (!file.getName().startsWith(".")) { + if (file.isFile()) { paths.add(path); - } else if (files[i].isDirectory()) { - doDirPaths(files[i], paths); + } else if (file.isDirectory()) { + doDirPaths(file, paths); } else { log("not file or dir: " + dir + "/" + path); } @@ -325,8 +325,8 @@ public class FileUtilTest extends TestCase { public void testGetURL() { String[] args = new String[] { ".", "../util/testdata", "../lib/test/aspectjrt.jar" }; - for (int i = 0; i < args.length; i++) { - checkGetURL(args[i]); + for (String arg : args) { + checkGetURL(arg); } } @@ -496,8 +496,8 @@ public class FileUtilTest extends TestCase { sb.append(LangUtil.EOL); } final String contents = sb.toString(); - for (int i = 0; i < sources.length; i++) { - File file = new File(sources[i]); + for (String source : sources) { + File file = new File(source); FileUtil.writeAsString(file, contents); tempFiles.add(file); } @@ -588,9 +588,9 @@ public class FileUtilTest extends TestCase { assertTrue(d.exists()); tempFiles.add(d); assertTrue(d.canWrite()); - for (int i = 0; i < filenames.length; i++) { - File f = new File(d, filenames[i]); - assertTrue(filenames[i], f.createNewFile()); + for (String filename : filenames) { + File f = new File(d, filename); + assertTrue(filename, f.createNewFile()); } return d; } |