Checkstyle warning suppression "the Java 5 way". :-)
Some examples from the unit test:
@SuppressWarnings("parameternumber")
public void needsLotsOfParameters(int a, int b, int c, int d, int e,
int f,
int g, int h)
{
}
@SuppressWarnings("illegalcatch")
public void needsToCatchException()
{
try {
} catch (Exception ex) {
// should NOT fail IllegalCatchCheck
}
}
Addresses these feature requests:
[ 1306338 ] Turn off checks with SuppressWarnings?
http://sourceforge.net/tracker/index.php?func=detail&aid=1306338&group_id=2
9721&atid=397081
[ 1841127 ] filter annotation
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=1841127&group_
id=29721
Functional design notes: I decided to use "javac -Xlint"-style warning
names (i.e. lower-case, no punctuation) rather than using a prefix (e.g.
"checkstyle:parameternumber") or Checkstyle class names (e.g.
"ParameterNumberCheck") in the hopes of moving toward a standard set of
names across different tools. For the same reason, I included no provision
for wildcards, regex, abbreviations, or user-configurable aliases.
Technical design notes: Since filters do not have access to the AST, I
followed the SuppressionCommentFilter pattern of using a helper Check,
SuppressWarningsHolder, to store the necessary AST-derived information for
the last file processed in a thread-local variable. However, since the
necessary information is more specific and complex than the comments
gathered by FileContentsHolder, SuppressWarningsHolder goes the extra step
of building a list of suppression regions itself. This allows it to
completely encapsulate the suppression checking, making
SuppressWarningsFilter a trivial wrapper.
Oliver Burn
None
None
Public
|
Date: 2009-07-30 07:08 Yes, the current patch is not applied due to lack of documentation. A patch |
|
Date: 2009-07-24 14:02 I for one would very much like to see this patch (or something like it) |
|
Date: 2009-03-08 10:53 OK - I would like to apply this patch since there is clearly demand for it. |
|
Date: 2009-01-16 13:41 I haven't put a lot of time evaluating your check (it looks well thought |
|
Date: 2009-01-14 20:27 I can't wait for this patch to be integrated! Thanks for the patch Trevor. |
|
Date: 2009-01-13 21:48 Any thoughts on the updated patch? |
|
Date: 2008-12-10 19:09 I've updated the patch file to automatically generate suppression names for |
|
Date: 2008-11-29 06:36 I understand that suppressions are a controversial issue. We've recently |
|
Date: 2008-11-29 04:52 Thanks for the patch Trevor. Although I personally like to keep |
| Filename | Description | Download |
|---|---|---|
| SuppressWarnings.patch.tgz | Updated patch file | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| assigned_to | nobody | 2009-03-08 10:53 | oburn |
| File Added | 304820: SuppressWarnings.patch.tgz | 2008-12-10 18:57 | trevor_robinson |
| File Deleted | 303366: | 2008-12-10 18:56 | trevor_robinson |
| File Added | 303366: SuppressWarnings.patch.tgz | 2008-11-28 20:26 | trevor_robinson |
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use