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

branch-never

v0.3.0

Published

[![npm](https://img.shields.io/npm/v/branch-never)](https://www.npmjs.com/package/branch-never) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Downloads

42

Readme

npm License: MIT

branch-never

branch-never is a static-analysis CLI for TypeScript and JavaScript projects. It scans source files for high-value conditional branches and flags the ones whose key tokens never appear in any test file.

It is intentionally heuristic-based: no runtime instrumentation, no AST parser, and no execution. The goal is to quickly surface risky branches that look untested.

Install

pnpm add -D branch-never

Or run it locally in this repository:

pnpm install
pnpm build
node dist/index.js src --tests test

Usage

branch-never <src-dir> [options]

Options:
  --tests <dir>     Test directory (default: test/)
  --json            JSON output
  --no-fail         Don't exit 1 when uncovered branches found
  --pattern <type>  Only check: env|retry|error|feature|all (default: all)
  --threshold <pct> Fail if coverage below N% (default: 0, fail on any)
  --report <file>   Write an HTML report
  --baseline <ref>  Compare current uncovered branches against a git ref
  --blame           Show git blame metadata for each unreachable branch
  --pr-check        Compare current unreachable branches against a baseline JSON file

Example output:

Analyzing import graph and branches...

Uncovered branches (never referenced in any test):
  src/api.ts:42    if (process.env.NODE_ENV === 'production')  <- env branch, no test

Covered branches:
  src/auth.ts:15   if (!token)  <- referenced in test/auth.test.ts

Summary: 1 uncovered branches, 1 covered. Coverage: 50%

HTML report:

branch-never src --tests test --report report.html

Baseline comparison:

branch-never src --tests test --baseline main

Blame mode:

branch-never src --tests test --blame

PR check mode:

branch-never src --tests test --json --no-fail > .branch-never-baseline.json
branch-never src --tests test --pr-check --baseline .branch-never-baseline.json

GitHub Actions:

- run: pnpm build
- run: pnpm test
- run: node dist/index.js src --tests test --pr-check --baseline .branch-never-baseline.json

What It Detects

The extractor looks for these branch shapes using regex:

  • if (...)
  • catch (...) { ... } blocks with error property checks
  • Ternary conditions like condition ? a : b
  • Short-circuit expressions like a && b or a || b when they include env/config checks

It only reports branches whose condition matches one of these interesting patterns:

  • process.env.* and NODE_ENV === "..." checks
  • Retry and timeout logic such as retries > 3, attempts >= 2, timeout
  • Error type/status/code checks such as err.code === "EXPIRED"
  • Feature flags such as feature.someFlag

Coverage is approximated by extracting tokens from each condition and checking whether any test file contains them.

Compared To Istanbul or c8

branch-never is not a replacement for Istanbul or c8.

  • branch-never is static and heuristic-based, so it can run without executing tests.
  • Istanbul and c8 are runtime coverage tools, so they produce precise statement and branch coverage from real execution.
  • branch-never is useful when you want a fast signal about suspicious branches before full runtime coverage is available.

The tradeoff is precision: runtime coverage is more accurate, while branch-never is faster to adopt and easier to run in lightweight environments.