create "should use collect" rule
Brought to you by:
chrismair
create "should use collect" rule
Fails:
def x = []
y.each {
y = it * 2
x.add y
}
---
def x = []
5.times {
x.add it
}
---
def x = []
for (Object o1 : o2) {
x.add o1
}
Passes:
def x = y.collect { it }
---
def x = []
y.each {
y = it * 2
x.add y
println x // passes b/c add is not last statement in block
}
---
def x = []
foo().times {
y = it * 2
x.add y
println x // passes b/c add is not last statement in block
}
---
def x = []
for (Object o1 : o2) {
x.add o1
println x // passes b/c add is not last statement in block
}