Skip to content

Commit d31dfd3

Browse files
authored
feat: replaced vulture with grimp - better deadcode detection (#242)
* feat: replaced vulture with grimp - better deadcode detection, also bumped up imports * fix: bug detected
1 parent ef85eeb commit d31dfd3

34 files changed

Lines changed: 191 additions & 205 deletions
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
vulture:
12-
name: Vulture Dead Code Check
11+
grimp:
12+
name: Grimp Orphan Module Check
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v6
@@ -26,7 +26,7 @@ jobs:
2626
uv python install 3.12
2727
uv sync --frozen --group lint --no-dev
2828
29-
- name: Run vulture
29+
- name: Run grimp orphan module check
3030
run: |
3131
cd backend
32-
uv run vulture app/ vulture_whitelist.py
32+
uv run python scripts/check_orphan_modules.py

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ repos:
2222
files: ^backend/.*\.py$
2323
pass_filenames: false
2424

25-
# Vulture - matches CI: cd backend && uv run vulture app/ vulture_whitelist.py
26-
- id: vulture-backend
27-
name: vulture dead code (backend)
28-
entry: bash -c 'cd backend && uv run vulture app/ vulture_whitelist.py'
25+
# Grimp - matches CI: cd backend && uv run python scripts/check_orphan_modules.py
26+
- id: grimp-backend
27+
name: grimp orphan modules (backend)
28+
entry: bash -c 'cd backend && uv run python scripts/check_orphan_modules.py'
2929
language: system
3030
files: ^backend/.*\.py$
3131
pass_filenames: false

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ uv run pytest tests/unit/ # unit only
4848
uv run pytest -k "test_name" -x # single test, stop on failure
4949
uv run ruff check . --config pyproject.toml # lint (must pass)
5050
uv run mypy --config-file pyproject.toml --strict . # types (must pass)
51-
uv run vulture app/ vulture_whitelist.py # dead code (must pass)
51+
uv run python scripts/check_orphan_modules.py # dead code (must pass)
5252

5353
# Frontend (from frontend/)
5454
npm run dev # dev server with hot reload
@@ -732,14 +732,14 @@ vi.mock('../../../lib/api', () => ({
732732
# Backend
733733
uv run ruff check . --config pyproject.toml # rules: E, F, B, I, W; ignore W293
734734
uv run mypy --config-file pyproject.toml --strict . # 318 source files
735-
uv run vulture app/ vulture_whitelist.py # framework patterns in whitelist
735+
uv run python scripts/check_orphan_modules.py # orphan module detection
736736

737737
# Frontend
738738
npm run check # svelte-check: 0 errors, 0 warnings
739739
npm run test # Vitest tests must pass
740740
```
741741

742-
Vulture whitelist (`backend/vulture_whitelist.py`) covers Dishka providers, FastAPI routes, Beanie documents, and Pydantic models that appear unused but are called at runtime.
742+
Grimp orphan module check (`backend/scripts/check_orphan_modules.py`) detects modules never imported by any other module in the package.
743743

744744
---
745745

backend/app/core/providers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727
from app.core.security import SecurityService
2828
from app.core.tracing import Tracer
29-
from app.db.repositories import (
29+
from app.db import (
3030
AdminEventsRepository,
3131
AdminSettingsRepository,
3232
DLQRepository,
@@ -42,7 +42,7 @@
4242
)
4343
from app.dlq.manager import DLQManager
4444
from app.domain.saga import SagaConfig
45-
from app.events.core import UnifiedProducer
45+
from app.events import UnifiedProducer
4646
from app.services.admin import AdminEventsService, AdminSettingsService, AdminUserService
4747
from app.services.admin.admin_execution_service import AdminExecutionService
4848
from app.services.auth_service import AuthService

backend/app/db/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
from app.db.repositories import (
2+
AdminEventsRepository,
23
AdminSettingsRepository,
4+
DLQRepository,
35
EventRepository,
46
ExecutionRepository,
57
NotificationRepository,
68
ReplayRepository,
9+
ResourceAllocationRepository,
710
SagaRepository,
811
SavedScriptRepository,
912
UserRepository,
1013
UserSettingsRepository,
1114
)
1215

1316
__all__ = [
17+
"AdminEventsRepository",
1418
"AdminSettingsRepository",
19+
"DLQRepository",
1520
"EventRepository",
1621
"ExecutionRepository",
1722
"NotificationRepository",
1823
"ReplayRepository",
24+
"ResourceAllocationRepository",
1925
"SagaRepository",
2026
"SavedScriptRepository",
2127
"UserRepository",

backend/app/db/repositories/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from app.db.repositories.admin.admin_events_repository import AdminEventsRepository
2-
from app.db.repositories.admin.admin_settings_repository import AdminSettingsRepository
1+
from app.db.repositories.admin import AdminEventsRepository, AdminSettingsRepository
32
from app.db.repositories.dlq_repository import DLQRepository
43
from app.db.repositories.event_repository import EventRepository
54
from app.db.repositories.execution_repository import ExecutionRepository

backend/app/dlq/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from faststream.kafka import KafkaBroker
77

88
from app.core.metrics import DLQMetrics
9-
from app.db.repositories import DLQRepository
9+
from app.db import DLQRepository
1010
from app.dlq.models import (
1111
DLQBatchRetryResult,
1212
DLQMessage,

backend/app/events/consumer_group_monitor.py

Lines changed: 0 additions & 126 deletions
This file was deleted.

backend/app/events/core/producer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from faststream.kafka import KafkaBroker
33

44
from app.core.metrics import EventMetrics
5-
from app.db.repositories import EventRepository
5+
from app.db import EventRepository
66
from app.domain.events import DomainEvent
77

88

backend/app/services/admin/admin_events_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import structlog
99

10+
from app.db import AdminEventsRepository
1011
from app.db.docs.replay import ReplaySessionDocument
11-
from app.db.repositories import AdminEventsRepository
1212
from app.domain.admin import ReplaySessionData, ReplaySessionStatusDetail, ReplaySessionUpdate
1313
from app.domain.enums import ExportFormat, ReplayStatus, ReplayTarget, ReplayType
1414
from app.domain.events import (

0 commit comments

Comments
 (0)