Skip to content
Fallow home
All docs pages

Docs home

Health issue types

Learn what each finding and metric of fallow health means, and what to do about it.

The output of fallow health has a number next to each function and each file, and a link below each section. You probably followed one of these links, and you want to know what the number means and what to do now. Each section on this page answers that for one metric or one finding. A section for an issue type links to its rule page, with an example, the fix and the facts.

To learn how fallow measures complexity and risk, read Health.

Complexity metrics

In the demo project, fallow health reports one function:

● High complexity functions (1)
  src/services/customers.ts
    :9 classifyCustomer CRITICAL
          23 ! cyclomatic   32 ! cognitive   39 lines
         552.0 ! CRAP

Fallow measures each function, and the template of a component, with two numbers: the cyclomatic complexity and the cognitive complexity. A function above a limit is a finding, and ! marks each limit that it passes. A function above both limits, such as classifyCustomer, gets the High complexity issue type. Test such a function first, then make it easier to read.

Cyclomatic complexity

The cyclomatic complexity is the number of paths through a function: 1, plus 1 for each if, loop, case, catch, ?:, &&, ||, ?? and ?.. Each path needs its own test, so classifyCustomer has 23 paths to test. Fallow reports a function above 20 by default. Remove branches, for example with a lookup table or one branch for cases that repeat.

Full reference: High cyclomatic complexity

Cognitive complexity

The cognitive complexity estimates how hard a function is to read. Nested code counts more than flat code. classifyCustomer has if blocks inside a loop inside an if, so it gets 32, more than its 23 paths. Fallow reports a function above 15 by default. Flatten the nesting with early returns, or give a long condition a name. Do not move a block to a helper only to pass the limit: a helper with one caller that takes many variables of that caller is harder to read than the original.

Full reference: High cognitive complexity

Cleared findings

A split into helper functions always lowers the score of a function. The score does not show if the code became simpler or if more functions hold the same code. fallow audit compares the base and the head of a change, so it can report two facts for each complexity finding that the change cleared.

FactMeaning
expanded_cognitiveThe cognitive complexity of the function with its single-use helpers and its inline callbacks read inline, on the base (previous) and on the head (current). A helper is single-use when it is in the same file, the file calls its name one time and has no other reference to its name, its declaration has no export keyword, and it is not on a call cycle. Code in a helper gets the nesting depth of the call site.
new_helpersEach function that the function reaches on the head and that is new in the file: its call_sites, its parameters, read_inline (the total reads it inline), and three coupling facts. writes_to_argument is true when the helper changes a parameter. writes_to_outer_binding is true when it changes a variable that it does not declare. status_code_return is true when it returns two or more different string or number literals.

Two flags summarize the facts. flat_total is true when the head total is 90% or more of the base total. coupled_helper is true when a new helper has 4 or more parameters or one of the three coupling facts. The output publishes both thresholds as flat_total_percent and coupled_helper_parameters.

The human output shows one line for each cleared finding that has a new helper and one of the two flags:

src/parse.ts:1 parse  cognitive 59 -> 12; 59 -> 60 counted with its 6 single-use helpers; 3 new helpers take 4 or more parameters (readHeader, readBody, readTail)

Neither fact is a finding. In a test with 101 cleared findings from open-source projects, one of the two flags was true for 16 of the 17 refactors that three blind model reviewers all rejected. It was also true for 12 of the 26 refactors with the best scores. A parser that becomes two passes keeps its total, and that is a good change. The facts do not change the verdict or the exit code, and SARIF and CodeClimate do not hold them. Use them to decide where to look.

The comparison has these limits:

  • It reads one file. A helper in another file is not read inline.
  • It matches names as text. A function that shares its name with another function of the file is not in the functions list. not_compared counts such functions.
  • The cognitive numbers do not include the prop count and the hook count of a React component, so they can be lower than the score of the finding.

Function names

A finding names the function by its declaration or by its variable, for example load for const load = () => {}. An anonymous export default is default. A callback gets a name from the call around it when that call has a string as first argument:

