Skip to content

Files

Latest commit

 

History

History
30 lines (21 loc) · 695 Bytes

UnusedArray.md

File metadata and controls

30 lines (21 loc) · 695 Bytes

Pattern: Unused array

Issue: -

Description

Checks for array allocations that are not assigned or used, unless it is the last statement within a block (because it may be the intentional return value). Examples include:

int someMethod() {
    new String[3]               // unused
    return -1
}

String[] someMethod() {
    new String[3]               // OK (last statement in block)
}

def closure = {
    doStuff()
    new Date[3]                 // unused
    doOtherStuff()
}

def closure = { new Date[3] }   // OK (last statement in block)

Further Reading