WhitespaceAround with annotation parameters

Johannes Ruthenberg <[email protected]> Wed, 13 Jan 2010 22:59:40 +0000
Newsgroups gmane.comp.java.audit.checkstyle.user
Message-ID <[email protected]>
Hello!

I'm using checkstyle 5 with the Eclipse plugin (plugin version 
5.0.3.200911042225) and I have a problem with the WhitespaceAround 
check. For this code:

@Target({ElementType.METHOD, ElementType.FIELD}) // generates warning

I get the warning that a space is missing before "}". For some reason I 
only get a warning for the closing bracket, not the opening one. Putting 
a space before the closing bracket looks odd, though, and all examples I 
found don't do this either. So I'm wondering if there's something wrong 
with the way I configured this check or if there's something else I can 
do to get rid of these warnings?!

Also, this seems to only happen in annotation parameter lists. If I use 
an array somewhere else, it does not trigger a warning:

String[] test = new String[]{"test"}; // no warning

The WhitespaceAround check is configured as follows:

<module name="WhitespaceAround">
  <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, 
BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, 
EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, 
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, 
LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, 
LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, 
QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, 
STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
</module>

I also found this thread from 2008 which describes a more or less 
identical problem:
http://markmail.org/message/2ne3sntoqe6pikxj
The solution then was to upgrade to checkstyle 5, which I'm already 
running. I'd appreciate any hints into the right direction. ;-)

Regards,
Johannes Ruthenberg

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev