Fix the PMD violations reported by the Maven site (#122) - #126
Merged
bertysentry merged 3 commits intoJul 27, 2026
Merged
Conversation
The PMD report flagged 89 violations; they were report-only, so the build stayed green while the findings piled up. The report is now clean. - UselessParentheses (68): drop the redundant outer parentheses in the MD4 rounds and helpers, the Envelopes SOAP builders, and the boolean/bitwise returns of WsmanClient, WinRMEndpoint, NTLMMessage, Type1Message, WmiHelper and ShellFileCopy. - UnnecessaryModifier (11): remove `public` on interface methods and `final` on try-with-resources variables. - EmptyCatchBlock (6): name the caught exception `ignored` (the name PMD accepts for a deliberately ignored exception); Type3Message's empty block also gets a comment explaining why a missing SHA1PRNG is left to the constructor to report. - AvoidBranchingStatementAsLastInLoop (2): NtlmCrypto.Cursor.skipUntil loops on a new matchesAt() predicate instead of a labelled continue/return, and WsmanClient.request accumulates into a Decoded sentinel and returns after the retry loop. - EmptyControlStatement (1): HttpTransport.readChunked reads the next trailer line in the loop body rather than in the condition. - UnusedFormalParameter (1): remove the unused `target` parameter from the CipherGen constructor and its single call site. - UnusedPrivateMethod (2, both false positives on used methods): rename the private collectItems overload to collectRows so PMD resolves the call, and annotate RemoteDigest.matches, which PMD cannot see through Optional#get(). All of it is behavior-preserving. The trailer-draining path rewritten in readChunked had no coverage, so FakeWsmanServer gained a chunked-response mode (several chunks, a chunk extension, trailer fields) and WsmanProtocolTest a test that pages a WQL enumeration over it — a client that leaves the trailers in the socket desyncs the kept-alive connection and fails on the following request.
The PMD findings were report-only: nothing stopped a new violation from landing. Bind pmd:check to the verify phase, with the same pmd.xml ruleset the report uses, so `mvn verify` fails on any violation. The plugin version is pinned to 3.26.0 — the version the parent manages for the site report — so the gate and the report always run the same PMD (7.7.0) rather than drifting to whatever the build resolves.
Contributor
Author
|
Pushed
Verified both directions: CPD is deliberately left alone — |
anuragpaul602-netizen
force-pushed
the
122-fix-pmd-violations
branch
from
July 24, 2026 22:12
ce08ad0 to
0d3b436
Compare
# Conflicts: # pom.xml
Contributor
|
@codex please review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
bertysentry
approved these changes
Jul 27, 2026
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.
Closes #122.
The PMD report is now clean: 0 violations (PMD 7.7.0, ruleset
pmd.xml), down from 89 in the issue (91 on my checkout — see the note onUnusedPrivateMethodbelow).Breakdown
UselessParenthesesMD4rounds and helpers, theEnvelopesSOAP builders, and the boolean/bitwise returns ofWsmanClient,WinRMEndpoint,NTLMMessage,Type1Message,WmiHelperandShellFileCopy.UnnecessaryModifierpublicon interface methods andfinalon try-with-resources variables.EmptyCatchBlockignored, the name PMD accepts for a deliberately ignored exception (allowExceptionNameRegex), keeping the existing explanatory comments.Type3Message's genuinely empty block also gained a comment: a missing SHA1PRNG leavesRND_GENnull and the constructor reports it.AvoidBranchingStatementAsLastInLoopNtlmCrypto.Cursor.skipUntilnow loops on a newmatchesAt(...)predicate instead of a labelledcontinue/return;WsmanClient.requestaccumulates into aDecodedsentinel and returns after the retry loop.EmptyControlStatementHttpTransport.readChunkedreads the next trailer line in the loop body rather than in the condition.UnusedFormalParametertargetparameter from theCipherGenconstructor and its single call site.UnusedPrivateMethodcollectItemsoverload tocollectRowsso PMD resolves the call, and annotatedRemoteDigest.matches, which PMD cannot see throughOptional#get(), with a justified@SuppressWarnings.The issue left open whether the
light/*NTLM/crypto ports should get a targeted suppression instead. I went with the mechanical fix: those files are already reformatted to the project's style, so they are not byte-comparable with upstream anyway, and removing the parentheses is provably semantics-preserving. Happy to switch them to a class-level suppression if you would rather keep them close to the fork.Tests
Everything above is behavior-preserving, and the NTLM paths (
MD4,NtlmCrypto,WsmanClient.request,Envelopes) are covered end to end by the existingWsmanProtocolTestagainstFakeWsmanServer.The one gap was the trailer-draining path rewritten in
readChunked, which had no coverage.FakeWsmanServergained a chunked-response mode (several chunks, a chunk extension, trailer fields after the terminating chunk) andWsmanProtocolTesta test that pages a WQL enumeration over it — a client that leaves the trailers in the socket desyncs the kept-alive NTLM connection and fails on the following request. I checked the test's sensitivity by deliberately truncating the drain, which makes it fail.Verification
main(theType3Messageempty catch), nothing new. Run with plugin 4.9.8.0 because the pinned version cannot read Java 25 bytecode on my machine.mvn test: 83 tests (was 82), all passing exceptWinRmCliTest.decodesCommandOutputUsingTheRemoteWindowsCodePageandWinRMWqlExecutorTest.testExecute, which fail identically on unmodifiedmainhere — Mockito's inline mock maker refuses to mock under JDK 25.mvn verify sitestill green" criterion: I could not confirm it locally, because SpotBugs and the site skin both break under JDK 25 (Unsupported class file major version 69,sun.misc.Unsafe.ensureClassInitialized) before and after these changes. It needs a CI run on a supported JDK.CipherGenis apublicclass, so dropping a constructor parameter is technically a signature change; it is internal NTLM plumbing with a single caller, and I noted it inCHANGELOG.mdunder the in-progress 2.0.0 section. No README change: nothing here is visible to users of the documented API.pmd:checkis enabled in this PR (see the comment below), so the report cannot silently regress.