npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@raketa-cloud/complexity-checker

v1.0.9

Published

Cyclomatic and cognitive complexity analyzer for JavaScript/TypeScript projects

Downloads

170

Readme

JavaScript Complexity Analyzer

A powerful CLI tool for analyzing cyclomatic and cognitive complexity in JavaScript/TypeScript projects. Perfect for CI/CD pipelines and code quality monitoring.

Quick Start

# Analyze current directory (default: cyclomatic complexity)
npx @raketa-cloud/complexity-checker

# Analyze cognitive complexity with custom thresholds
npx @raketa-cloud/complexity-checker ./src --type cognitive --error-threshold 15 --warning-threshold 10

# Generate detailed report
npx @raketa-cloud/complexity-checker ./src --report complexity-report.json

Features

  • Single Complexity Focus: Analyze either cyclomatic or cognitive complexity
  • CI/CD Ready: Exit codes for pipeline integration
  • Configurable Thresholds: Custom warning and error levels
  • Smart Filtering: Ignore patterns with glob support
  • Configuration File: JSON-based project configuration
  • Detailed Reports: JSON output for tracking over time
  • Fast Analysis: Babel-powered AST parsing
  • TypeScript Support: Analyze .js, .jsx, .ts, .tsx files

CLI Options

| Option | Description | Default | |--------|-------------|---------| | --type <type> | Complexity type to analyze (cyclomatic or cognitive) | cyclomatic | | --error-threshold <number> | Error threshold for complexity | 20 | | --warning-threshold <number> | Warning threshold for complexity | 10 | | --report <file> | Save detailed JSON report to file | - |

Usage Examples

CI/CD Integration

# GitHub Actions example
- name: Check code complexity
  run: npx @raketa-cloud/complexity-checker ./src --type cognitive --error-threshold 20

Local Development

# Quick check with default settings (cyclomatic complexity)
npx @raketa-cloud/complexity-checker ./src

# Analyze cognitive complexity with strict thresholds
npx @raketa-cloud/complexity-checker ./src --type cognitive --error-threshold 15 --warning-threshold 8

# Generate report for tracking
npx @raketa-cloud/complexity-checker ./src --report "reports/complexity-$(date +%Y%m%d).json"

Configuration File

Create a complexity.config.json file in the root of your analyzed directory:

{
  "type": "cognitive",
  "errorThreshold": 25,
  "warningThreshold": 15,
  "ignore": [
    "**/test/**",
    "**/*.spec.js",
    "**/vendor/**"
  ]
}

Configuration options:

  • type: Complexity type to analyze ("cyclomatic" or "cognitive")
  • errorThreshold: Error threshold for complexity
  • warningThreshold: Warning threshold for complexity
  • ignore: Array of glob patterns to ignore

CLI options will override configuration file settings.

Exit Codes

  • 0 - Success (no violations)
  • 1 - Complexity thresholds exceeded
  • 2 - Tool error (file not found, parse errors)

Output Examples

Success:

✓ No complexity threshold violations found

Warnings and Errors:

🟠 [12/10] parseComplexConfig @ src/utils/parser.js:45
🟠 [16/10] renderRows @ src/components/DataTable.js:23
🔴 [25/20] processData @ src/legacy/processor.js:156
🔴 [28/20] convertLegacyData @ src/legacy/converter.js:89

The format shows: [actual_complexity/threshold] function_name @ file_path:line

  • 🟠 indicates warnings (complexity ≥ warning threshold but < error threshold)
  • 🔴 indicates errors (complexity ≥ error threshold)

Note: All violations are collected and displayed, then exits with code 1 if any errors exist