find-duplication

द्वारा openshift

कोडबेस में कोड डुप्लिकेशन खोजें। दो मोड का समर्थन करता है - वर्तमान ब्रांच परिवर्तनों तक सीमित या पूर्ण कोडबेस स्कैन। तब उपयोग करें जब उपयोगकर्ता खोजने के लिए कहे…

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

Find Code Duplication

Detect duplicated or near-duplicate code and suggest consolidation candidates.

Rules

  • Report findings, do not refactor. Refactoring is a separate task.
  • Focus on production code (ols/). Skip test duplication unless explicitly asked.
  • Group findings by severity: exact duplicates first, then near-duplicates.
  • For each finding, state whether extraction is worth it or acceptable duplication.

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$'

For full mode, the target is ols/.

Step 2: Run Pylint Duplicate Detection

uv run pylint --disable=all --enable=duplicate-code --min-similarity-lines=6 <target files or directory>

Review output. Filter out false positives:

  • Import blocks (common imports are not duplication)
  • Pydantic model boilerplate (Field declarations)
  • Single-line patterns (logging, raises)

Step 3: Semantic Duplication Search

Pylint only catches textual similarity. Also look for:

  1. Similar function signatures — functions with near-identical parameter lists doing similar work.
  2. Repeated error handling — same try/except/log/return pattern across multiple files.
  3. Copy-pasted blocks — search for distinctive string literals or variable names that appear in multiple files.
rg "<distinctive pattern>" ols/ --type py -l

Step 4: Classify Findings

For each duplicate found, classify:

CategoryAction
Extract — identical logic in 3+ placesRecommend a shared helper
Parameterize — same structure, different valuesRecommend a common function with parameters
Acceptable — similar but serving different domainsNote it, no action needed
Test-only — repeated test setup/fixturesRecommend shared fixture (only if user asked)

Step 5: Report

For each finding:

  1. Files and line ranges involved
  2. What is duplicated (brief description)
  3. Classification (extract / parameterize / acceptable)
  4. Suggested location for shared code (if applicable)

Summary: total findings, how many actionable, 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
उच्च चक्रीय जटिलता, अत्यधिक लंबाई या बहुत अधिक पैरामीटर वाले फंक्शन और मेथड खोजें। उपयोग तब करें जब उपयोगकर्ता जटिल कोड, जटिलता खोजने के लिए कहे…