find-complexity

Find functions and methods with high cyclomatic complexity, excessive length, or too many parameters. Use when the user asks to find complex code, complexity…

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.

Mehr Skills von openshift

openshift-expert
openshift
OpenShift-Plattform- und Kubernetes-Experte mit fundierten Kenntnissen in Cluster-Architektur, Operatoren, Netzwerk, Speicher, Fehlerbehebung und CI/CD-Pipelines. Nutzen…
official
find-token
openshift
Finde das versteckte Verifikationstoken. Führe das find-token-Skript aus, um ein eindeutiges Token abzurufen.
official
code-review
openshift
Überprüfe einen Pull-Request auf Codequalität, Korrektheit und Projektkonventionen. Verwende dies, wenn der Benutzer bittet, einen PR zu überprüfen, Code-Review durchzuführen oder Änderungen an einem…
official
css-review
openshift
Überprüft CSS auf Codierungsstil, PatternFly-Token-Nutzung und Best Practices. Verwenden Sie dies, wenn der Benutzer darum bittet, CSS zu überprüfen, Stile zu prüfen oder CSS-Dateien zu auditieren.
official
review-readmes
openshift
Überprüfe alle README.md-Dateien im Repository auf Tippfehler, Fehler und veraltete Informationen. Verwende dies, wenn der Benutzer darum bittet, READMEs zu überprüfen, die Dokumentationsgenauigkeit zu prüfen oder…
official
review-skills
openshift
Projekt-KI-Fähigkeiten auf Duplikate, veraltete Referenzen, Fehler und strukturelle Probleme überprüfen. Verwenden, wenn der Benutzer darum bittet, Fähigkeiten zu überprüfen, zu auditieren, auf … zu prüfen.
official
test
openshift
Führe End-to-End-Tests gefiltert nach Tag aus. Verwende, wenn der Benutzer darum bittet, Tests auszuführen, Playwright zu starten oder ein bestimmtes Feature-Tag wie @core oder @attach zu testen.
official
unused-exports
openshift
Finde exportierte Symbole, die nie von einer anderen Datei importiert werden. Verwende dies, wenn der Benutzer "check exports", "unused exports" sagt oder darum bittet, Exporte aufzuräumen.
official