AgentStack
SKILL verified MIT Self-run

Complexity Analyzer

skill-armanzeroeight-fastagent-plugins-complexity-analyzer · by armanzeroeight

Analyzes cyclomatic and cognitive complexity, identifies overly complex functions. Use when assessing code complexity or identifying functions that need simplification.

No reviews yet
0 installs
15 views
0.0% view→install

Install

$ agentstack add skill-armanzeroeight-fastagent-plugins-complexity-analyzer

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Complexity Analyzer? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Complexity Analyzer

Quick Start

Analyze complexity with tools:

# JavaScript
npx eslint --plugin complexity --rule 'complexity: [error, 10]' src/

# Python
pip install radon
radon cc src/ -a -nb

# General
npx complexity-report src/

Instructions

Step 1: Calculate Cyclomatic Complexity

Count decision points + 1:

  • if, else, elif
  • for, while loops
  • case statements
  • && and || operators
  • ternary operators
  • catch blocks

Example:

function example(x) {  // +1 (base)
  if (x > 0) {         // +1
    return x;
  } else if (x 20)

**processOrder()** - src/orders.js:45
- Cyclomatic: 28
- Cognitive: 35
- Lines: 127
- Recommendation: Extract validation, calculation, and persistence logic

**validateUser()** - src/auth.js:12
- Cyclomatic: 22
- Cognitive: 28
- Lines: 89
- Recommendation: Extract individual validation rules

### Moderate Complexity (11-20)

[List functions with complexity 11-20]

Simplification Strategies

Extract Method

// Before: Complexity 15
function processData(data) {
  if (data.type === 'A') {
    // 20 lines of processing
  } else if (data.type === 'B') {
    // 20 lines of processing
  }
}

// After: Complexity 3
function processData(data) {
  if (data.type === 'A') return processTypeA(data);
  if (data.type === 'B') return processTypeB(data);
}

Replace Nested Conditionals

// Before: Cognitive 12
function getPrice(user, product) {
  if (user) {
    if (user.isPremium) {
      if (product.onSale) {
        return product.price * 0.7;
      } else {
        return product.price * 0.9;
      }
    }
  }
  return product.price;
}

// After: Cognitive 4
function getPrice(user, product) {
  if (!user || !user.isPremium) return product.price;
  if (product.onSale) return product.price * 0.7;
  return product.price * 0.9;
}

Use Polymorphism

// Before: Complexity 8
function getArea(shape) {
  if (shape.type === 'circle') {
    return Math.PI * shape.radius ** 2;
  } else if (shape.type === 'square') {
    return shape.side ** 2;
  }
  // ... more types
}

// After: Complexity 1 per class
class Circle {
  getArea() { return Math.PI * this.radius ** 2; }
}
class Square {
  getArea() { return this.side ** 2; }
}

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.