Skip to content

Fix the 2 CPD duplications reported by the Maven site - #129

Merged
bertysentry merged 1 commit into
mainfrom
123-fix-cpd-duplications
Jul 27, 2026
Merged

Fix the 2 CPD duplications reported by the Maven site#129
bertysentry merged 1 commit into
mainfrom
123-fix-cpd-duplications

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

What

Resolves the 2 duplicated blocks flagged by the CPD report (closes #123):

  1. LightWinRMService.java — genuine duplication: executeWql and executeCommand shared an identical catch (InterruptedException | ExecutionException)WinRMException unwrap-and-wrap tail around Utils.execute(...). Extracted into a private executeWithTimeout(Callable<T>, long) helper. Behavior is unchanged: same exception unwrapping, same messages.

  2. CipherGen.java — intentional duplication: lmv2Hash() and ntlmv2Hash() share an identical prologue because both mirror the reference NTLM implementation (Apache HttpClient's NTLMEngineImpl). 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 in ntlmv2Hash() is narrowly suppressed with // CPD-OFF / // CPD-ON comments. 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.xml reports 0 duplications.
  • mvn verify site green on JDK 17 (like CI): 79 unit tests + 1 IT pass, checkstyle/pmd/spotbugs gates all pass.
  • Code formatted with mvn formatter:format.

Reviewer notes

  • The CPD suppression only covers the duplicated block inside ntlmv2Hash(); the rest of CipherGen remains fully analyzed.
  • No user-facing change, so no README update.

🤖 Generated with Claude Code

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>
@bertysentry
bertysentry merged commit 95c3770 into main Jul 27, 2026
5 checks passed
@bertysentry
bertysentry deleted the 123-fix-cpd-duplications branch July 27, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix the 2 CPD (copy-paste) duplications reported by the Maven site

1 participant