FEAT: Raise Unused code during build stage#130
Merged
Conversation
The Java compiler's -Xlint cannot detect unused local variables, private fields, private methods or private parameters. Add the maven-pmd-plugin to the parent POM, bound to the compile phase with failOnViolation=true, so these surface during a normal build and fail it. Also fix the unused local it exposed in TestOnPremiseBuilder_CreateTempFile by asserting the temp data file is actually created.
justadreamer
approved these changes
Jun 17, 2026
Fix this-escape warning in MultiIPIDataCloud Declare MultiIPIDataCloud final to resolve the "possible 'this' escape before subclass is fully initialized" warning emitted by javac on JDK 21+ Replace java.util wildcard import in ValueTests with explicit imports Expand `import java.util.*` to the four types the test actually uses (ArrayList, Arrays, List, Map) in the shared module's ValueTests helper. Uncomment -Werror to make sure no warning regressions are introduced.
Contributor
Author
|
@justadreamer I've added some extra compiler warning fixes following the Java21 warnings issues on device-detection-java and pipeline-java |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #84
Unused variables (and other unused declarations) were not being reported at
build time. The Java compiler already runs with
-Xlint:allin this repo, but-Xlintfundamentally cannot detect unused local variables, unused privatefields, unused private methods, or unused private parameters.
Example that went undetected: an unused
Path tempPathlocal inTestOnPremiseBuilder_CreateTempFile.FIX: address compiler warnings:
Fix this-escape warning in MultiIPIDataCloud
Declare MultiIPIDataCloud final to resolve the "possible 'this' escape
before subclass is fully initialized" warning emitted by javac on JDK 21+
Replace java.util wildcard import in ValueTests with explicit imports
Expand
import java.util.*to the four types the test actually uses(ArrayList, Arrays, List, Map) in the shared module's ValueTests helper.
Uncomment -Werror to make sure no warning regressions are introduced.
Expected behaviour
Unused variables, methods, and similar dead declarations should be reported
during the build.
Change
Introduce PMD via
maven-pmd-pluginin the parentPOM:
ci/pmd-ruleset.xmlintroduces a deliberately narrow ruleset:pom.xml:maven-pmd-pluginadded to the parent build (inherited by allfour modules), bound to the
compilephase withfailOnViolation=trueand
includeTests=true. Unused code now surfaces during a normal build andfails it.
IPIntelligenceTests.java: fix the unusedPath tempPathlocal exposedby the new check by asserting the temp data file is actually created.
Notes / scope
pre-existing unused-code violations beyond the one fixed here. These need to be
cleaned up)for the build to go green.
Testing
pom.xmlandci/pmd-ruleset.xmlvalidated locally.