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.

Skills เพิ่มเติมจาก openshift

openshift-expert
openshift
ผู้เชี่ยวชาญด้านแพลตฟอร์ม OpenShift และ Kubernetes ที่มีความรู้เชิงลึกเกี่ยวกับสถาปัตยกรรมคลัสเตอร์ โอเปอเรเตอร์ เครือข่าย พื้นที่จัดเก็บข้อมูล การแก้ไขปัญหา และไปป์ไลน์ CI/CD ใช้…
official
find-token
openshift
ค้นหาโทเค็นการยืนยันที่ซ่อนอยู่ รันสคริปต์ find-token เพื่อดึงโทเค็นที่ไม่ซ้ำกัน
official
code-review
openshift
ตรวจสอบ pull request เพื่อดูคุณภาพโค้ด ความถูกต้อง และความสอดคล้องกับข้อกำหนดของโปรเจกต์ ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ PR, ตรวจสอบโค้ด หรือตรวจสอบการเปลี่ยนแปลงใน...
official
css-review
openshift
ตรวจสอบ CSS สำหรับรูปแบบการเขียนโค้ด การใช้โทเค็น PatternFly และแนวปฏิบัติที่ดีที่สุด ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ CSS ตรวจสอบสไตล์ หรือตรวจสอบไฟล์ CSS
official
review-readmes
openshift
ตรวจสอบไฟล์ README.md ทั้งหมดใน repo เพื่อหาคำผิด ข้อผิดพลาด และข้อมูลที่ล้าสมัย ใช้เมื่อผู้ใช้ขอให้ตรวจสอบ README ตรวจสอบความถูกต้องของเอกสาร หรือ…
official
review-skills
openshift
ตรวจสอบทักษะ AI ของโครงการเพื่อหาความซ้ำซ้อน การอ้างอิงที่ล้าสมัย ข้อผิดพลาด และปัญหาเชิงโครงสร้าง ใช้เมื่อผู้ใช้ขอให้ตรวจสอบทักษะ ตรวจสอบทักษะ ตรวจสอบหา…
official
test
openshift
รันการทดสอบแบบ end-to-end ที่กรองตามแท็ก ใช้เมื่อผู้ใช้ขอให้รันการทดสอบ รัน Playwright หรือทดสอบฟีเจอร์เฉพาะแท็ก เช่น @core หรือ @attach
official
unused-exports
openshift
ค้นหาสัญลักษณ์ที่ถูกส่งออกแต่ไม่เคยถูกนำเข้าโดยไฟล์อื่น ใช้เมื่อผู้ใช้พูดว่า "ตรวจสอบการส่งออก" "ส่งออกที่ไม่ได้ใช้" หรือขอให้ทำความสะอาดการส่งออก
official