When a method loops multiple over the same set of data, whether it's a list or a set of numbers, it is highly likely that the method could be made more efficient by combining the loops into a single set of iterations.
public void doSomethingToAList(List<String> strings) { for (String str : strings) { doStep1(str); } for (String str : strings) { // Noncompliant doStep2(str); } }
public void doSomethingToAList(List<String> strings) { for (String str : strings) { doStep1(str); doStep2(str); } }