Skip to content

Conversation

@Praveen7294
Copy link
Contributor

@Praveen7294 Praveen7294 commented Dec 15, 2025

Issue: #18265

From: https://google.github.io/styleguide/javaguide.html#s4.6.1-vertical-whitespace

  • Added a allowMultipleEmptyLinesInsideClassMembers property inside EmptyLineSeparator check.

  • Added test cases testCorrectEmptyLineSeparatorInsideClassMembers() and testIncorrectEmptyLineSeparatorInsideClassMembers() in VerticalWhitespaceTest.java.

  • Added input files InputCorrectEmptyLineInsideClassMembers.java and InputIncorrectEmptyLineInsideClassMembers.java to rule461verticalwhitespace directory.

  • From this PR Issue #17681: Fix multiple blank line separation #17950 , InputEmptyLineSeparator3.java and InputFormattedEmptyLineSeparator3.java were added to the rule461verticalwhitespace directory but but they were not covered by any test cases. Therefore, added test cases testEmptyLineSeparatorBetweenClassMembers() and testFormattedEmptyLineSeparatorBetweenClassMembers() to VerticalWhitespaceTest.java.


Diff Regression config: https://gist.githubusercontent.com/Praveen7294/605a30d7c12d5fcc633316127e4db0be/raw/c0f9602b094f75a806a296569b5f70a6c3d5e471/base-config-emptyline.xml
Diff Regression patch config: https://gist.githubusercontent.com/Praveen7294/0c2bffd20db9d6c9696c2fce03de4407/raw/f89ddb1333c8bfe4b26e62ba9f3e4327567bfc4e/patch-config-emptyline.xml
Diff Regression projects: https://gist.githubusercontent.com/Praveen7294/a1626a4272b4be9d7a0dc8a9fbae5ffa/raw/22fada1af5a2880572d3e91848996d50427c1616/list-of-projects.properties

@Praveen7294 Praveen7294 force-pushed the empty-line branch 11 times, most recently from 406dae4 to aca7eed Compare December 16, 2025 00:53
@Praveen7294
Copy link
Contributor Author

Github, generate report

@github-actions
Copy link
Contributor

@Praveen7294
Copy link
Contributor Author

@romani @Zopsss please review

Copy link
Member

@Zopsss Zopsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor:

Comment on lines 16 to 18
package com.google.checkstyle.test.chapter4formatting.rule461verticalwhitespace; //violation ''package' has more than 1 empty lines before'
package com.google.checkstyle.test.chapter4formatting.rule461verticalwhitespace;

// violation 2 lines above ''package' has more than 1 empty lines before.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this, no changes required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 13 to +16
package com.google.checkstyle.test.chapter4formatting.rule461verticalwhitespace;

// violation above ''package' has more than 1 empty lines before.'

public class InputFormattedEmptyLineSeparator3 {
// violation above ''CLASS_DEF' has more than 1 empty lines before.'
// violation above 'Missing a Javadoc comment.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a formatted file, then why did it contained "more than 1 empty lines before" violations? The formatter should have removed the empty lines, am I missing something here? @Praveen7294

Copy link
Contributor Author

@Praveen7294 Praveen7294 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am I missing something here?

No, the google-java-format workflow only formats non-excluded files. For excluded files, it locates the original file and its corresponding formatted file and compares the size difference by counting characters after removing whitespace and comments.

The contributor added this file, but it was not formatted. The contributor duplicated the original file and only changed the file name to InputFormatted* to pass the workflow. I have already mentioned that PR in this PR description.

@Praveen7294 Praveen7294 force-pushed the empty-line branch 3 times, most recently from 0b77b02 to 543b0be Compare December 19, 2025 15:49
@Praveen7294 Praveen7294 requested a review from Zopsss December 23, 2025 16:55
@Praveen7294
Copy link
Contributor Author

@Zopsss please review

@Zopsss
Copy link
Member

Zopsss commented Dec 25, 2025

Github, generate report

@github-actions
Copy link
Contributor

Comment on lines 21 to 23
public class InputEmptyLineSeparator3 {
// violation above ''CLASS_DEF' has more than 1 empty lines before.'
// violation above 'Missing a Javadoc comment.'
// violation 2 lines above ''CLASS_DEF' has more than 1 empty lines before.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be:

// 2 violations above:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* This file contains incorrect vertical whitespace inside class
* members and also between class members.
*/
public class InputCorrectEmptyLineInsideClassMembers {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an example of constructor, enum interface, etc. The supported tokens are mentioned here: https://checkstyle.org/checks/whitespace/emptylineseparator.html#Example5-config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added examples of constructors, enums, and interfaces. However, this check does not detect multiple empty lines inside enums, so I created an issue regarding this #18437

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name is InputCorrect* but it contains violations. Please change the input name to InputMultipleEmptyLineInsideClassMembers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Zopsss
Copy link
Member

Zopsss commented Dec 25, 2025

@Zopsss
Copy link
Member

Zopsss commented Dec 25, 2025

@Praveen7294 sorry for the delay, i have reviewed the PR and Report.

Also, please do not wait for maintainers to review reports. After pushing the changes, generate the report and always self review it so the bugs can be caught a lot earlier.

…rs property inside EmptyLineSeparator check in google_checks.xml
@Praveen7294
Copy link
Contributor Author

The check is not aware of comments: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/951dac4_2025065820/reports/diff/Hbase/index.html#A39

yes, in docs mentioned as Attention:
ATTENTION: empty line separator is required between token siblings, not after line where token is found. If token does not have a sibling of the same type, then empty line is required at its end (for example for CLASS_DEF it is after '}'). Also, trailing comments are skipped.
https://checkstyle.org/checks/whitespace/emptylineseparator.html#Description

should we include trailing comments to check?

@Praveen7294
Copy link
Contributor Author

@Praveen7294 sorry for the delay, i have reviewed the PR and Report.

No Problem.

Also, please do not wait for maintainers to review reports. After pushing the changes, generate the report and always self review it so the bugs can be caught a lot earlier.

Okay, I will take care of that from next time.

@Praveen7294 Praveen7294 requested a review from Zopsss December 27, 2025 10:30
@romani
Copy link
Member

romani commented Dec 28, 2025

@Zopsss , please finish review

@Zopsss
Copy link
Member

Zopsss commented Dec 29, 2025

There are multiple false-positive cases, so I created an issue regarding this #18438.

We cannot add false-positives to our style guide implementation. First we need to solve them. Unfortunately, until all false-positives are solved, we cannot proceed with this PR.

@Zopsss
Copy link
Member

Zopsss commented Dec 29, 2025

The check is not aware of comments: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/951dac4_2025065820/reports/diff/Hbase/index.html#A39

yes, in docs mentioned as Attention: ATTENTION: empty line separator is required between token siblings, not after line where token is found. If token does not have a sibling of the same type, then empty line is required at its end (for example for CLASS_DEF it is after '}'). Also, trailing comments are skipped. https://checkstyle.org/checks/whitespace/emptylineseparator.html#Description

should we include trailing comments to check?

Yes we should do that, it is causing unnecessary violations. Please open a new issue regarding this. @romani cc

@Praveen7294
Copy link
Contributor Author

We cannot add false-positives to our style guide implementation. First we need to solve them. Unfortunately, until all false-positives are solved, we cannot proceed with this PR.

Once it approved, I will start working on that

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I am blocking this PR until we clarify my comment in issue.

@Zopsss Zopsss added the blocked label Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants