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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ramnalawade1986/comprehensive-code-analyzer

v0.0.2

Published

A comprehensive TypeScript/JavaScript code analyzer with SonarQube-style quality analysis, security scanning, and GDPR compliance checking

Downloads

7

Readme

Comprehensive Code Analyzer

A powerful, extensible TypeScript/JavaScript code analyzer that provides SonarQube-style quality analysis, security scanning, and GDPR compliance checking.

Features

🔍 Quality Analysis

  • Cyclomatic & Cognitive Complexity - Advanced complexity metrics with configurable thresholds
  • Maintainability Index - Halstead-based maintainability scoring
  • Technical Debt Assessment - Quantified technical debt in minutes
  • Code Duplication Detection - AST-based duplication analysis with refactoring suggestions
  • Documentation Coverage - JSDoc analysis with quality scoring
  • Naming Convention Validation - Configurable naming rules for functions, classes, variables

🛡️ Security Analysis

  • Vulnerability Scanning - Detection of common security vulnerabilities
  • Secret Detection - API keys, passwords, and sensitive data detection
  • Cryptographic Analysis - Weak encryption and hashing algorithm detection
  • Input Validation - SQL injection, XSS, and other injection vulnerabilities

📋 Compliance Checking

  • GDPR Compliance - Personal data handling and privacy compliance analysis
  • Security Standards - OWASP Top 10 compliance checking
  • Industry Standards - Configurable compliance framework support

📊 Quality Gates

  • SonarQube-style Gates - Configurable quality thresholds
  • Rating System - A-E ratings for complexity, maintainability, and reliability
  • Metrics Dashboard - Comprehensive project health metrics

Installation

Global Installation

npm install -g @aitek/comprehensive-code-analyzer

Project Installation

npm install --save-dev @aitek/comprehensive-code-analyzer

Quick Start

Command Line Usage

# Analyze current directory
code-analyzer analyze .

# Analyze specific files
code-analyzer analyze src/components/*.ts

# Generate HTML report
code-analyzer analyze . --format html --output report.html

# Run specific analyzers only
code-analyzer analyze . --analyzers quality-analyzer,security-analyzer

# Initialize configuration file
code-analyzer init

Programmatic Usage

import { ComprehensiveCodeAnalyzer } from '@aitek/comprehensive-code-analyzer';

const analyzer = new ComprehensiveCodeAnalyzer();

// Analyze files
const report = await analyzer.analyze(['src/**/*.ts'], {
  analyzers: ['quality-analyzer', 'security-analyzer'],
  format: 'json',
  includeMetrics: true
});

console.log(`Found ${report.summary.totalIssues} issues`);
console.log(`Quality Rating: ${report.summary.qualityRating}`);
console.log(`Technical Debt: ${report.summary.technicalDebt} minutes`);

Configuration

Create a .code-analyzer.json file in your project root:

{
  "analyzers": [
    "quality-analyzer",
    "security-analyzer",
    "vulnerability-scanner",
    "gdpr-compliance-analyzer"
  ],
  "include": ["**/*.{ts,js,tsx,jsx}"],
  "exclude": ["node_modules/**", "dist/**", "*.test.{ts,js}"],
  "thresholds": {
    "cyclomaticComplexity": 10,
    "cognitiveComplexity": 15,
    "maintainabilityIndex": 20,
    "technicalDebtRatio": 5,
    "duplicatedLinesThreshold": 3
  },
  "qualityGates": {
    "coverage": 80,
    "duplicatedLines": 3,
    "maintainabilityRating": "C",
    "reliabilityRating": "B"
  },
  "reporting": {
    "format": "json",
    "includeMetrics": true,
    "includeSuggestions": true
  }
}

Available Analyzers

| Analyzer | Description | |----------|-------------| | quality-analyzer | Code quality, complexity, and maintainability analysis | | security-analyzer | General security vulnerability detection | | vulnerability-scanner | Known vulnerability and dependency scanning | | cryptographic-analyzer | Cryptographic implementation analysis | | secret-detector | Sensitive data and credential detection | | gdpr-compliance-analyzer | GDPR and privacy compliance checking |

Output Formats

JSON (Default)

code-analyzer analyze . --format json --output report.json

HTML Report

code-analyzer analyze . --format html --output report.html

Markdown

code-analyzer analyze . --format markdown --output report.md

