logo       

[ checkstyle-Bugs-1374798 ] Whitespace around generic params. is not needed: msg#00303

Subject: [ checkstyle-Bugs-1374798 ] Whitespace around generic params. is not needed
Bugs item #1374798, was opened at 2005-12-07 08:03
Message generated for change (Comment added) made by oburn
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=1374798&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Core Framework
>Group: release 5.0
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: D�niel D�k�ny (ddekany)
>Assigned to: Oliver Burn (oburn)
Summary: Whitespace around generic params. is not needed

Initial Comment:
The default configuration that 4.0 comes with require
whitespace around the <...> that is used for generic
parameters. I think the correct rule would be the
opposite of it, disallowing whitespace around the <...>.

----------------------------------------------------------------------

>Comment By: Oliver Burn (oburn)
Date: 2007-12-16 18:29

Message:
Logged In: YES 
user_id=218824
Originator: NO

I have create a new check called GenericWhitespaceCheck. The
WhitespaceAround check no longer looks at Generic tokens.

----------------------------------------------------------------------

Comment By: Martin Burger (mburger)
Date: 2006-10-20 23:10

Message:
Logged In: YES 
user_id=134963

What is the status of this bug? It is still a problem with
4.1 (used by the Maven 2 Checkstyle Plugin). And the release
notes of 4.2 does not contain any note about this bug.

This fixes the bug:

        <module name="NoWhitespaceAfter">
            <!-- Default tokens and additional GENERIC_START -->
            <property name="tokens" value="ARRAY_INIT, BNOT,
DEC, DOT, INC, LNOT,
            UNARY_MINUS, UNARY_PLUS, GENERIC_START"/>
        </module>

        <module name="NoWhitespaceBefore">
            <!-- Default tokens and additional GENERIC_START
and GENERIC_END -->
            <property name="tokens" value="SEMI, POST_DEC,
POST_INC,
            GENERIC_START, GENERIC_END"/>
        </module>

        <module name="WhitespaceAfter">
            <!-- Default tokens and additional GENERIC_END -->
            <property name="tokens" value="COMMA, SEMI,
TYPECAST, GENERIC_END"/>
        </module>

        <module name="WhitespaceAround">
            <!-- Default tokens without GENERIC_START and
GENERIC_END -->
            <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,
            TYPE_EXTENSION_AND, WILDCARD_TYPE"/>
        </module>

----------------------------------------------------------------------

Comment By: Lars Koedderitzsch (lkoe)
Date: 2006-10-13 04:03

Message:
Logged In: YES 
user_id=1238882

>And removing the tokens
>from WhitespaceAround kills Eclipse-CS

Which plugin version?
Please file a bug report over at the eclipse-cs project.

Regards,
Lars Ködderitzsch (from eclipse-cs team)

----------------------------------------------------------------------

Comment By: Stephen Colebourne (scolebourne)
Date: 2006-10-13 03:27

Message:
Logged In: YES 
user_id=408725

Our team just hit this today, and was surprised to find the
issue. Requiring spaces in the generics definition line
seems to be a ridiculous default. And removing the tokens
from WhitespaceAround kills Eclipse-CS. So we've had to
remove WhitespaceAround altogether, which is a very poor
solution!

----------------------------------------------------------------------

Comment By: Lance Finn Helsten (lanhel)
Date: 2006-07-11 06:59

Message:
Logged In: YES 
user_id=1553215

The generic type should be looked at as a complete element, i.e.
List<String> 
and List are the same thing.

1. GENERIC_START/END should be removed from WhitespaceAround defaults
2. GENERIC_START added to NoWhitespaceBefore and NoWhitespaceAfter
3. GENERIC_END added to NoWhitespaceBefore

This will not catch the case "List<String>strings = ...", but it will
handle all the 
other cases.


----------------------------------------------------------------------

Comment By: Lars Kühne (lkuehne)
Date: 2005-12-07 16:07

Message:
Logged In: YES 
user_id=401384

I tried to remove GENERIC_START/END from the
WhitespaceAround defaults and add it to the NoWhitespace*
checks, but I ran into a problem with nested generic types
(sample code from JDK HashMap):
Iterator<? extends Map.Entry<? extends K, ? extends V>>

I'm not sure how we should handle GENERIC_END, sometimes
whitespace is required, sometimes not.

Maybe some committer with a better understanding of generics
can look into this?


----------------------------------------------------------------------

Comment By: Lars Kühne (lkuehne)
Date: 2005-12-07 15:50

Message:
Logged In: YES 
user_id=401384

Verified. The following code is analogous to the JDK HashSet
code from Sun

public class MySet<E> extends AbstractSet<E> {
...
}

but WhiteSpaceAround kicks in and reports missing whitespace.



----------------------------------------------------------------------

Comment By: D�niel D�k�ny (ddekany)
Date: 2005-12-07 11:45

Message:
Logged In: YES 
user_id=546667

And the same with ? as generic parameter. No "white space
around" is needed, etc.
(BTW I experience the problem with cs-eclipse, but since it
uses sun_checks.xml that just contains <module
name="WhitespaceAround"/>, I guess the defaults come from
CheckStyle itself.)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=1374798&group_id=29721

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Checkstyle-devel mailing list
Checkstyle-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel
<Prev in Thread] Current Thread [Next in Thread>