#429 Defaults for WhitespaceAfter and NoWhitespaceAfter clash

release_4.2
closed
Oliver Burn
5
2012-10-10
2006-05-10
No

As a result of the fix for rfe 1248106, the defaults for WhitespaceAfter
and NoWhitespaceAfter both want to claim TYPECASTs.

My reading of rfe 1248106 was that they only wanted the option of
using NoWhitespaceAfter with typecasts. However the change has
made it the default.

Either WhitespaceAfter's defaults should change to not include
typecasts (which could cause problems for existing checkstyle
configurations that assume those defaults), or NoWhitespaceAfter's
defaults should change to not include typecasts.

See:
Revision 1.7 of cvs: checkstyle/checkstyle/src/checkstyle/com/
puppycrawl/tools/checkstyle/checks/whitespace/
NoWhitespaceAfterCheck.java

See:
Feature request 1248106

Discussion

  • Logged In: YES
    user_id=588200

    I can confirm this bug. It shows up when you have something
    like:
    String x = (String) someMethod();
    where someMethod doesn't return a string so it has to be
    casted.

    This satisfies the violation:
    String x = (String)someMethod();

    I vote for NoWhitespaceAfter's
    defaults should change to not include typecasts.

     
  • Logged In: YES
    user_id=588200

    Temporary workaround is:
    <module name="NoWhitespaceAfter">
    <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PL US"/>
    </module>

     
  • Oliver Burn
    Oliver Burn
    2006-05-23

    Logged In: YES
    user_id=218824

    I just got burnt by this as well - and will fix.

     
  • Oliver Burn
    Oliver Burn
    2006-06-17

    Logged In: YES
    user_id=218824

    Fixed in CVS.