Skip to content

fix: reduce dead code false positives#104

Draft
gzenz wants to merge 1 commit intotirth8205:mainfrom
gzenz:fix/reduce-dead-code-false-positives
Draft

fix: reduce dead code false positives#104
gzenz wants to merge 1 commit intotirth8205:mainfrom
gzenz:fix/reduce-dead-code-false-positives

Conversation

@gzenz
Copy link
Copy Markdown
Contributor

@gzenz gzenz commented Apr 5, 2026

Summary

  • Extract decorators/annotations from AST into node.extra["decorators"] for Python, Java/Kotlin/C#, and TypeScript -- enables framework entry point detection that was previously wired but never populated
  • Expand _FRAMEWORK_DECORATOR_PATTERNS from 8 to 22 patterns (pytest fixtures, Django signals, SQLAlchemy events, Celery tasks, Spring annotations, Flask/Starlette middleware, NestJS/Angular decorators)
  • Exclude dunder methods (__init__, __str__, etc.) from dead code results -- runtime-invoked, never have explicit callers
  • Skip classes referenced in function type annotations (Pydantic schemas, dataclasses used as param/return types)

Test plan

  • 2 parser tests: decorator extraction for Python functions and classes
  • 4 flows tests: new decorator patterns (pytest, Django, Spring, Celery)
  • 4 refactor tests: dunder exclusion, decorated entry points, type-ref via params, type-ref via return type
  • Full suite: 575 passed, 0 failures

- Extract decorators/annotations from AST into node.extra["decorators"]
  for Python, Java/Kotlin/C#, and TypeScript
- Expand framework decorator patterns from 8 to 24 (pytest, Django,
  Spring, Celery, NestJS, pydantic-ai agent tools, etc.)
- Exclude dunder methods from dead code results
- Skip classes referenced in function type annotations (Pydantic schemas)
- Per-symbol IMPORTS_FROM edges for JS/TS/TSX named imports -- eliminates
  ~320 FPs from frontend codebases
- ORM/framework base class exclusion (Base, DeclarativeBase, BaseModel,
  BaseSettings, etc.)
- New entry point name patterns: upgrade/downgrade (Alembic),
  lifespan/get_db (FastAPI)
@gzenz gzenz force-pushed the fix/reduce-dead-code-false-positives branch from 9a17cd9 to dea608f Compare April 5, 2026 16:52
@gzenz gzenz marked this pull request as draft April 5, 2026 21:59
Copy link
Copy Markdown
Owner

@tirth8205 tirth8205 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement to dead code detection accuracy — expanding framework patterns from 8 to 22, excluding dunder methods, and using AST decorators are all valuable. 314 lines of new tests.

Please rebase on latest main. Once rebased and CI passes, we'll review for merge.

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.

2 participants