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 की और Skills

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 PipelineRuns, TaskRuns और पॉड लॉग तक पहुँचता है। Konflux PipelineRun परिणामों की जाँच करते समय, जाँच करते समय स्वचालित रूप से लागू होता है…
backport
openshift
मुख्य शाखा से रिलीज़ शाखा में कमिट या PR को बैकपोर्ट करें। जब उपयोगकर्ता बैकपोर्ट, चेरी-पिक, या शाखाओं के बीच परिवर्तन पोर्ट करने के लिए कहे, या समाधान करते समय उपयोग करें…
rebase
openshift
वर्तमान शाखा को उसकी आधार शाखा पर रीबेस करें, सभी विरोधों को हल करें, और लिंट, i18n, और बिल्ड पास होने की पुष्टि करें। उपयोग तब करें जब उपयोगकर्ता रीबेस, अपडेट या सिंक करने के लिए कहे…
Build CPO Image
openshift
कंट्रोल-प्लेन-ऑपरेटर कंटेनर इमेज बनाएँ और पुश करें। CPO परिवर्तनों का परीक्षण करते समय जिन्हें लाइव क्लस्टर पर तैनात करने की आवश्यकता होती है, स्वचालित रूप से लागू होता है।
find-complexity
openshift
उच्च चक्रीय जटिलता, अत्यधिक लंबाई या बहुत अधिक पैरामीटर वाले फंक्शन और मेथड खोजें। उपयोग तब करें जब उपयोगकर्ता जटिल कोड, जटिलता खोजने के लिए कहे…