find-dead-code

작성자: openshift

사용되지 않는 함수, 클래스, 임포트 및 도달할 수 없는 코드 경로를 찾습니다. 사용자가 죽은 코드, 사용되지 않는 코드, 정리 대상 코드를 찾거나 원할 때 사용하세요.

npx skills add https://github.com/openshift/lightspeed-service --skill find-dead-code

Find Dead Code

Detect unused code that can be safely removed.

Rules

  • Report findings, do not delete. Removal is a separate task.
  • Focus on production code (ols/). Skip tests unless explicitly asked.
  • Vulture has false positives — classify each finding before recommending removal.
  • Code used only via dynamic dispatch (e.g. Pydantic validators, FastAPI dependencies) is not dead.

Step 1: Determine Scope

Ask the user:

  • Branch mode: only files changed in the current branch vs main.
  • Full mode: scan the entire ols/ directory.

For branch mode:

git diff --name-only origin/main -- 'ols/' | grep '\.py$'

Step 2: Run Vulture

uvx vulture <target> --min-confidence 80

--min-confidence 80 reduces noise. Lower confidence findings are more likely false positives.

Step 3: Run Pylint Unused Checks

uv run pylint --disable=all --enable=unused-import,unused-variable,unused-argument,unreachable <target>

Cross-reference with vulture findings to increase confidence.

Step 4: Filter False Positives

Common false positives in this codebase:

PatternWhy it's not dead
Pydantic model_validator, field_validatorCalled by Pydantic, not directly
FastAPI dependency functionsInjected via Depends()
__eq__, __hash__, __str__Called implicitly by Python
Constants used in config YAMLReferenced by config loader
Abstract method implementationsCalled via base class interface
Imports re-exported from __init__.pyUsed by external consumers

Step 5: Classify Findings

For each finding, classify:

CategoryCriteriaAction
RemoveClearly unused, no dynamic referencesSafe to delete
VerifyPossibly used dynamically or externallySearch for string references before removing
False positivePydantic/FastAPI/magic methodSkip

For "Verify" findings, search for string-based references:

rg "<function_or_class_name>" ols/ tests/

Step 6: Report

For each finding:

  1. File and line number
  2. What is unused (function, class, import, variable)
  3. Confidence level (vulture %)
  4. Classification (remove / verify / false positive)

Summary: total findings, how many safe to remove, estimated lines saved.

openshift의 다른 스킬

openshift-docs
openshift
OpenShift Container Platform 문서를 마크다운 형식으로 검색하고 읽습니다. 사용자가 OpenShift 기능, 구성, 설치 등에 대해 질문할 때 사용합니다.
triage-leaked-infra
openshift
AWS VPC 또는 HyperShift CI의 인프라 세트가 삭제해도 안전한지 평가합니다. 사용자가 cleanleaked 출력을 붙여넣고 '이거 삭제해도 되나요?', '이거...'라고 물을 때 사용합니다.
openshift-expert
openshift
OpenShift 플랫폼 및 Kubernetes 전문가로, 클러스터 아키텍처, 오퍼레이터, 네트워킹, 스토리지, 문제 해결 및 CI/CD 파이프라인에 대한 깊은 지식을 보유하고 있습니다. 사용…
Konflux Archived PipelineRuns
openshift
KubeArchive를 통해 보관된 Konflux PipelineRun, TaskRun 및 파드 로그에 접근합니다. Konflux PipelineRun 결과를 확인하거나 조사할 때 자동으로 적용됩니다.
backport
openshift
메인 브랜치에서 릴리스 브랜치로 커밋이나 PR을 백포트합니다. 사용자가 브랜치 간 변경 사항을 백포트, 체리픽, 포팅하거나 해결을 요청할 때 사용합니다.
rebase
openshift
현재 브랜치를 기본 브랜치 위로 리베이스하고, 모든 충돌을 해결한 뒤 린트, i18n, 빌드가 통과하는지 확인합니다. 사용자가 리베이스, 업데이트, 또는 동기화를 요청할 때 사용합니다…
Build CPO Image
openshift
컨트롤 플레인 오퍼레이터 컨테이너 이미지를 빌드하고 푸시합니다. 라이브 클러스터에 배포가 필요한 CPO 변경 사항을 테스트할 때 자동으로 적용됩니다.
find-complexity
openshift
순환 복잡도가 높거나, 길이가 지나치게 길거나, 매개변수가 너무 많은 함수와 메서드를 찾습니다. 사용자가 복잡한 코드나 복잡도를 찾아 달라고 요청할 때 사용하세요.