find-complexity

작성자: openshift

순환 복잡도가 높거나, 길이가 지나치게 길거나, 매개변수가 너무 많은 함수와 메서드를 찾습니다. 사용자가 복잡한 코드나 복잡도를 찾아 달라고 요청할 때 사용하세요.

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

Find Complexity Hotspots

Identify functions that are hard to review, test, and maintain.

Rules

  • Report findings, do not refactor. Refactoring is a separate task.
  • Focus on production code (ols/). Skip tests unless explicitly asked.
  • Rank by severity: highest complexity first.

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: Cyclomatic Complexity

uvx radon cc <target> -s -n C -a

This shows functions with complexity grade C or worse (threshold: 11+).

Grades: A (1-5), B (6-10), C (11-15), D (16-20), E (21-25), F (26+).

Step 3: Maintainability Index

uvx radon mi <target> -s -n B

This shows files with maintainability grade B or worse.

Grades: A (20+, good), B (10-19, medium), C (0-9, poor).

Step 4: Cognitive Complexity

Cognitive complexity weights nesting depth — a 5-deep if scores much higher than 5 sequential ifs.

uvx --with flake8-cognitive-complexity flake8 --select=CCR001 --max-cognitive-complexity=10 <target>

Step 5: Function Length

Find long functions (30+ lines of logic, excluding docstrings and blank lines):

uvx radon raw <target> -s

Also use pylint for method length:

uv run pylint --disable=all --enable=too-many-statements,too-many-branches,too-many-return-statements,too-many-arguments,too-many-locals <target>

Step 6: File Size

Find large files (500+ lines):

wc -l $(find <target> -name '*.py') | sort -rn | head -20

Files over 500 lines are candidates for splitting into focused modules.

Step 7: Classify Findings

For each function found, classify:

CategoryCriteriaAction
SplitHigh complexity + long bodyBreak into smaller functions
SimplifyHigh complexity + short bodyReduce branching (early returns, lookup tables)
ParameterizeToo many arguments (6+)Group into config/dataclass
MonitorGrade C, not growingNote it, revisit if it gets worse
Split fileFile over 500 linesBreak into focused modules

Step 8: Report

For each finding:

  1. File, function name, line number
  2. Complexity grade and score
  3. Number of statements / arguments
  4. Classification (split / simplify / parameterize / monitor)
  5. Brief suggestion

Summary: total hotspots by grade, top 5 worst offenders.

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 변경 사항을 테스트할 때 자동으로 적용됩니다.
raise-pr
openshift
lightspeed-service 저장소에서 스테이징된 변경 사항을 커밋하고 풀 리퀘스트를 여는 단계별 워크플로우입니다.