SARIF (Static Analysis Results Interchange Format)

code-analyzer analyze . --format sarif --output report.sarif

Quality Metrics

The analyzer provides comprehensive metrics including:

  • Cyclomatic Complexity - Measure of code complexity
  • Cognitive Complexity - Human-perceived complexity
  • Maintainability Index - Overall maintainability score
  • Technical Debt - Estimated time to fix issues
  • Code Coverage - Test coverage analysis
  • Duplication Percentage - Code duplication metrics
  • Quality Ratings - A-E ratings for different aspects

Integration

CI/CD Integration

# GitHub Actions
- name: Code Analysis
  run: |
    npm install -g @aitek/comprehensive-code-analyzer
    code-analyzer analyze . --format sarif --output results.sarif
    
- name: Upload SARIF
  uses: github/codeql-action/upload-sarif@v2
  with:
    sarif_file: results.sarif

Pre-commit Hook

{
  "husky": {
    "hooks": {
      "pre-commit": "code-analyzer analyze --analyzers quality-analyzer"
    }
  }
}

VS Code Integration

Add to your VS Code tasks:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Analyze Code Quality",
      "type": "shell",
      "command": "code-analyzer",
      "args": ["analyze", ".", "--format", "json"],
      "group": "build",
      "presentation": {
        "echo": true,
        "reveal": "always"
      }
    }
  ]
}

Custom Analyzers

Extend the analyzer with custom rules:

import { BaseAnalyzer, AnalysisResult, ParsedFile } from '@aitek/comprehensive-code-analyzer';

class CustomAnalyzer extends BaseAnalyzer {
  readonly id = 'custom-analyzer';
  readonly name = 'Custom Rules Analyzer';
  readonly description = 'Custom business logic analysis';

  async analyze(files: ParsedFile[]): Promise<AnalysisResult> {
    const issues = [];
    
    for (const file of files) {
      // Your custom analysis logic
      if (this.violatesBusinessRule(file)) {
        issues.push(this.createIssue(
          'Business Rule Violation',
          'Custom business rule violated',
          file.path,
          'Fix according to business requirements'
        ));
      }
    }
    
    return this.createAnalysisResult(issues);
  }
  
  private violatesBusinessRule(file: ParsedFile): boolean {
    // Your custom logic here
    return false;
  }
}

// Register custom analyzer
const analyzer = new ComprehensiveCodeAnalyzer();
analyzer.registerAnalyzer(new CustomAnalyzer());

API Reference

ComprehensiveCodeAnalyzer

Main analyzer class for running analysis.

Methods

  • analyze(paths: string[], options?: AnalysisOptions): Promise<AnalysisReport>
  • getAvailableAnalyzers(): string[]
  • registerAnalyzer(analyzer: Analyzer): void

AnalysisOptions

Configuration options for analysis.

interface AnalysisOptions {
  analyzers?: string[];
  filePatterns?: string[];
  format?: 'json' | 'html' | 'markdown' | 'sarif';
  outputPath?: string;
  includeMetrics?: boolean;
  includeSuggestions?: boolean;
}

AnalysisReport

Analysis results structure.

interface AnalysisReport {
  summary: {
    totalFiles: number;
    totalIssues: number;
    criticalIssues: number;
    highIssues: number;
    mediumIssues: number;
    lowIssues: number;
    technicalDebt: number;
    qualityRating: 'A' | 'B' | 'C' | 'D' | 'E';
  };
  results: AnalysisResult[];
  metrics?: Record<string, any>;
  timestamp: string;
  version: string;
}

Examples

Basic Quality Analysis

# Analyze TypeScript project
code-analyzer analyze src/ --analyzers quality-analyzer

# Generate detailed HTML report
code-analyzer analyze . --format html --output quality-report.html

Security Focused Analysis

# Run security analyzers only
code-analyzer analyze . --analyzers security-analyzer,vulnerability-scanner,secret-detector

# SARIF output for security tools
code-analyzer analyze . --format sarif --output security.sarif

GDPR Compliance Check

# Check GDPR compliance
code-analyzer analyze . --analyzers gdpr-compliance-analyzer --format markdown --output gdpr-report.md

CI/CD Pipeline

# Fail build on high-priority issues
code-analyzer analyze . --analyzers quality-analyzer,security-analyzer || exit 1

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support


Made with ❤️ by the Aitek Development Team