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

cod-stat

v1.2.1

Published

CLI tool to count lines of code, comments, and categorize by language.

Readme

Cod Stat

cod-stat is a powerful, configurable command-line tool for analyzing source code. It helps developers measure code quality, structure, complexity, and productivity across multiple programming languages and file types. Perfect for personal projects, team projects, or CI/CD pipelines.


🔹 Features

  • Line Counting: Total lines, code lines, blank lines, and comment lines.
  • Function Analysis: Count functions/methods and calculate average function length.
  • Complexity Estimation: Rough complexity scoring using common keywords.
  • Language Detection: Supports multiple languages and config file types.
  • File Type Filtering: Scan only code files (--only-code) or config files (--only-config).
  • Largest Files: Identify the top N largest files by code lines.
  • Progress Feedback: Interactive progress bar for large projects.
  • Output Options: Pretty table or JSON output (--json).
  • Colored CLI Interface: Easy-to-read, visually structured outputs.
  • Customizable: Ignore directories, filter by language, and more.

🔹 Installation

# Clone repository
git clone https://github.com/Eyob-smax/cod-stat.git
cd cod-stat

# Install dependencies
npm install

# Optional: Make CLI available globally
npm link

Basic scan in current directory

cod-stat .

Scan and count comment lines

cod-stat . -c

Count functions/methods

cod-stat . -f

Show average function length

cod-stat . -a

Filter by specific language extensions

cod-stat . -l js ts py

Only scan code files

cod-stat . --only-code

Only scan config/markup files

cod-stat . --only-config

Show top 10 largest files by code lines

cod-stat . --largest 10

Save results in JSON

cod-stat . --json

Ignore directories

cod-stat . --ignore node_modules dist

| Option | Alias | Description | | -------------------------------- | ----- | -------------------------------------- | | [directory] | - | Directory to scan (default: .) | | -c, --count-comments | - | Count comment lines | | -f, --function-count | - | Count number of functions/methods | | -a, --avg-func-length | - | Show average function length in lines | | -l, --language <extensions...> | - | Only scan certain languages/extensions | | --ignore <dirs...> | - | Directories to ignore | | --only-code | - | Only scan code files | | --only-config | - | Only scan config/markup files | | --largest <n> | - | Show top N largest files (default: 5) | | --json | - | Output JSON to cod-stat/report.json |

🔍 Supported Languages & File Types Code Files

Extensions: js, ts, jsx, tsx, py, java, cpp, c, cs, rb, php, go, rs, kt, swift, dart, sh Languages: JavaScript, TypeScript, Python, Java, C++, C, C#, Ruby, PHP, Go, Rust, Kotlin, Swift, Dart, Shell

Config/Markup Files

Extensions: env, toml, ini, yml, yaml, json, xml, plist, gradle, makefile Types: Environment files, TOML, INI, YAML, JSON, XML, Property Lists, Gradle, Makefiles

Note: Language detection is based on file extensions or basenames using a languageMap. Files with unknown extensions are labeled as "Unknown".

┌─────────┬─────────────────────────┬───────────┬───────┬────────┬────────────┬──────────┐ │ (index) │ File │ Lang │ Lines │ Blanks │ Comments │ Code Lines │ Density │ ├─────────┼─────────────────────────┼───────────┼───────┼────────┼────────────┼──────────┤ │ 0 │ src/index.js │ JavaScript│ 100 │ 10 │ 20 │ 70 │ 70.0% │ │ 1 │ src/utils/helpers.ts │ TypeScript│ 50 │ 5 │ 5 │ 40 │ 80.0% │ └─────────┴─────────────────────────┴───────────┴───────┴────────┴────────────┴──────────┴──────────┘

=== Summary === Total Lines: 150 Total Blanks: 15 Total Code Lines: 110 Total Comments: 25 Average Density: 75.0%