Przejdź do treści
Biblioteka skilli
Programowanie · Analiza

cyclomatic-complexity

/cyclomatic-complexity

Mierzy złożoność rozgałęzień funkcji i zmniejsza ją, by logika pozostała testowalna, gdy funkcja ma wiele ścieżek, głębokie zagnieżdżenia lub długi łańcuch if albo switch.

Repozytorium
AI-SKILLS ↗
Licencja
MIT
Ostatnia zmiana repozytorium
05.09.2026

Ocena i bezpieczeństwo

90/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść25 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 05.09.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Mierzy złożoność rozgałęzień funkcji i zmniejsza ją, by logika pozostała testowalna, gdy funkcja ma wiele ścieżek, głębokie zagnieżdżenia lub długi łańcuch if albo switch.

Oryginalny opis (EN)

Measure a function's branching complexity and reduce it so the logic stays testable. Use when a function has many paths, deep nesting, or a long if or switch chain.

Jak działa

  1. Method
  2. Checks
  3. Boundaries
Sekcje z nagłówków SKILL.md, w oryginale · 50 linii, 433 słów
Podgląd SKILL.md
---
name: cyclomatic-complexity
description: Measure a function's branching complexity and reduce it so the logic stays testable. Use when a function has many paths, deep nesting, or a long if or switch chain.
---

# Cyclomatic complexity

Cyclomatic complexity counts the independent paths through a function: one plus
each branch point (`if`, `for`, `while`, `case`, and every `&&` or `||`). Paths
multiply the tests a function needs and the states a reader must hold at once,
and past roughly ten paths a function stops fitting in one head.

## Method

1. **Measure before you judge.** Run a real tool: `radon cc -s file.py`, the
   ESLint `complexity` rule, `gocyclo`, or SonarQube. Rank functions by score
   and start with the worst. A number ends the argument about whether a function
   merely "feels" complex.
2. **Set a threshold, treat crossings as a signal not a law.** Flag functions
   over 10 for a look and over 15 for a rewrite plan. The score is a smoke
   alarm: it says where to look, not that the code is wrong. Some parsers and
   state machines earn their number.
3. **Extract cohesive branches into named functions.** Each block pulled out
   drops the parent's count and gives the logic a name and a seam to test. A
   40-path function that becomes a 6-path coordinator calling five 8-path
   helpers is far more testable, even though the total branches barely move.
4. **Replace nesting with early returns.** Guard invalid and edge cases at the
   top and return, so the main path steps out from under the arrow of nested
   `if` blocks. Every level removed cuts the states a reader tracks through the
   rest of the function.
5. **Turn a long switch on a value into table dispatch.** Map keys to handlers:
   `handlers[event.type](event)`. A twelve-case switch scoring 12 becomes a
   lookup scoring 1, and adding a case is a map entry rather than a new branch.
6. **Collapse compound conditions into named predicates.** `if (a && b && !c)`
   hides several paths in one line. Extract `isEligible(...)` returning a
   boolean: the branches move into a small, separately testable function whose
   name states what it decides.

## Checks

- Does the tool's score actually drop after the change, not just relocate to a
  helper you forgot to re-measure?
- Can you still name every path the function takes, or did extraction only hide
  them behind a call?
- Is the deepest nesting two levels or fewer once the guards are in place?

## Boundaries

The score is one signal: a low number with terrible names is still unreadable,
and a slightly high number in a genuinely branchy state machine can be the
clearest form available. Do not extract single-use helpers with vague names just
to move a metric. Defer length questions to function-size and profiling to the
performance skills.

Wersje

RepozytoriumWynikLicencja
Ta strona · Amey-Thakur/AI-SKILLS90MIT
saurabhkumar8112/cyclomatic-complexity-skill100Apache-2.0
ambervdberg/sniff100MIT

Migawka bazy z 28.10.2026 · wersja paczki 9c1d5bccc42d (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100code-complexity-scanner
    Mierzy złożoność cyklomatyczną i kognitywną oraz długość funkcji w bazie kodu, by wskazać hotspoty utrzymaniowe.
  • 84audit-complexity
    Mierzy złożoność cyklomatyczną, poznawczą i trudność Halsteada dla każdej funkcji w zmianie, ścieżce lub całym drzewie, podając obok liczb źródła odniesienia.
  • 100code-simplification
    Redukuje złożoność działającego kodu bez zmiany zachowania: głębokie zagnieżdżenia, długie funkcje, duplikaty, martwy kod, niejasne nazwy i funkcje trudne do testowania.
  • 100reviewing-naming-and-readability
    Sprawdza lokalną czytelność kodu: nazwy oddające intencję, długość funkcji, głębokie zagnieżdżenia i mieszane poziomy abstrakcji.
  • 90complexity-rework
    Audytuje i przerabia kod trudny do czytania: długie łańcuchy if i switch, flagi, głębokie zagnieżdżenia i testy charakteryzujące.
  • 100complexity
    Upraszcza zmieniony kod: mierzy złożoność cyklomatyczną i kognitywną, refaktoryzuje najgorsze miejsca najpierw i dowodzi, że zachowanie się nie zmieniło.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.