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 /ajdoc/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 'ajdoc/src/test')
-rw-r--r-- | ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java | 8 | ||||
-rw-r--r-- | ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java | 13 |
2 files changed, 9 insertions, 12 deletions
diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java index 2100f7dba..b22d1250d 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java @@ -61,8 +61,7 @@ public class AjdocOutputChecker { */ public static List<String> getMissingStringsInFile(File htmlFile, String[] requiredStrings) throws Exception { List<String> missingStrings = new ArrayList<String>(); - for (int i = 0; i < requiredStrings.length; i++) { - String string = requiredStrings[i]; + for (String string : requiredStrings) { if (!containsString(htmlFile, string)) { missingStrings.add(string); } @@ -122,9 +121,8 @@ public class AjdocOutputChecker { public static List<String> getMissingStringsInSection(File htmlFile, String[] requiredStrings, String sectionHeader) throws Exception { List<String> missingStrings = new ArrayList<String>(); - for (int i = 0; i < requiredStrings.length; i++) { - String string = requiredStrings[i]; - if (!containsStringWithinSection(htmlFile,string,sectionHeader)) { + for (String string : requiredStrings) { + if (!containsStringWithinSection(htmlFile, string, sectionHeader)) { missingStrings.add(string); } } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java index 26dda1187..6dfd5633f 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocTestCase.java @@ -97,8 +97,7 @@ public abstract class AjdocTestCase extends TestCase { String contents[] = from.list(); if (contents == null) return; - for (int i = 0; i < contents.length; i++) { - String string = contents[i]; + for (String string : contents) { File f = new File(from, string); File t = new File(to, string); @@ -209,9 +208,9 @@ public abstract class AjdocTestCase extends TestCase { if (inputFiles.length == 0) { fail("need to pass some files into ajdoc"); } - for (int i = 0; i < inputFiles.length; i++) { - if (!inputFiles[i].exists()) { - fail(inputFiles[i].getAbsolutePath() + " does not exist"); + for (File inputFile : inputFiles) { + if (!inputFile.exists()) { + fail(inputFile.getAbsolutePath() + " does not exist"); } } @@ -305,8 +304,8 @@ public abstract class AjdocTestCase extends TestCase { public void runAjdoc(List options) { String[] args = new String[options.size()]; int i = 0; - for (Iterator iter = options.iterator(); iter.hasNext();) { - String element = (String) iter.next(); + for (Object option : options) { + String element = (String) option; args[i] = element; i++; } |