#388 Turn off checks with SuppressWarnings?

open
nobody
None
3
2012-10-10
2005-09-27
Ian Brown
No

How about the idea of putting Annotation support into
rules such that, for example, you could disable a
particular check for a section of code with either an
@SuppressWarning or similar?

It would mean, probably, different builds for Java 5, but
it'd be well worth it.

I'd guess that each Check would need to test for its
Annotation in code when assessing it - unless you
could put the test into a base class or configuration.

It's the equivalent of the developer saying "I'm breaking a
rule here - but I have a good reason"

Discussion

  • Oliver Burn
    Oliver Burn
    2005-09-27

    Logged In: YES
    user_id=218824

    You know that we already support the
    SuppressionCommentFilter which allows you to achieve this
    functionality now.

     
  • Ian Brown
    Ian Brown
    2005-09-30

    Logged In: YES
    user_id=513630

    Cool. Sorry that I hadn't spotted that previously.

    I'm still tempted to suggest an @SuppressWarnings thing
    though - it's prettier, there is no need to encode the 'end' of
    the suppression, and Checkstyle can lead the way for other
    tools to do the same - just like compiler vendors will be doing

    If I happen to write this filter (I'll try), would you be interested
    in having it contributed?

     
  • Oliver Burn
    Oliver Burn
    2005-10-01

    Logged In: YES
    user_id=218824

    Naturally we are interested in contributions. Just bear in mind
    that any patches need to:
    - Pass Checkstyle
    - Have unit tests
    - Be documented