Skip to content

Files

Latest commit

 

History

History
24 lines (16 loc) · 606 Bytes

ParameterReassignment.md

File metadata and controls

24 lines (16 loc) · 606 Bytes

Pattern: Parameter reassignment

Issue: -

Description

Checks for a method or closure parameter being reassigned to a new value within the body of the method/closure, which is a confusing and questionable practice. Use a temporary variable instead.

Example of violations:

void someMethod(int a, String b) {
    println a
    b = 'new value'     // violation
}

def someClosure1 = { int a, b ->
    a = 123             // violation
}

Further Reading