checkstyle icon indicating copy to clipboard operation
checkstyle copied to clipboard

Issue #17393: new check TypeBodyPadding

Open matrei opened this issue 3 months ago • 36 comments

Issue #17393

New module config: https://gist.githubusercontent.com/matrei/3049e9b9feed9396d54af7af2d721d75/raw/849ec04daf4a2c440a79f0952819a8e832c045d3/TypeBodyPadding

Contribution PR: checkstyle/contribution#970

matrei avatar Sep 12 '25 09:09 matrei

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

matrei avatar Sep 15 '25 14:09 matrei

GitHub, generate website

romani avatar Sep 18 '25 13:09 romani

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

romani avatar Sep 18 '25 13:09 romani

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#

github-actions[bot] avatar Sep 18 '25 14:09 github-actions[bot]

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

romani avatar Sep 19 '25 04:09 romani

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.

romani avatar Sep 26 '25 15:09 romani

@matrei , ping, do you need help?

romani avatar Nov 10 '25 01:11 romani

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

matrei avatar Nov 11 '25 14:11 matrei

github, generate report

matrei avatar Nov 11 '25 16:11 matrei

ping, do you need help?

@romani Yes, looks like I need help to get this one over the finish line.

matrei avatar Nov 11 '25 16:11 matrei

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.

romani avatar Nov 11 '25 18:11 romani

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.

matrei avatar Nov 12 '25 12:11 matrei

Semafor is restarted, GitHub actions are started.

romani avatar Nov 13 '25 00:11 romani

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.

romani avatar Nov 13 '25 14:11 romani

GitHub, generate website

romani avatar Nov 13 '25 14:11 romani

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#

github-actions[bot] avatar Nov 13 '25 14:11 github-actions[bot]

Please add example for tokens with custom values.

romani avatar Nov 16 '25 03:11 romani

Please add example for tokens with 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?

matrei avatar Nov 17 '25 08:11 matrei

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.

romani avatar Nov 19 '25 05:11 romani

There is conflict, please rebase.

romani avatar Nov 19 '25 05:11 romani

GitHub, generate website

romani avatar Nov 19 '25 14:11 romani

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#

github-actions[bot] avatar Nov 19 '25 14:11 github-actions[bot]

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

romani avatar Nov 19 '25 17:11 romani

@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 ?

romani avatar Nov 20 '25 03:11 romani

@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

matrei avatar Nov 20 '25 08:11 matrei

GitHub, generate website

romani avatar Nov 20 '25 13:11 romani

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#

github-actions[bot] avatar Nov 20 '25 13:11 github-actions[bot]

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.

romani avatar Nov 20 '25 13:11 romani

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.

matrei avatar Nov 20 '25 13:11 matrei

GitHub, generate report

matrei avatar Nov 20 '25 15:11 matrei