#264 WhitespaceAround confused by generics

SVN_Head
closed
5
2012-10-10
2004-11-22
Baron Roberts
No

The "<" and ">" in generic declarations confuse the
WhitespaceAround check. The check assumes that the
generic declaration contains GT and LT operators and
complains that there should be whitespace around them.
At a minimum there should be a separate operator class
for the use of "<>" in generics. However, since the "<>"
in generics are not operators, a different check might
make more sense. In any case, the generics "<>" need
to be differentiated from the "<>" operators.

Discussion

  • Logged In: YES
    user_id=1022106

    I think the way forward on this is to enhance the checks to
    understand better the context of the GTs and LTs and act
    accordingly rather than to create fictitious tokens based on
    parsing context.

    Recent patches submitted seem to resolve the
    WhitespaceAround checks and I'll be reviiewing these and
    submitting when fully tested.

     
  • Logged In: YES
    user_id=1150256

    This patch is still not added in the 4.0 beta 1 version. Can
    this be done anytime soon; this bug creates a lot (!) of
    false positives in our codebase.

     
  • Logged In: YES
    user_id=1022106

    Fix committed to CVS HEAD.

    WhitespaceAround check now checks GENERIC_START ('<'),
    GENERIC_END ('>'), TYPE_EXTENSION_AND ('&') and
    WILDCARD_TYPE ('?') tokens by default but of course this can
    be turned off through configuration.

    Please let us know if this does the trick.

     
  • Logged In: YES
    user_id=1150256

    For easy use/configuration for every possible style wish, I
    would like to see the new tokens also available in the
    following checks: NoWhiteSpaceBefore and NoWhiteSpaceAfter
    and maybe even WhiteSpaceAfter.

     
  • Greg Luck
    Greg Luck
    2005-07-28

    Logged In: YES
    user_id=693320

    This issue is closed but is still failing.

    Project.java:29:17: '<' is not preceded with whitespace.

    The line is:

    private List<AssetReference> assetReferences;

    I have compiled from source CVS as of 27/7/05 which shows as
    checkstyle 4 beta 5.

    This bug should be reopened.

     
  • Logged In: YES
    user_id=1022106

    Greg:

    Could you please confirm that you have removed GENERIC_START and
    GENERIC_END tokens from the token set in your configuration.

     
  • Logged In: YES
    user_id=1022106

    Created 1255367 as I didn't update documentation on my initial commit.