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

EmptyLineSeparator causing violation in `package-info.java` #3426

Closed
mkobit opened this Issue Sep 3, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@mkobit

mkobit commented Sep 3, 2016

main/java/com/my/package/package-info.java

/**
 * My package for doing things.
 */
package com.my.package;

Config:

        <module name="EmptyLineSeparator">
            <property name="allowNoEmptyLineBetweenFields" value="true"/>
        </module>

Output (using Gradle and Checkstyle 7.1)

[ant:checkstyle] [WARN] main/java/com/my/package/package-info.java:5: 'package' should be separated from previous statement. [EmptyLineSeparator]

I expect that adding Javadoc to my package-info.java file to not trigger this violation.

Adding a separate line between the Javadoc comment and the package declaration causes the violation to not be triggered, but I want to keep them together, especially if I annotate my package definition (like @ParametersAreNonnullByDefault)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Oct 19, 2016

Member

http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator

looks like we step into a problem of distinguishing of header and javadoc of package that usually placed in special files - package-info.java.
In our project we do have such files but files have header too - https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/package-info.java

logic is very simple and need to be adjusted to expect annotations: https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java#L407

and distinguish javadoc vs simple multiline header - http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/2bf254421854//test/tools/pack200/typeannos/TypeUseTarget.java . Javadoc comment has special identification - http://checkstyle.sourceforge.net/writingjavadocchecks.html#What_is_Javadoc_comment

Member

romani commented Oct 19, 2016

http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator

looks like we step into a problem of distinguishing of header and javadoc of package that usually placed in special files - package-info.java.
In our project we do have such files but files have header too - https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/package-info.java

logic is very simple and need to be adjusted to expect annotations: https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheck.java#L407

and distinguish javadoc vs simple multiline header - http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/2bf254421854//test/tools/pack200/typeannos/TypeUseTarget.java . Javadoc comment has special identification - http://checkstyle.sourceforge.net/writingjavadocchecks.html#What_is_Javadoc_comment

@romani romani added the approved label Oct 19, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 12, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 12, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 12, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 12, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 12, 2016

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

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

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 15, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 15, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 15, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 18, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 18, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 26, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 26, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 30, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Nov 30, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 2, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 2, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 2, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 2, 2016

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

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 4, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 4, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 5, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 5, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 5, 2016

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

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

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

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 12, 2016

kazachka added a commit to kazachka/checkstyle that referenced this issue Dec 12, 2016

romani added a commit that referenced this issue Dec 12, 2016

@romani romani added the bug label Dec 12, 2016

@romani romani added this to the 7.4 milestone Dec 12, 2016

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 12, 2016

Member

Fix is merged

Member

romani commented Dec 12, 2016

Fix is merged

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