Skip to content
Back to skills

Example 4 Complexity Reduction

ASecurity

Sub-skill of sparc-refinement: Example 4: Complexity Reduction.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
developmenttypescriptgo

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add vamseeachanta/workspace-hub --skill example-4-complexity-reduction --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Example 4 Complexity Reduction?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Example 4 Complexity Reduction
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vamseeachanta-example-4-complexity-reduction/badge)](https://www.skillsdirectory.com/skills/vamseeachanta-example-4-complexity-reduction)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sparc-refinement-example-4-complexity-reduction
description: 'Sub-skill of sparc-refinement: Example 4: Complexity Reduction.'
version: 1.0.0
category: development
type: reference
scripts_exempt: true
---

# Example 4: Complexity Reduction

## Example 4: Complexity Reduction


```typescript
// Bad: Cyclomatic complexity = 7
function processUser(user: User): void {
  if (user.age > 18) {
    if (user.country === 'US') {
      if (user.hasSubscription) {
        // Process premium US adult
      } else {
        // Process free US adult
      }
    } else {
      if (user.hasSubscription) {
        // Process premium international adult
      } else {
        // Process free international adult
      }
    }
  } else {
    // Process minor
  }
}

// Good: Cyclomatic complexity = 2
function processUser(user: User): void {
  const processor = getUserProcessor(user);
  processor.process(user);
}

function getUserProcessor(user: User): UserProcessor {
  const type = getUserType(user);
  return ProcessorFactory.create(type);
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.