Skip to content

Empty line separator is not enforced in package-info.java file #17541

@mohitsatr

Description

@mohitsatr

I have read check documentation: https://checkstyle.org/checks/whitespace/emptylineseparator.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

From: https://google.github.io/styleguide/javaguide.html#s3-source-file-structure

Exactly one blank line separates each section that is present.
A package-info.java file is the same, but without the top-level class.

$ cat package-info.java

///////////////////////////////////////////////////////////////////////////////////////////////
// checkstyle: Checks Java source code and other text files for adherence to a set of rules.
///////////////////////////////////////////////////////////////////////////////////////////////
package com.google.checkstyle.test.chapter3filestructure.rule3sourcefile;
// EXPECTED VIOLATION ABOVE

CLI:

$ java -jar checkstyle-10.26.1-all.jar -c google_checks.xml package-info.java
Starting audit...
Audit done.

Google-formatter also has issues with formatting:

$ java -jar google-java-format-1.27.0-all-deps.jar package-info.java > FormattedCode.java
$ diff -Naru package-info.java FormattedCode.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions