Move third-party sources, tighten encapsulation, extend Konsist rules - #4
Merged
Conversation
markitdown and anydoc are reference sources for the benchmark, not part of the build. Grouping them keeps the repository root to this project's own layout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The JVM and Android source sets held nine byte-identical converter files. They drifted twice during recent work, each time silently, because nothing checked them against each other. - a jvmShared source set now holds every converter that both targets run; only PdfConverter (pdfbox vs pdfbox-android) and the factory stay per-target - explicit API mode: every exported declaration states visibility and return type, which turned up helpers that were public only by omission — HtmlToDocument, plainTextBlocks and both MIME detectors are now internal - converter selection moved into a ConverterRegistry that sorts on registration and never hands out its entries, instead of a Pair list re-sorted per parse - DocumentBuilder's title is private behind titleIfAbsent()/title(), and the builders carry a @DocumentDsl marker so inline scopes cannot reach document-level methods Six new Konsist rules, each verified to fail against a planted violation: - helpers under utils are never public - the model exposes no mutable state - every DocumentConverter is named *Converter and lives in converters - converters do not import each other - no wildcard imports, no printing from library code - no production file exists in two source sets, with the two platform-specific files named explicitly, so the duplication cannot come back unnoticed Converted output is byte-identical across all eight fixtures. Co-Authored-By: Claude Opus 5 (1M context) <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.
Two commits.
1. Move vendored checkouts under
third-party/markitdownandanydocare reference sources for the benchmark, not part of the build.third-party/markitdownandthird-party/anydocnow; the repository root is this project's own layout again.scripts/benchmark.pyalso picks up acargo build --releaseinsidethird-party/anydoc.2. Encapsulation, and rules that keep it
The duplication that kept biting. JVM and Android held nine byte-identical converter files. They drifted twice during recent work — once in
EpubConverter, once inPptxConverter— and nothing caught it either time. AjvmSharedsource set now holds every converter both targets run. OnlyPdfConverter(pdfbox vs pdfbox-android) and the platform factories remain per-target.Explicit API mode. The library now builds with
explicitApi(), so every exported declaration states its visibility and return type. This surfaced several helpers that were public only because nobody wrote a modifier:HtmlToDocument,plainTextBlocks,TikaMimeDetectorandAndroidMimeDetectorare allinternalnow.Smaller cleanups.
ConverterRegistrythat sorts on registration and never exposes its entries, replacing aPair<DocumentConverter, Double>list re-sorted on everyparseDocumentBuilder.titleis private behindtitleIfAbsent()/title()@DocumentDslmarker, so aninlines { }block cannot silently call document-level methodsSix new Konsist rules (11 total), each verified to fail against a planted violation before being committed:
utilsare never publicvaron an exported model typeDocumentConverteris named*Converterand lives inconvertersThe last one names the two legitimately platform-specific files explicitly, so adding a third requires saying so out loud.
Verification
./gradlew checkpasses: JVM tests, Android host tests, CLI build, detekt, ktfmtCheck, and all 11 architecture rules.Converted output is byte-identical across all eight fixtures — this refactor moves code without changing behaviour.
🤖 Generated with Claude Code