New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow WhitespaceAround for ARRAY_INIT token #3202

Closed
jsotuyod opened this Issue May 20, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@jsotuyod
Contributor

jsotuyod commented May 20, 2016

Using this configuration:

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="WhitespaceAround"/>
    </module>
</module>

Checkstyle won't report on the curly braces used for array declarations, such as:

public class Foo {
    public final int[] COLORS = new int[]{Color.BLACK };
    //                                   ^ doesn't report missing whitespace around {
}
$ java -jar ~/Downloads/checkstyle-6.18/checkstyle-6.18-all.jar -c config.xml Foo.java
Starting audit...
Audit done.

This is down to the fact that even though WhitespaceAround appllies to LCURLY and RCURLY tokens, when writing an array, the { is actually treated as an ARRAY_INIT token, which is not currently being processed by the check at all (even is not allowed Token).

It would be desired if ARRAY_INIT was to be processed by WhitespaceAround in order to allow valiadation of code above, and have the configuration(given before) violation on arrays' initialization.

@jsotuyod jsotuyod changed the title from Allow WhitespaceAround for array init to Allow WhitespaceAround for ARRAY_INIT token May 20, 2016

romani added a commit that referenced this issue Jun 28, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jun 28, 2016

Member

I failed to fix it quickly, Check logic need to specially process that token, as token could be multi-line.
Report of failed UT:

Expected :../whitespace/InputWhitespace.java:262:14: '}' is not followed by whitespace.
Actual   :../whitespace/InputWhitespace.java:255:43: '{' is not followed by whitespace.
Member

romani commented Jun 28, 2016

I failed to fix it quickly, Check logic need to specially process that token, as token could be multi-line.
Report of failed UT:

Expected :../whitespace/InputWhitespace.java:262:14: '}' is not followed by whitespace.
Actual   :../whitespace/InputWhitespace.java:255:43: '{' is not followed by whitespace.

kazachka added a commit to kazachka/checkstyle that referenced this issue Aug 27, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 3, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 8, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 9, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 10, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 11, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 11, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 13, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 13, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 19, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 20, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 20, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Sep 21, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Oct 3, 2016

romani added a commit that referenced this issue Oct 16, 2016

@romani romani added this to the 7.2 milestone Oct 16, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Oct 16, 2016

Member

Fix is merged

Member

romani commented Oct 16, 2016

Fix is merged

@romani romani closed this Oct 16, 2016

agcuda added a commit to agcuda/checkstyle that referenced this issue Oct 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment