Affects PMD Version:
6.22.0
Rule:
AvoidArrayLoops
Description:
It is recommended to have AvoidArrayLoops additionally check the case using that for loop + list.add() to copy a list
Similar to using for loop to manually copy data between two arrays, using for loop + list.add() to manually copy data between two list can also be simplified to Collections.addAll(dest, source)
Code Sample demonstrating the suggestion:
Example 1:
// can also be simplified to <code>Collections.addAll(rawData, dd)
double[] dd = sc.summaryStats();
for (double d : dd) {
rawData.add(d);
}
Example 2:
// can also be simplified to <code>Collections.addAll(mbeans, beans)
for (int i = 0; i < beans.length; i++) {
mbeans.add(beans[i]);
}
Type:
Suggestions for rule improvement
Running PMD through:
CLI
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4