Skip to content

Google style has improper enforcement of horizontal whitespace #8122

@shashwatj07

Description

@shashwatj07

Leftover from #7988
Reference: #7988 (comment)

Add all tokens left to be added and make google_checks adhere to Google style's chapter 4.6.2
https://google.github.io/styleguide/javaguide.html#s4.6.2-horizontal-whitespace

the colon (:) in an enhanced for ("foreach") statement

Between any content and a double slash (//) which begins a comment. Multiple spaces are allowed.

The following code should show violations wherever pointed.

class A {
    public static void main(String args[]) {
        for (int i:ll) { // violation as per 4.6.2.4
            int k;
        }
        List<String>list; // violation as per 4.6.2.7
        String g = "Google"; //google
        // the line above: violation as per 4.6.2.6, should be "// google", space after "//"
    }
}
C:\Users\Shashwat\Documents>java -jar checkstyle-8.31-all.jar -c config.xml Test.java
Starting audit...
Audit done.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions