#352 usage.UnusedLocalVariable: Wrongly detected

release_4.0
closed
nobody
usage (27)
5
2014-07-11
2005-07-22
Marc Guillemot
No

usage.UnusedLocalVariable detects unused local
variables that are... used. It seems that it has to do
with parameterised types as shown in example below:

public class TestCheckstyle
{
/*
* @return a List

/
protected List getList()
{
Collection col = new Vector(); // wrongly
complains with "Unused local variable 'col'."
return new Vector<Object>(col);
}

/**
 * @return a List
 */
protected List getList2()
{
    Collection col = new Vector(); // doesn't

complain. Ok
return new Vector(col);
}
}

Discussion

  • Logged In: YES
    user_id=746148

    Unfortunately, we have no resources to support usage checks
    and thus we've moved them to contributed area. This means
    that we will not fix this problem until someone contributes
    a fix.

    So, I close this bug as will not fix. :(

    Sorry.

     
  • Marc Guillemot
    Marc Guillemot
    2005-07-22

    Logged In: YES
    user_id=402164

    Perhaps could you add a note about this problem to the
    documentation?