Skip to content
Fallow home
All docs pages

Docs home

First run

Run npx fallow on a small demo project and read each part of the report.

You want to know what fallow finds in a JavaScript or TypeScript project. Run one command, and in a few seconds you get a report in three parts: dead code, duplication and complexity. This page reads each part with you, on a small demo project with 16 files, so your output is the same as the output on this page.

Before you start

  • You need Git, and Node.js 22 or later for npx. Installation lists the other ways to get fallow.
  • Get the demo project and install its dependencies. Fallow reads the packages in node_modules. Without them, it can report an import or a dependency wrongly.
git clone https://github.com/fallow-rs/fallow-demo.git
cd fallow-demo
npm install

Run fallow

In the root of the demo project, run the three analyses of fallow (dead code, duplication and health) with one command:

npx fallow

To run only some of the analyses, use --only or --skip, as the fallow command shows.

Fallow needs no config file for this run. It reads the package.json, turns on a plugin for each framework and tool that the project uses, and analyzes each source file. It prints a header first, and then one part for each analysis.

Read the header

■ Metrics: dead files 6.3% (1 of 16) · dead exports 14.3% (3 of 21) · MI 92.8 (good)
  16 files analyzed
  3 entry points detected (2 package.json, 1 plugin)
  1 refactoring target: start with src/services/customers.ts (complexity)

The first line gives the share of dead files and dead exports, and the maintainability index (MI) from 0 to 100, where higher is better. The last line names the file to refactor first, and the complexity part below says why.

Read the third line before all others. An entry point is a file that something outside your source code runs, for example the start of your app or a test. In the demo, package.json names two of them, and the Vitest plugin adds the test file. Fallow follows the imports from each entry point, and a file that no import path reaches is unused (the graph of the demo shows this walk). The dead code part of the report is only as good as this line. If fallow prints No entry points detected, stop here and tell fallow where your code starts.

Read the dead code part

── Dead Code ──────────────────────────────────────

● Unused files (1)
  src/utils/legacy-currency.ts

● Unused exports (3)
  src/lib/format.ts
    :3 formatPercent
  src/lib/index.ts
    :1 formatPercent (re-export)
  src/services/orders.ts
    :18 cancelOrder

── Dependencies ─────────────────────────────────────

● Unused dependencies (1)
  left-pad

● Unlisted dependencies (1)
  uuid

✗ 1 file · 3 exports · 1 unused dependency · 1 unlisted dependency (0.18s)

Each group holds the findings of one issue type. A finding in a file gives the path, the line and the name. A dependency finding gives the package name.

FindingMeaningUsual fix
Unused fileNo entry point reaches the file.Delete the file.
Unused exportThe file is in use, but no file imports this name.Remove the export keyword, or delete the code.
Unused dependencypackage.json lists the package, but no file imports it.Remove it from package.json.
Unlisted dependencyA file imports the package, but package.json does not list it.Add it to package.json.

Why does formatPercent appear twice? Line 3 of format.ts defines the function. src/lib/index.ts is a barrel file: it exports names from other files again, so that other files can import them from ./lib:

// src/lib/index.ts
export { formatPrice, formatPercent } from "./format";
export { parseAmount } from "./parse";

The (re-export) marker means that no file imports formatPercent through the barrel file. Here format.ts is in the list too, so delete both lines; when only the barrel line shows, delete only that line. When two files of your project import each other, this part also gets an Architecture group with the circular dependency.

Read the duplication part

Dead code is code that nothing uses. The next part finds code that exists twice:

● Duplicates (1 clone group)

     17 lines  2 instances  spread 2  dup:f42424e8
    src/reports/export.ts:3-19
    src/utils/summary.ts:7-23

⚠ 34 lines (20.0%) duplicated across 2 files (0.02s)

A clone group is one block of code that exists in two or more places. This group has 17 lines in two files, and dup:f42424e8 is its handle: you give it to other commands to inspect the group. The last line counts each copy, so 2 times 17 lines is 34 lines. The percentage is the share of the code that fallow compared, and by default fallow does not compare test files such as *.test.ts.

Read the complexity part

The last part does not look for extra code. It looks for functions that are hard to change safely:

● High complexity functions (1)
  No coverage file found, so CRAP scores are a static estimate. Pass `--coverage <coverage-final.json>` for measured scores, or raise `health.maxCrap`.
  src/services/customers.ts
    :9 classifyCustomer CRITICAL
          23 ! cyclomatic   32 ! cognitive   39 lines
         552.0 ! CRAP

The ! marks each number that is above its limit. cyclomatic counts the paths through the function, and cognitive estimates how hard it is to read, where nested code counts more. CRAP combines the complexity with the test coverage, so a complex function without tests gets a high number.

The line under the heading is a hint, not an error. Fallow has no coverage file of your tests, so it estimates the coverage from the exports that your tests import. No test reaches classifyCustomer, so its estimated coverage is 0 and its CRAP score is 552. Health and complexity shows how to give fallow real coverage.

Read the result

Failed: dead-code (6 issues), dupes (1 clone group), health (1 above threshold): start with src/services/customers.ts
Setup: `npx fallow init` writes a config; `npx fallow agent install --dry-run` previews the agent guide, skills, MCP server, and commit gate (hide this hint: `npx fallow init --decline`).

The Failed: line names each part that has findings, and the file to start with. The Setup: line shows while the project has no config file.

The run exits with code 1, because some findings have the severity error. Clone groups alone do not fail the run, although the Failed: line names them. Findings, rules and gates explains which findings fail a run.

What you learned

  • One npx fallow gives three parts: dead code (with dependencies and cycles), duplication and complexity.
  • Check the entry points first, because the dead code part depends on them.
  • A clone group has a handle, and a complex function has a CRAP score that needs coverage to be exact.
  • The exit code is 1 when a finding fails the run.

Next

Act on one finding of each kind in the same demo project: Fix your first findings. To see your own code, run npm install and npx fallow in the root of your project.