refactor: extract AbstractPythonAntlrDetector, fix MD5 hotspot, boost coverage to 90.6%#36
Merged
Conversation
- Extract AbstractPythonAntlrDetector base class (parse, getSupportedLanguages, getBaseClassesText, extractClassBody, NEXT_CLASS_RE) shared across all 10 Python ANTLR detectors — eliminates ~325 lines of duplicated code - Extract AbstractPythonDbDetector for Django/SQLAlchemy ORM detectors (ensureDbNode, addDbEdge) — further reduces duplication - Replace MD5 with SHA-256 in FileHasher (fixes 2 SonarCloud security hotspots) - Update FileHasherTest + CacheCoverageTest for SHA-256 output length (64 vs 32) Co-Authored-By: Claude Sonnet 4.6 <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.


Summary
FileHasher— removes 2 SonarCloud security hotspotsAbstractPythonAntlrDetectorandAbstractPythonDbDetectorbase classes, eliminating ~325 lines of copy-paste across 10 Python detectors (~13% → lower duplication rate)Changes
New base classes
AbstractPythonAntlrDetector— sharedparse()(500 KB ANTLR cutoff),getSupportedLanguages(),getBaseClassesText(),extractClassBody(),NEXT_CLASS_REAbstractPythonDbDetector— addsensureDbNode()+addDbEdge()for ORM detectorsDetectors refactored
All 10 Python ANTLR detectors now extend the appropriate base class:
CeleryTaskDetector,DjangoAuthDetector,DjangoModelDetector,DjangoViewDetector,FastAPIAuthDetector,FastAPIRouteDetector,FlaskRouteDetector,PydanticModelDetector,PythonStructuresDetector,SQLAlchemyModelDetectorSecurity fix
FileHasher: MD5 → SHA-256 (bothhash(Path)andhashString(String))Test plan
FileHasherTest+CacheCoverageTestupdated for SHA-256 output length (64 hex chars)🤖 Generated with Claude Code