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 /bridge | |
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 'bridge')
-rw-r--r-- | bridge/src/main/java/org/aspectj/bridge/MessageUtil.java | 4 | ||||
-rw-r--r-- | bridge/src/test/java/org/aspectj/bridge/MessageTest.java | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java index 6d85ea6f9..0393a5a58 100644 --- a/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java +++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java @@ -1101,8 +1101,8 @@ public class MessageUtil { return true; } boolean result = true; - for (int i = 0; i < sources.length; i++) { - if (!sink.handleMessage(sources[i])) { + for (IMessage source : sources) { + if (!sink.handleMessage(source)) { if (fastFail) { return false; } diff --git a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java index be30c48ba..d3bd73be6 100644 --- a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java +++ b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java @@ -74,18 +74,18 @@ public class MessageTest extends TestCase { public void testKind_isSameOrLessThan() { IMessage.Kind last; IMessage.Kind next = null; - for (Iterator<IMessage.Kind> iter = IMessage.KINDS.iterator(); iter.hasNext();) { - last = next; - next = iter.next(); - if (null == last) { - continue; - } - String label = "last: " + last + " next: " + next; - assertTrue(label, !next.isSameOrLessThan(null)); - assertTrue(label, !next.isSameOrLessThan(last)); - assertTrue(label, last.isSameOrLessThan(next)); - assertTrue(label, next.isSameOrLessThan(next)); - } + for (IMessage.Kind kind : IMessage.KINDS) { + last = next; + next = kind; + if (null == last) { + continue; + } + String label = "last: " + last + " next: " + next; + assertTrue(label, !next.isSameOrLessThan(null)); + assertTrue(label, !next.isSameOrLessThan(last)); + assertTrue(label, last.isSameOrLessThan(next)); + assertTrue(label, next.isSameOrLessThan(next)); + } } public void testMessageHandler() { |