Inspectopedia Help

Local variable is reassigned in closure or anonymous class

Reports local variables assigned to expression with different type inside of closure or anonymous class.


int sum = 0 [1, 2, 3].each { sum += 'as' } println(sum)

As a result, the integer variable sum is reassigned to a String expression.

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Groovy, 241.16690

Last modified: 29 April 2024