GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — refactor: resolve high coupling, God Class, and high cognitive complexity in core library classes by sajibsarkar92 · Pull Request #231 · java-diff-utils/java-diff-utils ConversationRefactor: Resolve High Coupling, God Class, and High Cognitive ComplexityThis PR addresses three critical architectural code smells identified via PMD static analysis. Issues Addressed1. High Object Coupling in
|
| File | Change | Description |
|---|---|---|
DiffUtils.java |
Modified | Converted to slim delegating façade |
PatchUtils.java |
New | Owns all patch manipulation logic |
InlineDiffUtils.java |
New | Owns inline diff annotation logic |
DiffAlgorithmDefaults.java |
New | Algorithm engine factory |
DiffRowGenerator.java |
Modified | Reduced to ~240-line orchestrator |
InlineTagRenderer.java |
New | HTML tag injection specialist |
DeltaDecompressor.java |
New | Asymmetric delta normalization |
InlineDiffAnnotator.java |
New | Token-level highlighting engine |
InlineDiffAnnotatorConfig.java |
New | Immutable annotation config object |
UnifiedDiffReader.java |
Modified | Phase-driven complexity reduction |
pom.xml (parent) |
Modified | Eclipse m2e lifecycle mapping for Spotless |
All existing tests pass with zero regressions. The 3 skipped tests are pre-existing
upstream skips entirely unrelated to this refactoring.
Tests run: 11, Failures: 0, Errors: 0 — GenerateUnifiedDiffTest
Tests run: 1, Failures: 0, Errors: 0 — ChunkTest
Tests run: 8, Failures: 0, Errors: 0 — PatchWithAllDiffAlgorithmsTest
Tests run: 2, Failures: 0, Errors: 0 — PatchWithMyerDiffTest
Tests run: 1, Failures: 0, Errors: 0 — PatchWithMyerDiffWithLinearSpaceTest
Tests run: 4, Failures: 0, Errors: 0 — DiffRowGeneratorEqualitiesTest
Tests run: 44, Failures: 0, Errors: 0 — DiffRowGeneratorTest
Tests run: 4, Failures: 0, Errors: 0 — StringUtilsTest
Tests run: 32, Failures: 0, Errors: 0 — UnifiedDiffReaderTest
Tests run: 7, Failures: 0, Errors: 0 — UnifiedDiffRoundTripTest (1 pre-existing skip)
Tests run: 1, Failures: 0, Errors: 0 — UnifiedDiffRoundTripNewLineTest (1 pre-existing skip)
Tests run: 2, Failures: 0, Errors: 0 — UnifiedDiffWriterTest
Tests run: 2, Failures: 0, Errors: 0 — HistogramDiffTest (jgit module)
Total — Tests run: 147, Failures: 0, Errors: 0, Skipped: 3
BUILD SUCCESS
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…eDiffAnnotator, InlineDiffAnnonatorConfig, InlineTagRender.java
…5 via phase-driven helpers
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR refactors core java-diff-utils classes to reduce coupling and cognitive complexity by extracting patching, inline diff annotation, delta normalization, and unified-diff parsing phases into focused helpers while keeping existing behavior intact.
Changes:
PatchUtils and InlineDiffUtils, and introduced DiffAlgorithmDefaults for default algorithm selection.DiffRowGenerator responsibilities into dedicated helpers (InlineDiffAnnotator, InlineTagRenderer, DeltaDecompressor, and config object).UnifiedDiffReader.parse() into phase methods to reduce nesting and repeated rule lists.Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pom.xml | Formatting/lifecycle mapping adjustments (Spotless/m2e related) |
| java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java | Slimmed diff façade; default algorithm now via DiffAlgorithmDefaults |
| java-diff-utils/src/main/java/com/github/difflib/PatchUtils.java | New patch/unpatch utility wrapper around Patch |
| java-diff-utils/src/main/java/com/github/difflib/InlineDiffUtils.java | New inline character-level diff utility |
| java-diff-utils/src/main/java/com/github/difflib/DiffAlgorithmDefaults.java | New default diff algorithm factory provider |
| java-diff-utils/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java | Refactored parsing into header/file/chunk/tail phases |
| java-diff-utils/src/main/java/com/github/difflib/text/DiffRowGenerator.java | Reduced to orchestrator; delegates inline annotation and delta decompression |
| java-diff-utils/src/main/java/com/github/difflib/text/InlineTagRenderer.java | Extracted tag injection logic used by inline annotation |
| java-diff-utils/src/main/java/com/github/difflib/text/DeltaDecompressor.java | Extracted asymmetric ChangeDelta normalization logic |
| java-diff-utils/src/main/java/com/github/difflib/text/InlineDiffAnnotator.java | New dedicated inline token diff + tag application engine |
| java-diff-utils/src/main/java/com/github/difflib/text/InlineDiffAnnotatorConfig.java | New config carrier for inline annotator execution |
| java-diff-utils/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffRoundTripTest.java | Updated patch application calls to PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithMyerDiffWithLinearSpaceTest.java | Updated patch application calls to PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithMyerDiffTest.java | Updated patch application calls to PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/patch/PatchWithAllDiffAlgorithmsTest.java | Updated patch application calls to PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java | Updated patch application calls to PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/examples/ApplyPatch.java | Updated example to use PatchUtils |
| java-diff-utils/src/test/java/com/github/difflib/DiffUtilsTest.java | Updated inline diff tests to use InlineDiffUtils |
| java-diff-utils/src/test/java/com/github/difflib/algorithm/myers/WithMyersDiffWithLinearSpacePatchTest.java | Updated patch application calls to PatchUtils |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…tibility and fix PMD violations
749d76e to
bbf6ec6
Compare
|
Stale pull request message |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.