Skip to main content
Analyze function complexity across your codebase. Fallow computes cyclomatic and cognitive complexity for every function, then reports those exceeding configurable thresholds.
Use --top N to quickly find the most complex functions without setting thresholds.
fallow health

Options

Thresholds

FlagDescription
--max-cyclomatic <N>Maximum cyclomatic complexity before reporting (default: 20)
--max-cognitive <N>Maximum cognitive complexity before reporting (default: 15)

Output

FlagDescription
-f, --format <FORMAT>Output format: human (default), json, compact
--top <N>Show only the top N most complex functions
--sort <METRIC>Sort by: cyclomatic (default), cognitive, lines

Exit codes

CodeMeaning
0No functions exceed the configured thresholds
1One or more functions exceed a threshold

Examples

# Report functions exceeding default thresholds
fallow health

Example output

$ fallow health --top 5
  1. src/server/resolvers/analytics.ts:42  processAnalytics
     cyclomatic: 34  cognitive: 28  lines: 187

  2. src/features/auth/handlers.ts:118  handleOAuthCallback
     cyclomatic: 27  cognitive: 22  lines: 134

  3. src/utils/parser.ts:15  parseExpression
     cyclomatic: 25  cognitive: 31  lines: 98

  4. src/server/middleware/validate.ts:8  validateRequest
     cyclomatic: 22  cognitive: 18  lines: 76

  5. src/components/Table/Table.tsx:44  renderColumns
     cyclomatic: 21  cognitive: 16  lines: 112

5 functions exceed thresholds (0.14s)

JSON output

$ fallow health --format json --top 2
{
  "functions": [
    {
      "file": "src/server/resolvers/analytics.ts",
      "line": 42,
      "name": "processAnalytics",
      "cyclomatic": 34,
      "cognitive": 28,
      "lines": 187
    },
    {
      "file": "src/features/auth/handlers.ts",
      "line": 118,
      "name": "handleOAuthCallback",
      "cyclomatic": 27,
      "cognitive": 22,
      "lines": 134
    }
  ],
  "summary": {
    "functions_analyzed": 1842,
    "functions_exceeding": 2
  }
}

Configuration

Configure default thresholds and ignore patterns in your config file:
{
  "health": {
    "maxCyclomatic": 20,
    "maxCognitive": 15,
    "ignore": ["**/*.generated.ts", "src/legacy/**"]
  }
}
See Configuration for the full config reference.

See also

Dead code analysis

Find unused code alongside complexity hotspots.

Configuration

Set default thresholds in your config file.

CI integration

Enforce complexity limits in your pipeline.