#241 avoid nested blocks should ignore case statements

release_3.2
closed
Lars Kühne
Check (274)
5
2012-10-10
2003-07-16
Nikolay Metchev
No

I think it should be possible to configure checkstyle to
warn about nested blocks but if that nested block is in a
case statement it shouldn't warn you about it:
e.g.

switch(a)
{
case 3:
{
//this is a nice nested block
}
}

public void method()
{
Math.abs(-123.3);
{
//this is a bad nested block
System.out.println("debug info");
}
}

Discussion

  • Lars Kühne
    Lars Kühne
    2003-07-19

    Logged In: YES
    user_id=401384

    We are way ahead of you :-)

    This has already been implemented in CVS and will be part of
    release 3.2. From the releasenotes: "Added allowInSwitchCase
    property to AvoidNestedBlocksCheck to allow limiting the
    scope of variables to one case of a switch statement."