Avoid unexpected closure inside parentheses call

Why you should care

If a method is called and the last parameter is an inline closure then it can be declared outside of the method call parentheses, to comply with Groovy style programming.

How we detect

CAST Highlight counts one occurrence each time an inline closure is encountered inside parameters, in last position of the call parameters.

    [1,2,3].each({ println it })   // +1 VIOLATION
    [1,2,3].each { println it }    // OK

References

5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.