Skip to content

refactor: extract AbstractPythonAntlrDetector, fix MD5 hotspot, boost coverage to 90.6%#36

Merged
aksOps merged 2 commits into
mainfrom
coverage/boost-80pct-r2
Apr 4, 2026
Merged

refactor: extract AbstractPythonAntlrDetector, fix MD5 hotspot, boost coverage to 90.6%#36
aksOps merged 2 commits into
mainfrom
coverage/boost-80pct-r2

Conversation

@aksOps

@aksOps aksOps commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Coverage: 1500+ new tests bring local line coverage to 90.6% (projected SonarCloud ~83–86% after grammar file exclusions)
  • Security: Replace MD5 with SHA-256 in FileHasher — removes 2 SonarCloud security hotspots
  • Duplication: Extract AbstractPythonAntlrDetector and AbstractPythonDbDetector base classes, eliminating ~325 lines of copy-paste across 10 Python detectors (~13% → lower duplication rate)

Changes

New base classes

  • AbstractPythonAntlrDetector — shared parse() (500 KB ANTLR cutoff), getSupportedLanguages(), getBaseClassesText(), extractClassBody(), NEXT_CLASS_RE
  • AbstractPythonDbDetector — adds ensureDbNode() + addDbEdge() for ORM detectors

Detectors refactored

All 10 Python ANTLR detectors now extend the appropriate base class: CeleryTaskDetector, DjangoAuthDetector, DjangoModelDetector, DjangoViewDetector, FastAPIAuthDetector, FastAPIRouteDetector, FlaskRouteDetector, PydanticModelDetector, PythonStructuresDetector, SQLAlchemyModelDetector

Security fix

FileHasher: MD5 → SHA-256 (both hash(Path) and hashString(String))

Test plan

  • All 3219 tests pass locally (0 failures, 0 errors)
  • FileHasherTest + CacheCoverageTest updated for SHA-256 output length (64 hex chars)
  • SonarCloud CI scan to confirm coverage and duplication improvements

🤖 Generated with Claude Code

aksOps and others added 2 commits April 4, 2026 13:15
- 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>
@aksOps aksOps merged commit e5d49de into main Apr 4, 2026
6 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Apr 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.9% Coverage on New Code (required ≥ 80%)
10.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

1 participant