CodeFinding name
Effect.fn("Users.create")(function* () {...})Users.create
Command.make("setup", {...}, (args) => ...)Command.make("setup")
api.group().handle("github", (req) => ...)handle("github")
it("renders the empty state", () => ...)it("renders the empty state")
const load = (id) => Effect.gen(function* () {...})load, for the arrow and for the generator

Fallow keeps the first 40 characters of a long string. A generator takes the name of the function that returns it, also through .pipe(...). Other callbacks are <anonymous> or <arrow>: use the path and the line of the finding to find them. The name does not change the score or the coverage match.

In Effect code, the combinators are calls, so they add nothing: pipe(...), Effect.catchTag(...), Effect.if(...), Match.when(...), and yield* in Effect.gen. Each callback is its own unit, and its nesting starts at zero.

Templates and components

A component template is a unit of its own, with the name <template>. For an Angular component, fallow reads an external templateUrl file and an inline @Component({ template }) literal. When a class method of the component has a finding, fallow also adds a <component> finding. Its values are the values of the worst class method plus the values of the template. The ranking and --targets use these totals, and component_rollup has the class part and the template part.

  • Fix a <template> finding with child components, or move derived data to the class as computed signals.
  • Fix the larger part of a <component> finding first.
  • A template file gets its CRAP estimate from its component class: coverage_source is estimated_component_inherited, and inherited_from names the class file. Add tests to the class.
  • To hide an inline template and the <component> finding, put // fallow-ignore-next-line complexity above the decorator or above the worst class method. To hide an external template, put <!-- fallow-ignore-file complexity --> at the top of the template.

Full reference: High complexity

Unit size

The unit size is the length of a function in lines of code. When many functions are longer than 60 lines, the report lists them under "Large functions". Split each long function. To change the limit of 60 lines, set health.maxUnitSize.

File length

The file has more lines than the limit that you set in health.maxFileLines. Each line counts, also blank lines and comments. The check is off until you set a limit. Move groups of exports to their own files.

Full reference: Long file

File health scores

The complexity metrics rate one function. A file can be hard to change for other reasons too, for example many imports or many unused exports. fallow health --file-scores gives each file a score and its measurements. The measurements are the lines, the fan-in (the files that import it), fan-out (the files that it imports), the share of unused exports and the complexity density. Fallow sorts the files with the most concern first, so start with the files at the top. Fallow leaves out files without functions, such as barrel files.

Maintainability index

The maintainability index (MI) is a number from 0 to 100 for one file. It goes down with more complexity for each line, more unused exports and more imports. Higher is better. In the demo project, src/utils/legacy-currency.ts has the MI 78.8, lower than most files, because each of its exports is unused. The health score counts a file below 70 as low. The formula is different from the index of other tools, so do not compare the numbers. The MI formula gives each coefficient.

Untested complexity risk

Complexity tells you how hard a function is. It does not tell you if tests protect the function, and complex code without tests is the most likely place for a bug. So fallow combines the complexity of each function with its test coverage. Without coverage data, fallow estimates the coverage from the imports of the test files, and the report says so in a hint line:

  No coverage file found, so CRAP scores are a static estimate. Pass `--coverage <coverage-final.json>` for measured scores, or raise `health.maxCrap`.

This line is not an error. Give fallow real coverage data with --coverage for exact scores.

CRAP score

CRAP combines the cyclomatic complexity of a function with its test coverage. A complex function without tests gets a high score: classifyCustomer has 23 paths and no test, so its estimate is 552.0. Fallow reports a score of 30 or more by default. Add tests for the function first, then make it simpler. CRAP gives the formula and the action of each case, and Severity bands gives the bands.

Full reference: High CRAP score

Coverage gaps

A coverage gap asks a simpler question than CRAP: does any test import the code at all? A coverage gap is production code that no test imports, directly or through other files. fallow health --coverage-gaps reports a file as Untested file and an export as Untested export. A gap is not line coverage: a test can import a file and still skip most of its code. Add a test that imports the code, or check that fallow finds your test files.

