Skip to content

Fix UnusedMethod & Finally#34881

Merged
ov7a merged 1 commit intogradle:masterfrom
Pankraz76:into-spotless-pmd
Sep 12, 2025
Merged

Fix UnusedMethod & Finally#34881
ov7a merged 1 commit intogradle:masterfrom
Pankraz76:into-spotless-pmd

Conversation

@Pankraz76
Copy link
Copy Markdown

@Pankraz76 Pankraz76 commented Sep 3, 2025

Fix UnusedMethod & Finally

Contributor Checklist

  • Review Contribution Guidelines.
  • Make sure that all commits are signed off to indicate that you agree to the terms of Developer Certificate of Origin.
  • Make sure all contributed code can be distributed under the terms of the Apache License 2.0, e.g. the code was written by yourself or the original code is licensed under a license compatible to Apache License 2.0.
  • Check "Allow edit from maintainers" option in pull request so that additional changes can be pushed by Gradle team.
  • Provide integration tests (under <subproject>/src/integTest) to verify changes from a user perspective.
  • Provide unit tests (under <subproject>/src/test) to verify logic.
  • Update User Guide, DSL Reference, and Javadoc for public-facing changes.
  • Ensure that tests pass sanity check: ./gradlew sanityCheck.
  • Ensure that tests pass locally: ./gradlew <changed-subproject>:quickTest.

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

ref:

@zbynek can you please tell if PMD should find these groovy issues we well? Assuming we check for bytecode and docs tell it should be possible to detect these.

@bot-gradle bot-gradle added from:contributor PR by an external contributor to-triage labels Sep 3, 2025
Copy link
Copy Markdown
Member

@ov7a ov7a left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

Please, split the PR.

Removing unused private methods should be fine. A PR with these changes will be accepted if it pass the tests.

Introducing PMD into our build is a different story. First, it should be done as a part of sanity check. Second, CheckStyle has UnusedPrivateMethodCheck. So instead of introducing a new tool, please adjust already existing ones.

@ov7a ov7a added the pending:feedback Indicates that changes or additional info are required, and the issue will be closed without them label Sep 4, 2025
@Pankraz76

This comment was marked as resolved.

@github-actions github-actions Bot removed the pending:feedback Indicates that changes or additional info are required, and the issue will be closed without them label Sep 4, 2025
Pankraz76

This comment was marked as resolved.

Comment thread gradle/sanity-check.pmd.xml Outdated
Comment thread gradle.properties Outdated
@Pankraz76
Copy link
Copy Markdown
Author

Pankraz76 commented Sep 5, 2025

kindly request feedback. Thanks for consideration.

happy ci run (including Rewrite as comparison):

@alllex alllex removed their request for review September 5, 2025 18:01
@ov7a ov7a self-assigned this Sep 8, 2025
@zbynek
Copy link
Copy Markdown

zbynek commented Sep 9, 2025

@zbynek can you please tell if PMD should find these groovy issues we well?

I don't think this is the right place to discuss Groovy support in PMD. But at the moment Groovy is only supported in CPD.

And since I'm already here: you're right that CheckStyle may fail to detect missing unused methods, but Error Prone that's also configured in this build should catch those with https://errorprone.info/bugpattern/UnusedMethod . This rule is currently disabled in some modules, e.g. https://github.com/gradle/gradle/blob/master/subprojects/core/build.gradle.kts#L59 . You should be able to enable it and remove unused methods if that's something Gradle maintainers are interested in.

Copy link
Copy Markdown
Member

@ov7a ov7a left a comment

Choose a reason for hiding this comment

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

❌ Let's keep the discussion focused.

I agree with @zbynek that it's not the right place to discuss Groovy support in PMD.

I think what you mean is that it could only be done there.
... That said, this really makes the most sense when combined with some kind of quality gate

I'm not sure if I understand what you mean by that. We have a quality gate already.

testing ci run that should fail due to unused method unusedTestCi:

Ok, I assume that can be used as some proof that PMD is better with that check compared to CheckStyle. I'm still not convinced that we should introduce PMD just because of that check, though.

You should be able to enable it and remove unused methods if that's something Gradle maintainers are interested in.

@zbynek Thank you for your suggestion and constructive feedback!

Indeed, errorprone is enabled in our build, and working on cleaning up disabled checks is something that we plan to do eventually.

@Pankraz76 given that, we don't have a good reason to introduce PMD. You're welcome to remove errorprone exceptions and make relevant code changes.

Comment thread build-logic-commons/code-quality-rules/src/main/resources/codenarc/codenarc.xml Outdated
Comment thread .github/workflows/contributor-pr.yml Outdated
Comment thread gradle.properties Outdated
Comment thread gradle/verification-metadata.xml Outdated
@ov7a ov7a added in:building-gradle gradle/gradle build and removed to-triage labels Sep 10, 2025
Copy link
Copy Markdown
Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

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

concerning/disturbing api change.

@Pankraz76
Copy link
Copy Markdown
Author

thanks for rebase.

Copy link
Copy Markdown
Member

@ov7a ov7a left a comment

Choose a reason for hiding this comment

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

LGTM overall

@ov7a
Copy link
Copy Markdown
Member

ov7a commented Sep 11, 2025

@bot-gradle test this

@bot-gradle

This comment has been minimized.

@ov7a
Copy link
Copy Markdown
Member

ov7a commented Sep 11, 2025

@Pankraz76 Thanks for working on this. If the tests pass, I'll merge this.

FTR, this PR only addresses issues in the core subproject. There are similar suppressions in other projects as well.

@bot-gradle
Copy link
Copy Markdown
Collaborator

The following builds have failed:

@ov7a
Copy link
Copy Markdown
Member

ov7a commented Sep 11, 2025

Signed-off-by: Vincent Potucek <[email protected]>
@ov7a ov7a added this pull request to the merge queue Sep 12, 2025
@bot-gradle bot-gradle added this to the 9.2.0 RC1 milestone Sep 12, 2025
@cobexer cobexer removed the request for review from a team September 12, 2025 13:36
Merged via the queue into gradle:master with commit f80840e Sep 12, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:contributor PR by an external contributor in:building-gradle gradle/gradle build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants