From 72194b7982ddfa8e9864d0a9934905bb76b90f33 Mon Sep 17 00:00:00 2001 From: Lars Grefer Date: Sat, 8 Aug 2020 03:06:37 +0200 Subject: '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 --- .../src/main/java/org/aspectj/tools/ajbrowser/BrowserManager.java | 6 +++--- ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/Main.java | 4 ++-- .../aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java | 3 +-- .../org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'ajbrowser') diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/BrowserManager.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/BrowserManager.java index 84bb63683..e59c16103 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/BrowserManager.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/BrowserManager.java @@ -183,9 +183,9 @@ public class BrowserManager { private List getConfigFilesList(String[] configFiles) { List configs = new ArrayList(); - for (int i = 0; i < configFiles.length; i++) { - if (configFiles[i].endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { - configs.add(configFiles[i]); + for (String configFile : configFiles) { + if (configFile.endsWith(BuildConfigManager.CONFIG_FILE_SUFFIX)) { + configs.add(configFile); } } return configs; diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/Main.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/Main.java index 76c1b50e2..6d56a6f2a 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/Main.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/Main.java @@ -42,8 +42,8 @@ public class Main { return false; } int numConfigFiles = 0; - for (int i = 0; i < args.length; i++) { - if ((null != args[i]) && args[i].endsWith(".lst")) { + for (String arg : args) { + if ((null != arg) && arg.endsWith(".lst")) { numConfigFiles++; } } diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java index 35f676e1b..0295a9a24 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/core/BrowserCompilerConfiguration.java @@ -43,8 +43,7 @@ public class BrowserCompilerConfiguration implements ICompilerConfiguration { classpath.append(userPath); } List outputDirs = getOutputLocationManager().getAllOutputLocations(); - for (Iterator iterator = outputDirs.iterator(); iterator.hasNext();) { - File dir = (File) iterator.next(); + for (File dir : outputDirs) { classpath.append(File.pathSeparator + dir.getAbsolutePath() + File.pathSeparator); } classpath.append(System.getProperty("java.class.path", ".")); diff --git a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java index fa24f709f..d3abd95eb 100644 --- a/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java +++ b/ajbrowser/src/main/java/org/aspectj/tools/ajbrowser/ui/swing/MessageHandlerPanel.java @@ -73,8 +73,8 @@ public class MessageHandlerPanel extends JPanel { private void createList(List messages) { list = new JList(); listModel = new DefaultListModel(); - for (Iterator iterator = messages.iterator(); iterator.hasNext();) { - listModel.addElement(iterator.next()); + for (IMessage message : messages) { + listModel.addElement(message); } } -- cgit v1.2.3