An app that exists only for end-to-end tests is not production code. When a Playwright webServer command starts a server in a folder below the config, such as cd ./app && pnpm run dev, fallow does not report the files that only that app reaches. The folder must have its own package.json. A folder that your workspace patterns declare stays production code, and so does an entry that you list in entry.

Runtime coverage

Test coverage shows the code that your tests run. Runtime coverage adds data about the functions that ran in production. Each function gets a verdict, for example "safe to delete" for a function that is unused and never ran. A function that never ran can still run at another time of year, or only on an error path. Check those cases before you delete code.

Full reference: Runtime coverage, Safe to delete, Review required, Low traffic, Coverage unavailable

Evidence fields

Each entry of runtime_coverage.findings has an evidence object with the facts behind its verdict:

FieldValues
static_statusused: the module graph reaches the function. unused: static analysis finds it unused.
test_coveragecovered: the local tests run the function. Else not_covered.
v8_trackingtracked: V8 saw the function in the capture window. Else untracked.
test_only_referencetrue: the production graph does not reach the function, but a test, spec, story, fixture or benchmark file uses it. The verdict is then never safe_to_delete. false: fallow compared both graphs and found no such use. Absent when the run had no production filter.

Coverage intelligence

Coverage intelligence combines runtime coverage with the static analysis, the tests, the CRAP score, the owners and the changed files. It gives one recommendation for a function: delete, review with an owner, refactor with care, or add tests before a risky change. Follow the rule page of the recommendation.

Hotspot metrics

A complex file costs you time only when you change it, so the metrics above need the change history too. A hotspot is a file that is complex and changes often. fallow health --hotspots reads the git history to find them. Recent commits count more than old commits. The score is relative to your project: the worst file of a clean project can still have a high score. Refactor the top hotspots first, because a fix there helps most. Hotspots gives the formula, the trend rules and the fields.

Ownership markers

With --ownership, the human output adds a summary line above the hotspots, for example 9/10 hotspots depend on a single recent contributor · top authors: alice (6), bob (4). Each hotspot row has a bus= marker:

  • Red and bold, when the top contributor has 90 percent or more of the weighted commits, or when the bus factor is 1 and the trend is Accelerating. The marker then says (sole author) for a share of 100 percent, else (at risk).
  • Yellow, for a bus factor of 1 in other cases.
  • Dimmed, for a bus factor of 2 or more.

Test paths

Hotspots keep test files in the ranking, because the work on tests is real work. The human output tags them [test], and the JSON output has is_test_path: true. A path is a test path when one of these is true:

  • A directory of the path is test, tests, __tests__, __test__, e2e, test-d, __mocks__, __fixtures__, fixtures or __snapshots__.
  • A directory is spec or specs at a test root: the project root, a package root, or a directory next to a src or lib directory.
  • The file name has .test., .test-d., .spec., .e2e., .e2e-spec. or .fixture..
  • The file name has .cy., and the file is a script below a cypress directory, or below a directory that holds a Cypress config or a cypress directory.

The match ignores ASCII case. fallow audit and fallow similar-code inspect use the same definition.

Change coupling

Two files often change in the same commits, and no import connects them. Fallow reports a pair when the two files share at least 5 commits, and the shared commits are at least 30 percent of the mean commit count of the two files. A person who follows the imports does not find the second file. Make the dependency visible with an import, or move the shared logic to one file. Ignore a pair when it is a coincidence of the history. This section never fails a run. Change coupling gives the window and the fields.

Change dispersion

Each hotspot shows how far a change to the file usually spreads: the median number of files, and of lines, in the commits that change the file. A high number means that a change to this file usually needs changes in many other files.

Shallow directories

A directory is a module: files outside it use its interface items, and it keeps the rest inside. A deep directory hides much code behind a small interface. A shallow directory shows almost all that it has, so each caller must learn many names and gets little in return. fallow health --shallow-directories reports a directory when files outside it use at least as many of its interface items as it keeps inside, and it shows at least health.shallowDirectories.minInterface items (default 8).

