Issue #17393: new check TypeBodyPadding
Issue #17393
New module config: https://gist.githubusercontent.com/matrei/3049e9b9feed9396d54af7af2d721d75/raw/849ec04daf4a2c440a79f0952819a8e832c045d3/TypeBodyPadding
Contribution PR: checkstyle/contribution#970
Please follow CI validations, all should be green.
There is one remaining failure. Is that depending on the contribution PR being merged?
We would need PR to contribution repository to add new check in regression testing.
Done: checkstyle/contribution#970
GitHub, generate website
please start testing on real code, please pay attentiont to New module config in description of https://github.com/checkstyle/checkstyle/pull/16946 , we need "same" for your new check and report generation will be automatic , see how to trigger it https://github.com/checkstyle/checkstyle/pull/16946#issuecomment-2914667125 .
here is doc on how github action is working: https://github.com/checkstyle/contribution/tree/master/checkstyle-tester#executing-generation-using-github-action
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/098ccbe_20250918142616/index.html
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/098ccbe_20250918142616/checks.html#Standard_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/098ccbe_20250918142616/checks/whitespace/index.html#Whitespace_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/098ccbe_20250918142616/checks/whitespace/typebodypadding.html#
Please add
static class Inner {
int b = 0; // violation 'A blank line is required after the opening'
}
To all examples. We try to keep java code the same, to let users see how comments with violations are changing
Please add to test Inputs cases with interface, record, enum. We need diversity.
Please add to also case when class is declared in method body, just to see how Chevk will behave on such potential code.
@matrei , ping, do you need help?
Please add to test Inputs cases with interface, record, enum. We need diversity.
Please add to also case when class is declared in method body, just to see how Chevk will behave on such potential code.
Done
github, generate report
ping, do you need help?
@romani Yes, looks like I need help to get this one over the finish line.
https://ci.appveyor.com/project/Checkstyle/checkstyle/builds/53057700/job/ryshhydq55tcpv3u#L193
[ERROR] [checkstyle] [ERROR] C:\projects\checkstyle\src\main\java\com\puppycrawl\tools\checkstyle\checks\whitespace\TypeBodyPaddingCheck.java:178:16: Condition inversion could be avoided. [AvoidConditionInversion]
Please fix, usually this is easy update
Semafor reporting:
[ERROR] [checkstyle] [ERROR] /home/semaphore/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypeBodyPaddingCheck.java:178:16: Condition inversion could be avoided. [AvoidConditionInversion]
Please fix .
https://checkstyle.semaphoreci.com/jobs/d3aaf525-571e-4828-8203-d34eafd2b660 this failure will stay, it just notification that config in contribution repository should be updated by PR to add new Check.
https://ci.appveyor.com/project/Checkstyle/checkstyle/builds/53057700/job/ryshhydq55tcpv3u#L193 [ERROR] [checkstyle] [ERROR] C:\projects\checkstyle\src\main\java\com\puppycrawl\tools\checkstyle\checks\whitespace\TypeBodyPaddingCheck.java:178:16: Condition inversion could be avoided. [AvoidConditionInversion]
Please fix, usually this is easy update
Semafor reporting: [ERROR] [checkstyle] [ERROR] /home/semaphore/checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypeBodyPaddingCheck.java:178:16: Condition inversion could be avoided. [AvoidConditionInversion]
Please fix .
Done
Now there was a problem running CodeNarc (looks like a temporary problem):
General error during conversion: Error grabbing Grapes -- [download failed: org.codehaus.groovy#groovy;2.5.14!groovy.jar, download failed: org.apache.ant#ant-antlr;1.9.15!ant-antlr.jar]
and still the error for No Error Test (openjdk21, fast pool) - CMD=.ci/validation.sh no-error-checkstyles-sevntu for which I cannot see what the actual problem is.
Semafor is restarted, GitHub actions are started.
please address pitest survivals, no mutations are allowed, it means we need more tests to kill them.
in Checker violations, please try to address only @Initialized @Nullable all others can be added to suppression, see logs of CI it prints patch to copy-apply on local.
GitHub, generate website
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/522a693_20251113141925/index.html
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/522a693_20251113141925/checks.html#Standard_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/522a693_20251113141925/checks/whitespace/index.html#Whitespace_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/522a693_20251113141925/checks/whitespace/typebodypadding.html#
Please add example for tokens with custom values.
Please add example for
tokenswith custom values.
Is this comment still of concern (I think all CI check failures are now addressed)? If it is, could you clarify what you mean by this?
There is no Example for custom value of property https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/522a693_20251113141925/checks/whitespace/typebodypadding.html#tokens Users love examples, not all user well experienced.
There is conflict, please rebase.
GitHub, generate website
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2c709af_20251119141228/index.html
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2c709af_20251119141228/checks.html#Standard_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2c709af_20251119141228/checks/whitespace/index.html#Whitespace_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/2c709af_20251119141228/checks/whitespace/typebodypadding.html#
Please address Checker complains on missed annotation that something can be nullable.
Pitest needs to be resolved by extra test or removal of unnecessary code
./.ci/pitest.sh "pitest-whitespace" please run and review report.
https://github.com/checkstyle/checkstyle/pull/17781#issuecomment-3550841660 I don't see example with tokens property
@matrei , as you are author of Check idea, it should means that you have some project to apply it. Did you test your implementation on such projects ?
@matrei , as you are author of Check idea, it should means that you have some project to apply it. Did you test your implementation on such projects ?
Yes, I have tested it on https://github.com/apache/grails-core
GitHub, generate website
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48e4c74_20251120133836/index.html
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48e4c74_20251120133836/checks.html#Standard_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48e4c74_20251120133836/checks/whitespace/index.html#Whitespace_Checks
https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/48e4c74_20251120133836/checks/whitespace/typebodypadding.html#
we need extend testing on real projects as we usually do. please look at https://github.com/checkstyle/checkstyle/pull/17233 , attention to PR description link, triggering testing is by comment like https://github.com/checkstyle/checkstyle/pull/17233#issuecomment-3341439148 github action will generate report like: https://github.com/checkstyle/checkstyle/pull/17233#issuecomment-3341463839
as minimum there should be no exceptions on wild real sources.
We usually ask to make as much reports as Examples, configs are already created by you in examples, so should be easy to copy-paste.
this will create exception, and if there is some very rare but compiled code , check will block execution all checksyle. Lets make logic to skip validation if OBJBLOCK is not found. We would rather have false positive, but not an exception.
Same for other methods below. If you did for some good reason (multiple CI validations demands), please share it.
I'm getting bounced back and forth between test coverage failures and pitest failures. This was a try to fix this.
I see now how I can run these checks locally with the scripts in the .ci folder.
GitHub, generate report