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

codeguard-cli

v1.0.0

Published

A lightweight, zero-dependency Node.js CLI tool for code cleanliness and risk analysis

Downloads

5

Readme

🔍 CodeGuard

Code Cleanliness & Risk Analysis Tool

CodeGuard is a lightweight, zero-dependency Node.js CLI tool that detects code quality issues and security risks in your projects.

✨ Features

  • 🔍 Smart Code Scanning: Finds risky code like TODO, FIXME, eval(), console.log
  • 📊 Risk Scoring: Assigns 1-10 risk scores to each issue
  • 📈 Detailed Reports: JSON, HTML, and console reports
  • 🚀 Zero Dependency: No external dependencies required
  • Fast: Quick scanning even for large projects
  • 🎯 Multi-Language Support: JavaScript, TypeScript, Python, Java, C++ and more

🚀 Installation

# Install globally
npm install -g codeguard-cli

# Or use npx
npx codeguard-cli scan

# Or clone and install locally
git clone https://github.com/erencanucarr/codeguard-cli.git
cd codeguard-cli
npm link

📖 Usage

Basic Usage

# Scan current directory
codeguard scan

# Scan specific directory
codeguard scan --path ./src

# Generate JSON report
codeguard scan --output json --file my-report

# Generate HTML report
codeguard scan --output html --file security-report

# Set minimum risk threshold
codeguard scan --risk-threshold 5

Command Options

| Option | Description | Default | |--------|-------------|---------| | -p, --path <path> | Path to scan | . (current directory) | | -o, --output <format> | Output format (json, html, console) | console | | -f, --file <filename> | Report filename | codeguard-report | | --ignore <patterns> | Ignore patterns (comma-separated) | node_modules,dist,build,.git | | --risk-threshold <number> | Minimum risk score (0-10) | 3 | | -h, --help | Show help message | - |

🎯 Risk Scores

| Score | Level | Examples | |-------|-------|----------| | 10 | 🔴 Critical | eval(), require('fs'), exec() | | 8 | 🟠 High | TODO, FIXME, any, @ts-ignore | | 6 | 🟡 Medium | console.log, debugger, alert() | | 4 | 🔵 Low | eslint-disable, prettier-ignore | | 2 | ⚪ Info | NOTE, INFO, WARNING |

📊 Detected Risks

🔴 Critical Security Risks (10 points)

  • eval() usage
  • require('fs') file system access
  • require('child_process') system commands
  • exec() usage
  • innerHTML XSS risk
  • document.write() XSS risk

🟠 High Risks (8 points)

  • // TODO - Incomplete code
  • // FIXME - Code needs fixing
  • // HACK - Temporary solution
  • // BUG - Known issue
  • any - TypeScript any usage
  • @ts-ignore - TypeScript ignore
  • password = - Password variable
  • api_key = - API key variable
  • secret = - Secret variable

🟡 Medium Risks (6 points)

  • console.log() - Should be removed in production
  • console.error() - Error logs
  • console.warn() - Warning logs
  • debugger; - Debug statement
  • alert() - User experience issue
  • confirm() - Confirmation dialogs
  • prompt() - Input dialogs

🔵 Low Risks (4 points)

  • // eslint-disable - ESLint disable
  • // @ts-nocheck - TypeScript check disable
  • // prettier-ignore - Prettier disable
  • // stylelint-disable - Stylelint disable

📁 Supported File Types

  • JavaScript: .js, .jsx
  • TypeScript: .ts, .tsx
  • Vue/Svelte: .vue, .svelte
  • Python: .py
  • Java: .java
  • C/C++: .c, .cpp
  • C#: .cs
  • PHP: .php
  • Ruby: .rb
  • Go: .go
  • Rust: .rs
  • Swift: .swift
  • Kotlin: .kt
  • Scala: .scala

📈 Sample Outputs

Console Report

📊 CodeGuard Report
Date: 2024-01-15T10:30:00.000Z
Path: ./src
Files Scanned: 25
Total Issues: 12
Risk Score: 78

📈 Summary:
  🔴 Critical: 2
  🟠 High: 5
  🟡 Medium: 3
  🔵 Low: 2
  ⚪ Info: 0

📁 File Details:

./src/utils.js (3 issues, 24 points)
  🟠 Line 15:1 - TODO comment - incomplete code
    // TODO: Optimize this function
  🟡 Line 42:1 - console.log usage - should be removed in production
    console.log('Debug info:', data);
  🔴 Line 67:1 - eval() usage - security risk
    eval(userInput);

HTML Report

The HTML report provides a modern and interactive interface:

  • 📊 Statistics cards
  • 📈 Risk summary charts
  • 📁 File-based detailed analysis
  • 🎨 Color-coded risk levels

🔧 Configuration

Git Hooks Integration

Add to .git/hooks/pre-commit:

#!/bin/sh
echo "🔍 Running CodeGuard scan..."
codeguard scan --risk-threshold 5
if [ $? -ne 0 ]; then
    echo "❌ CodeGuard found issues. Commit aborted."
    exit 1
fi
echo "✅ CodeGuard scan passed."

CI/CD Integration

GitHub Actions example:

name: CodeGuard Analysis
on: [push, pull_request]

jobs:
  codeguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install -g codeguard-cli
      - run: codeguard scan --output json --file ci-report
      - name: Upload report
        uses: actions/upload-artifact@v3
        with:
          name: codeguard-report
          path: ci-report.json

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

🙏 Acknowledgments

  • All contributors
  • Open source community
  • Projects that inspired code quality tools

Keep your code clean and secure with CodeGuard! 🚀