An interface item is a module-scope function or an exported class with a method. Types, constants, enums and UI components are no items, because a wide set of them is usually on purpose. An export that a package entry re-exports is public API, so it is no item either. Only runtime imports from files that are not tests or stories count as use. A barrel index file is the face of its directory: a caller that imports through it counts for the file that declares the item.

Some directories pass the counts but do not act as one module. Fallow does not report them, and their parent directory counts their items:

  • a catalog, where the shown items come about one per file (one hook, model or task per file), or all from one file;
  • a family, where at least 30 percent of the shown functions have one parameter list, for example a set of editor commands;
  • low reuse, where the shown items have fewer than 2 outside users on average.

A reported directory claims its items, so one wide child does not make each of its parents shallow too.

The signal finds junk-drawer utils, lib and shared directories best. A cohesive set of same-role functions with different parameter lists, such as an i18n helper set, can still report: in a check on public projects, about half of the findings were real. Move the logic behind fewer items, split the directory by the concern of its callers, or merge a helper into its only caller. To keep the interface narrow after the fix, see Keep a module deep. When the width is on purpose, add the directory to health.shallowDirectories.ignore. Fields lists the JSON fields.

Fields

FieldDescription
min_interfaceThe health.shallowDirectories.minInterface value of the run.
totalThe shallow directories before --top.
directories[].pathThe directory, relative to the project root.
directories[].anchor_fileThe index file of the directory, else its first source file. SARIF and CodeClimate report the finding on this file.
directories[].shown_count, shown_filesThe interface items that files outside the directory use, and the files of the directory that declare them.
directories[].hidden_countThe functions and classes that no outside file uses.
directories[].itemsAt most 7 shown items, the most used first: name, path, line, kind (function or class), outside_files, and members for a class. is_default marks a default export.
directories[].more_itemsThe shown items that items leaves out.
directories[].actionsnarrow-interface, and ignore-directory. Add its value, an escaped glob of the directory, to its config_key list (health.shallowDirectories.ignore) to hide the directory.

SARIF has the rule fallow/shallow-directory at level note. CodeClimate has the check fallow/shallow-directory at severity info. Both fingerprints read the directory, so a new anchor file keeps them. The markdown format adds a Shallow Directories table, and the compact format has one line for each directory:

shallow-directory:src/utils/index.ts:dir=src/utils,shown=8,hidden=2,files=2

Full reference: Shallow directory

Refactoring targets

fallow health --targets gives a list of files to refactor, with the reason, the expected effort and the confidence. The quick wins come first. Start at the top of the list, and act on the evidence of each target, for example the unused exports or the complex functions that it names. Refactoring targets gives the priority formula and the rule of each category.

Full reference: Refactoring target

Styling findings

With --css, fallow health also checks stylesheets and CSS-in-JS. Styling explains this analysis. These findings are warnings by default.

Token drift

A styling value does not use the design tokens of the project, for example a Tailwind arbitrary value or a color near a token. Use the existing token when it is correct.

Full reference: CSS token drift

Duplicate declaration block

The same block of declarations is in two or more rules. Merge the copies into one rule.

Full reference: CSS duplicate block

Selector complexity

A rule uses an id selector, deep nesting, !important, or a complex selector. Make the selector simpler when you can.

Full reference: CSS selector complexity

Dead surface

A class, a token, a @keyframes rule or other styling has no use in the project. Make sure that no dynamic class name uses it, then remove it.

Full reference: CSS dead surface

Broken reference

Code uses a class or an animation that no stylesheet of the project defines. Correct the name, unless an external stylesheet defines it.

Full reference: CSS broken reference

CSS analytics

With --css, the JSON output of fallow health has css_analytics, styling_findings and styling_health.

Each cleanup candidate in css_analytics is a list. A list is absent when it is empty.

FieldContent
unreferenced_css_classesA class of a plain stylesheet that no class or className of the project markup uses.
unresolved_class_referencesA class in markup that is one edit away from a defined class, probably a typo.
undefined_keyframesAn animation that names a @keyframes block that no file defines.
unused_font_facesA @font-face family that no rule uses.
unused_theme_tokensA Tailwind v4 @theme token whose utility no file uses.
token_consumersThe users of each design token. See Token consumers.
font_size_unit_mixfont-size values in more than one unit, for example px and rem.

