Fix the 2 CPD duplications reported by the Maven site - #129
Merged
Conversation
Extract the shared Utils.execute() unwrap-and-wrap exception handling in LightWinRMService into a private executeWithTimeout() helper, and narrowly suppress (CPD-OFF/CPD-ON) the intentional near-duplication between lmv2Hash() and ntlmv2Hash() in CipherGen, which is kept line-for-line comparable with the upstream NTLM reference implementation. Closes #123 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Resolves the 2 duplicated blocks flagged by the CPD report (closes #123):
LightWinRMService.java— genuine duplication:executeWqlandexecuteCommandshared an identicalcatch (InterruptedException | ExecutionException)→WinRMExceptionunwrap-and-wrap tail aroundUtils.execute(...). Extracted into a privateexecuteWithTimeout(Callable<T>, long)helper. Behavior is unchanged: same exception unwrapping, same messages.CipherGen.java— intentional duplication:lmv2Hash()andntlmv2Hash()share an identical prologue because both mirror the reference NTLM implementation (Apache HttpClient'sNTLMEngineImpl). As discussed in the issue, this code is deliberately kept line-for-line comparable with upstream rather than factored through a shared helper, so the duplicated block inntlmv2Hash()is narrowly suppressed with// CPD-OFF/// CPD-ONcomments. The suppression comment documents the rationale and the easy-to-miss deliberate divergence between the two methods (LMv2 upper-cases the domain, NTLMv2 keeps its case).Why
The CPD page of the Maven site flagged these 2 duplications; the report is now clean.
Verification
target/cpd.xmlreports 0 duplications.mvn verify sitegreen on JDK 17 (like CI): 79 unit tests + 1 IT pass, checkstyle/pmd/spotbugs gates all pass.mvn formatter:format.Reviewer notes
ntlmv2Hash(); the rest ofCipherGenremains fully analyzed.🤖 Generated with Claude Code