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

dead-code-hunter-core

v1.0.20

Published

Core analysis engine for dead code detection - JS/TS, Python, Go, Java, Ruby, Rust, PHP, C#

Readme

dead-code-hunter-core

Core analysis engine for Dead Code Hunter - the multi-language dead code detection CLI.

This package is the library used by the dch CLI. Install the CLI for the command-line experience:

npm install -g dead-code-hunter
dch scan

| Command | Description | |---------|-------------| | dch scan [dir] | Run all checks at once - dashboard summary | | dch analyze [dir] | Dead symbols - functions, classes, variables | | dch files [dir] | Source files never imported by anything | | dch deps [dir] | Packages in manifests never imported in code | | dch todos [dir] | Stale TODO / FIXME / HACK comments with git age | | dch dupes [dir] | Duplicate or near-identical function bodies | | dch unreachable [dir] | Code after return/throw that can never execute | | dch catches [dir] | Empty catch blocks and swallowed errors | | dch config [dir] | .env / config.json keys never used in source | | dch console [dir] | Debug console.log / print / fmt.Println statements | | dch complexity [dir] | Functions with high cyclomatic complexity | | dch circular [dir] | Circular import chains between files | | dch secrets [dir] | Hardcoded API keys, passwords, and tokens | | dch fix [dir] | Interactively delete or suppress dead symbols | | dch watch [dir] | Re-analyze automatically on every file save | | dch baseline save/diff/check | Snapshot dead code and fail CI only on new issues | | dch init | Generate a .dchrc.json config file |

Install this package directly only if you want to embed the analyzer in your own tooling.

npm install dead-code-hunter-core

API

import {
  analyze,
  analyzeFiles,
  analyzeDeps,
  analyzeTodos,
  analyzeDupes,
  analyzeUnreachable,
  analyzeCatches,
  analyzeConfigKeys,
  analyzeConsole,
  analyzeComplexity,
  analyzeCircular,
  analyzeSecrets,
  saveBaseline,
  loadBaseline,
  diffFromBaseline,
} from 'dead-code-hunter-core';

// Dead symbols
const result = await analyze('/path/to/project');
console.log(result.deadSymbols);        // DeadSymbol[]
console.log(result.detectedLanguages);  // LanguageStats[]

// Unused files
const files = await analyzeFiles('/path/to/project');
console.log(files.unusedFiles);         // UnusedFile[]
console.log(files.totalBytes);          // number

// Unused dependencies
const deps = await analyzeDeps('/path/to/project');
console.log(deps.deadDependencies);     // DeadDependency[]

// Stale comments
const todos = await analyzeTodos('/path/to/project');
console.log(todos.todos);              // TodoItem[] (with author, issueRef, daysSince)

// Duplicate code
const dupes = await analyzeDupes('/path/to/project', 6);
console.log(dupes.duplicateGroups);    // DuplicateGroup[] (with snippet, suggestedLocation)

// Unreachable code
const unreachable = await analyzeUnreachable('/path/to/project');
console.log(unreachable.unreachableCode); // UnreachableCode[]

// Error handling issues
const catches = await analyzeCatches('/path/to/project');
console.log(catches.emptyCatches);     // EmptyCatch[] (with kind, severity, suggestion)

// Unused config keys
const config = await analyzeConfigKeys('/path/to/project');
console.log(config.deadKeys);          // DeadConfigKey[]

// Debug statements
const debug = await analyzeConsole('/path/to/project', true); // skipTests = true
console.log(debug.statements);         // ConsoleStatement[]

// Cyclomatic complexity
const complexity = await analyzeComplexity('/path/to/project', 5); // threshold = 5
console.log(complexity.functions);     // FunctionComplexity[] (with risk level)

// Circular imports
const circular = await analyzeCircular('/path/to/project');
console.log(circular.cycles);          // CircularCycle[]

// Hardcoded secrets
const secrets = await analyzeSecrets('/path/to/project');
console.log(secrets.findings);         // SecretFinding[] (values redacted)

// Baseline mode
saveBaseline(result, '.dch-baseline.json');
const baseline = loadBaseline('.dch-baseline.json');
const newDead = diffFromBaseline(result, baseline!);

Reports

import { consoleReport, jsonReport, htmlReport, sarifReport } from 'dead-code-hunter-core';

const text = consoleReport(result, rootDir);
const json = jsonReport(result);
const html = htmlReport(result, rootDir);
const sarif = sarifReport(result);

Links