A @theme token counts as used through its utility (bg-brand for --color-brand), a var(--token) read, an @apply body, an arbitrary value such as rounded-[--radius-card], or a reference from another @theme token. The token check runs only for a Tailwind v4 project: a tailwindcss dependency and a @theme block. It reports nothing when Tailwind plugins or published CSS can use the tokens.

A Sass or Less animation value can hold a variable, for example animation: #{$name} 1s. Such a value can name each @keyframes block of a Sass or Less source, so fallow does not report these blocks as unused. css_analytics.summary.keyframes_unchecked counts them, and the human output shows them as not checked. A @keyframes block in plain CSS is always checked.

A class prefix before a {{ expression, as in grid--\{\{ columns \}\}, uses each class that starts with grid--. Fallow reads server templates as class references. markupExtensions lists the template extensions.

Token consumers

token_consumers is a reverse index of the design tokens. Each entry has these fields:

FieldContent
tokenA Tailwind token with its -- prefix (--color-brand), or the path of a CSS-in-JS token (vars.color.primary).
namespaceThe Tailwind namespace (color), or the export binding of a CSS-in-JS token set (vars).
definition_path, definition_lineThe place of the definition.
consumer_countThe number of uses.
consumersA sample of up to 20 uses, each with path, line and kind.
kindUse
utilityA class that ends in -<name>, such as bg-brand.
applyA class in an @apply body.
css-varA var(--token) read outside @theme.
theme-varA var(--token) read in another @theme token.
js-memberA member access on a StyleX or vanilla-extract token binding, also through an import.
js-callA PandaCSS token(...) call, or a StyleX createTheme call.

CSS-in-JS entries cover StyleX defineVars, vanilla-extract createTheme, createThemeContract and createGlobalTheme, PandaCSS defineTokens, styled-components and Emotion. Fallow resolves each import to the file of the definition, so a vars binding of another module does not count.

consumer_count is a lower bound. Fallow cannot see a computed class name such as bg-${color}, an import that it cannot resolve, or computed token access. A count of 0 is a reason to investigate, not proof that you can delete the token. A run on a part of the project has no token_consumers.

Styling score

styling_health has score (0 to 100), grade, formula_version, penalties, confidence and confidence_reason. The score starts at 100, and fallow subtracts five penalties:

PenaltyMeasuresMaximum
duplicationThe removable declarations in copied declaration blocks.20
dead_surfaceThe unused @theme tokens as a share of all tokens, plus the unused classes, @property and @layer rules and @font-face families as a share of all declarations.20
broken_referencesThe unresolved class references and the undefined @keyframes.15
token_erosionMixed font-size units, Tailwind arbitrary values, and the hardcoded box-shadow, border-radius and line-height values above a small set for each property. A var(--*) value does not count.10
structural!important above a small share, and deep nesting.10

confidence is low when the score comes from few declarations, or from mostly compile-time CSS-in-JS. confidence_reason then says why, and the human output puts ~ before the score. Confidence does not change the score. The styling score never changes an exit code, a badge or the health score.

formula_version (3) is separate from the formula version of the health score. When you compare styling scores over time, compare only scores with the same formula_version.

Health score

The sections above rate functions and files. The health score is one number from 0 to 100 for the whole project. Higher is better. Fallow subtracts points for unused files and exports, complex functions, hotspots, cycles, duplication and other problems. The grade is A at 85 or more, B at 70, C at 55, D at 40 and F below 40.

The demo project gets a low score, and the first lines of the report show why:

● Health score: 61 C
  Deductions: unused deps -25.0 · duplication -10.0 · dead exports -2.9 · dead files -1.3

Fallow counts the unused dependencies for each 1,000 files, so in a small project one package can cost the maximum of 25 points. The demo project has 16 files and one unused dependency, left-pad. The JSON output lists each penalty, so you can see which problem costs the most points.