Skip to content
Fallow home
All docs pages

Docs home

fallow health

Find the options, gates, output fields, file formats and exit codes of fallow health, which measures complexity, hotspots and the health score.

fallow health reports the functions above the complexity thresholds, the health of each file, the hotspots, the refactoring targets and the health score.

For the concepts and the workflow, read Health.

Synopsis

fallow health [OPTIONS] [PATH]

Options

ArgumentDescription
[PATH]Scope reported findings to this file or directory (default: whole project). The full project graph is still built; only reported items are narrowed

Detection

OptionDescription
--max-cyclomatic <MAX_CYCLOMATIC>Maximum cyclomatic complexity threshold (overrides config)
--max-cognitive <MAX_COGNITIVE>Maximum cognitive complexity threshold (overrides config)
--max-crap <MAX_CRAP>Maximum CRAP score threshold (overrides config, default 30.0). Functions meeting or exceeding this score are reported alongside complexity findings.
--max-file-lines <LINES>Maximum physical lines per file (overrides config health.maxFileLines, default 0 = off). A longer file is reported as a complexity finding with exceeded: "file_lines"
--since <DURATION>Git history window for hotspot analysis (default: 6m). Accepts durations (6m, 90d, 1y, 2w) or ISO dates (2025-06-01)
--min-commits <N>Minimum number of commits for a file to be included in hotspot ranking (default: 3)

Sections

OptionDescription
--complexityShow only complexity findings (functions exceeding thresholds). By default all sections are shown; use this to select only complexity
--file-scoresShow only per-file health scores (fan-in, fan-out, dead code ratio, maintainability index). Requires full analysis pipeline (graph + dead code detection).
--coverage-gapsShow only static test coverage gaps: runtime files and exports with no dependency path from any discovered test root. Requires full analysis pipeline
--shallow-directoriesShow only shallow directories: directories whose interface is as large as what they hide. Advisory, no health score weight.
--hotspotsShow only hotspots: files that are both complex and frequently changing. Combines git churn history with complexity data.
--ownershipAttach ownership signals to hotspot entries: bus factor, contributor count, declared CODEOWNERS owner, and ownership drift. Implies --hotspots.
--ownership-emails <MODE>Privacy mode for author emails emitted with --ownership. Defaults to handle (local-part only). Values: raw, handle, anonymized.
--targetsShow only refactoring targets: ranked recommendations based on complexity, coupling, churn, and dead code signals. Requires full analysis pipeline
--type-couplingShow advisory project-local public-signature type coupling. Requires type-aware analysis and does not change the health score
--cssAdd structural CSS analytics: specificity hotspots, !important density, over-complex selectors, deep nesting, and conservative cleanup candidates. Standard CSS is parsed structurally; preprocessor sources are scanned only where fallow can avoid expanding Sass/Less semantics
--effort <EFFORT>Filter refactoring targets by effort level (low, medium, high). Implies --targets
--scoreShow only the project health score (0–100) with letter grade (A/B/C/D/F). The score is included by default when no section flags are set
--trendCompare current metrics against the most recent saved snapshot. Reads from .fallow/snapshots/ and shows per-metric deltas with directional indicators.
--trend-from <PATH>Compare current metrics against this snapshot file instead of the newest file in .fallow/snapshots/. Use it to restore a baseline from external storage in CI.

Output

OptionDefaultDescription
--complexity-breakdownInclude the per-decision-point complexity breakdown (contributions[]) on each complexity finding in --format json output. Each entry names the construct (if, else-if, loop, boolean operator, ...) and its cyclomatic/cognitive weight, so a consumer can explain WHY a function scored high. Off by default to keep CI/default output lean
--top <TOP>Show only the N most complex functions
--sort <SORT>cyclomaticSort by: cyclomatic (default), cognitive, lines, or severity
--save-snapshot <PATH>Save a vital signs snapshot for trend tracking. Defaults to .fallow/snapshots/{timestamp}.json if no path is given, with a -2, -3 suffix when a snapshot of the same second exists.

Gates

OptionDescription
--min-score <N>Fail if the health score is below this threshold (0-100). Implies --score.
--min-severity <LEVEL>Only exit with error for findings at or above this severity. Use --min-severity critical to ignore moderate/high findings in CI.
--report-onlyPrint the score and findings but never fail CI (always exit 0). Advisory mode for surfacing health in logs without blocking.

Coverage

OptionDefaultDescription
--coverage <PATH>Path to coverage data for measured per-function CRAP scores. Accepts an Istanbul coverage map JSON file (coverage-final.json, from jest --coverage, vitest run --coverage, c8 or nyc), a directory containing coverage-final.json, a raw V8 coverage directory (NODE_V8_COVERAGE=<dir> node --test), or a single V8 coverage JSON file.
--coverage-root <PATH>Absolute prefix to strip from file paths in coverage data before prepending the project root. Use when coverage was generated in a different environment (CI runner, Docker).
--runtime-coverage <PATH>File or directory containing runtime coverage input. Accepts a V8 coverage directory, a single V8 JSON file, or a single Istanbul coverage map JSON file (commonly coverage-final.json).
--mutation-report <FILE>Saved fallow mutation --format json report (for example .fallow/mutation/last-report.json or the -o file of a run). Adds the mutation score of each complexity finding next to its CRAP score.
--min-invocations-hot <MIN_INVOCATIONS_HOT>100Threshold for hot-path classification
--min-observation-volume <N>Minimum total trace volume before the runtime coverage add-on gives high-confidence safe_to_delete / review_required verdicts. Below this, the add-on caps confidence at medium to protect against overconfident verdicts on new or low-traffic services. Omit to use the add-on default (5000)
--low-traffic-threshold <RATIO>Fraction of total trace count below which an invoked function is classified as low_traffic rather than active. Expressed as a decimal (e.g. 0.001 for 0.1%). Omit to use the runtime coverage add-on default (0.001)

The global options are in these groups: Project, Output, Scope, Baselines, Gates, Duplication, Type-aware, Performance.

The thresholds take their default from the health config.

Option details

Section selection

Without a section option, the run shows the health score, the complexity findings, the file scores, the hotspots and the refactoring targets. A section option shows only its section: --complexity, --file-scores, --hotspots, --targets, --score, --coverage-gaps. You can give more than one. --ownership implies --hotspots, and --effort implies --targets.

  • --hotspots and --ownership need git history, or a --churn-file. Outside a git repository, the section is empty and the run continues.
  • --score alone does not read the git history, so the score has no hotspot penalty. Add --hotspots for the penalty.
  • --coverage-gaps is opt-in. --type-coupling needs --type-aware. With --type-aware and no section flag, the run also includes type coupling.
  • Fallow takes the coverage path from --coverage, else from FALLOW_COVERAGE, else from health.coverage. When none is set, fallow reads coverage/coverage-final.json, then .nyc_output/coverage-final.json, in the project root. Without these files, it estimates the CRAP score. An auto-detected file gives the note using auto-detected coverage at <path> on stderr. --coverage-root follows the same order with FALLOW_COVERAGE_ROOT and health.coverageRoot, and must be an absolute path.
  • --coverage reads an Istanbul coverage map (coverage-final.json), a directory that holds one, a raw V8 coverage directory, or one V8 coverage JSON file. It does not read LCOV: with lcov.info, the run stops with failed to parse coverage data and exits with code 2. Add the json reporter to the test runner, and pass coverage-final.json.

Coverage input

Fallow computes the statement coverage of each function over the statements in the body of that function. The statements of a nested function belong to the nested function, not to the function that holds it.

  • For an Istanbul map, fallow counts the statements of each function from the file on disk, and reads the counts from the map. The coverage of a function can therefore differ from the text table of the test runner.
  • For V8 input, fallow takes the statements from the file on disk and the counts from the V8 block ranges. It sums the dumps of all test processes. A transpiled script (tsx, an esbuild or webpack bundle) maps back to its sources through the source map that Node writes into the dump. A script that is different from the file on disk and has no source map keeps the estimate.
  • A function that the coverage data does not describe keeps the estimate. The human output counts the matched functions: CRAP scores use Istanbul coverage where matched (22/25 functions); the rest fall back to the static estimate.
  • When the coverage data describes files that match no analyzed file, fallow prints note: the coverage file describes N files that no analyzed file matched. Set --coverage-root to the checkout that made the data.

In the JSON output, summary.coverage_model names the model (see CRAP). With measured coverage, summary.coverage_input_format names the input: istanbul or v8. Each CRAP finding has coverage_source, and summary.coverage_source_consistency is uniform when all findings have the same source, else mixed.

Literal membership chains

The standard cyclomatic count adds 1 for each ||. A check of one value against a list of literals therefore gets a high value, although it is one decision:

if (kind === "a" || kind === "b" || kind === "c" || kind === "d") {
  throw new Error("Unsupported kind");
}

The standard value of this function is 5. Set health.cyclomaticPolicy to "literal-membership" to count the chain as one predicate. The function then has the value 2 for the gates. A chain qualifies only when all of these are true:

  • Each operator of the chain is ||. Parentheses do not change the chain.
  • Each operand is a === check between a plain identifier and a string, number, bigint, boolean or null literal, on either side.
  • Each operand checks the same identifier, and the chain has two operands or more.

Member access (obj.kind === "a"), calls, ==, !== and a chain with another operator keep the standard count. A chain inside a wider condition, such as flag && (kind === "a" || kind === "b"), counts as one predicate, and the && still adds 1.

The policy changes the cyclomatic value of the maxCyclomatic gate, of each CRAP score and of the CRAP values of the file scores. The health score, the complexity density, the vital signs and the hotspots keep the standard count. The cognitive complexity does not change. In the JSON output, summary.cyclomatic_policy names the policy. A finding has the policy value in cyclomatic, and the standard value in standard_cyclomatic when the two values are different. With --complexity-breakdown, each || contribution of a chain has "literal_membership": true.

Threshold overrides

A health.thresholdOverrides entry gives some files or functions their own limits. The entry keeps the function in the output, and a suppression comment hides it. A finding checked against an override has effective_thresholds and threshold_source: "override".

When an entry affects the run, the JSON output has a threshold_overrides array. It has one row for each entry and dimension. The dimension complexity covers maxCyclomatic, maxCognitive, maxUnitSize and maxFileLines. The dimension crap covers only maxCrap. To count the entries and not the rows, group on override_index.

FieldContent
statusactive: the entry raises a limit that the unit needs, or the unit exceeds a limit that the entry lowers. stale: the entry changes no result, because the unit passes the global limits or a suppression comment covers it. insufficient: the unit still exceeds the raised limit, so the finding stays. no_match: the entry matches no analyzed file or function.
override_indexThe position of the entry in thresholdOverrides.
dimensioncomplexity or crap.
outstandingThe dimensions that the unit still exceeds with the entry. Absent when empty.
path, function, line, colThe matched unit. line is 1-based, col is 0-based. No position on a no_match row.
configured_thresholds, effective_thresholdsThe limits of the entry, and the limits after fallow applies each matching entry to the defaults.
metricsThe current cyclomatic and cognitive of the unit, crap when coverage data exists, and line_count on a complexity row.
reasonThe reason of the entry, when set.

For an insufficient row, raise the limit more or make the function simpler.

A fallow-override-threshold-next-line comment sets the limits of the next function. Its rows go to inline_threshold_overrides. Its findings have override_comment_line.

Option values

OptionValues
--sortcyclomatic (default), cognitive, lines, severity. Equal findings sort by path, line, column and name.
--min-severity, --effortmoderate, high, critical for --min-severity. low, medium, high for --effort.
--ownership-emailshandle (default): the local part of the email. anonymized: an xxh3:<16 hex> name, which is not a cryptographic hash. raw: the full email. hash is an old name of anonymized.
--sinceA duration (6m, 90d, 1y, 2w) or a date (2025-06-01). The default is 6m.
--baseline-modecount (default): match per file and category. identity: match per file and function name, only with a baseline that you saved with --baseline-mode identity.

Scope of the score

--workspace and a path argument compute the score, the vital signs and the file scores again for the files in scope. --group-by adds a groups array: each group has its own vital_signs, health_score, findings, file_scores, hotspots and targets. The top-level fields stay project-wide. --group keeps only the groups that match.

Baseline

--save-baseline saves the complexity findings and the refactoring targets with "kind": "health". --baseline hides the findings and the targets in the file. A baseline does not apply to file scores. The key of a target is <path>:<category label>, for example src/utils.ts:dead code. A target stays known while its file and category stay the same, also when its priority or effort changes. The result of the comparison is in summary.baseline_staleness.

Performance timings

--performance prints the time of each health stage on stderr. In the demo project:

┌─ Health Pipeline Performance ─────────────────────
│  config:                0.0ms
│  discover files:       16.6ms
│  parse/extract:        38.5ms
│  complexity:            0.0ms
│  file scores:           0.2ms
│  git churn:           246.2ms (cold, 597 git log bytes)
│  hotspots:              0.0ms
│  duplication:          20.2ms
│  targets:               0.0ms
│  (other):              33.6ms
│  ────────────────────────────────────────────────
│  TOTAL:               355.4ms
└───────────────────────────────────────────────────
  • git churn shows cached when the churn came from the cache, else cold. The byte count is the git log output that the run read. It is 0 when the cache or a churn file gave all the history.
  • (other) is TOTAL minus the stage rows, at least 0.0ms.
  • In a bare fallow run, the health stages reuse the parse of the dead-code pass. discover files and parse/extract then show (measured above).

With --format json, fallow writes the timings as one JSON object on stderr, so stdout keeps one report. The object has the _ms field of each stage, parse_cpu_ms, git_churn_cache_hit, git_log_bytes, total_ms and shared_parse. The times change from run to run, so do not use them as a gate.

Mutation report

--mutation-report <FILE> reads a saved fallow mutation JSON report, and shows the mutation score of each complexity finding below its CRAP score. The run starts no test. A function whose file changed since the mutation run shows stale and no score. The mutation score does not change the CRAP score, the health score or a gate. A plan document, a missing file or an invalid file exits with code 2.

Output

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

■ Metrics: 214 LOC · dead files 6.3% · dead exports 14.3% · avg cyclomatic 2.1 · p90 cyclomatic 2 · maintainability 92.8 (good) · 0 churn hotspots (since 6 months) · 1 unused dep · duplication 20.0%
  Cyclomatic units: functions 24, module scopes 1, templates 0
  Module scope: max cyclomatic 2; included in metrics, not function findings

● 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
  Functions exceeding cyclomatic, cognitive, or CRAP thresholds; ! marks the
  dimension that breached
  https://fallow.tools/docs/explanations/health/#complexity-metrics

● File health scores (13 files) · sorted by triage concern

   86.2    src/services/customers.ts                       risk
             48 LOC    1 fan-in    0 fan-out    0% dead  0.48 density  552.0 risk

● Refactoring targets (1)
  1 low effort
    score = quick-win ROI (higher = better) · pri = absolute priority

   17.4  pri:17.4    src/services/customers.ts
         complexity · effort:low · confidence:high  Extract classifyCustomer (cognitive: 32) in 48-LOC file into smaller functions
         importers: src/index.ts (classifyCustomer)

✗ 1 above threshold · 24 analyzed · maintainability 92.8 (good) (0.04s)
  • Health score gives the score, the grade and the largest deductions.
  • Metrics gives the vital signs of the project.
  • Each complexity finding gives the function, its severity band, its metrics and its CRAP score. ! marks each threshold that the function exceeds.
  • Each file score gives the maintainability index, the size, the fan-in and fan-out, the share of unused code, the complexity density and the CRAP risk.
  • Each refactoring target gives its score, its priority, its effort and the recommendation.

Severity bands and labels

Each complexity finding gets the highest band of its three values. The bands are fixed. The limits maxCyclomatic, maxCognitive and maxCrap decide only if a function has a finding, and the complexity-* rules decide if the finding fails the run.

Valuemoderatehighcritical
Cyclomatic complexitybelow 3030 to 4950 or more
Cognitive complexitybelow 2525 to 3940 or more
CRAPbelow 5050 to 99100 or more

A long file finding is always moderate.

The other labels of the human output:

  • maintainability 92.8 (good): good for an average maintainability index of 85 or more, moderate for 65 or more, low below 65. The health score counts a file below 70 as low (maintainability_low_pct).
  • The risk column of a file score shows the highest CRAP score of the file: low below half of maxCrap, moderate up to maxCrap, high at maxCrap or more. With the default limit, that is low <15, moderate 15-30 and high >=30. A value above 999 shows as >999. The JSON output has the exact value.
  • The risk or structure tag tells which value puts the file in its place: the CRAP risk, or the low maintainability index.

JSON output

With --format json, the output has these top-level fields. The field of a section is present only when the section ran.

FieldContent
kind"health"
schema_version, version, elapsed_msThe version of this output format, the fallow version and the run time.
sectionsThe sections that the run produced. Use it to tell an empty section from a section that did not run.
summaryThe counts and the thresholds: files_analyzed, functions_analyzed, functions_above_threshold, the max_*_threshold values, average_maintainability, coverage_model, and the count for each severity band.
findingsThe complexity findings: path, name, line, col, cyclomatic, cognitive, line_count, param_count, exceeded, severity (the band), effective_severity (the rule), crap, coverage_source, actions. --complexity-breakdown adds contributions.
health_scorescore, grade, formula_version and the penalties of each metric.
vital_signsThe project metrics. See Vital signs.
file_scoresOne object for each file: maintainability_index, fan_in, fan_out, dead_code_ratio, complexity_density, crap_max and other metrics.
hotspots, hotspot_summaryThe hotspots and the window of the history. See Hotspots.
change_couplingFile pairs that change together without an import between them.
targets, target_thresholdsThe refactoring targets, with direct_callers and clone_siblings when present.
coverage_gapsThe files and exports that no test reaches. Present with --coverage-gaps.
runtime_coverage, coverage_intelligenceThe result of --runtime-coverage.
mutationThe result of --mutation-report.
health_trendThe comparison with a snapshot. Present with --trend.
threshold_overridesThe state of each health.thresholdOverrides entry: active, stale, insufficient or no_match.
inline_threshold_overrides, inline_threshold_override_problemsThe threshold override comments.
css_analytics, styling_findings, styling_healthThe CSS analysis. Present with --css.
grouped_by, groups, group_filterThe groups of a --group-by run.
gate_outcomesOne entry for each gate of the run. Always present.
workspace_diagnosticsProblems with the project or the inputs.
next_stepsCommands to run next.
large_functionsThe functions longer than 60 lines. Present only when these functions are 3 percent or more of all functions.
prop_drilling_chainsThe prop-drilling chains. Present only when the opt-in prop-drilling rule is on.
framework_healthThe coverage of the framework detectors. Optional.
actions_metaWhy fallow changed the actions arrays, for example no suppression hint when a baseline is active. Optional.
request_outcomesThe result of each scope request. See Request outcomes.
_metaMetadata of the run, for example telemetry.analysis_run_id.

The JSON output reference has each field.

CSS analysis

With --css, the output has three fields. Styling explains the analysis.

  • css_analytics: the measurements and the cleanup candidates.
  • styling_findings: the findings of the five styling rules, each with code, sub_kind, effective_severity, the location, the evidence value and read-only actions.
  • styling_health: the styling score.

Styling findings has the cleanup candidates, the token consumers and the styling score formula.

Coverage gaps

With --coverage-gaps, the output has coverage_gaps:

  • summary: runtime_files, covered_files, file_coverage_pct, untested_files and untested_exports.
  • files[]: the runtime files that no test reaches, with path, value_export_count and actions.
  • exports[]: the exports that no test reaches in files that tests reach, with path, export_name, line, col and actions.

The analysis knows test mocks. A vi.mock or jest.mock call with a closed factory replaces the module: the factory has no vi.importActual or jest.requireActual, and the test has no other import of the module. Such a test does not reach the module, so the module can be a gap. When fallow cannot prove the replacement, the module keeps its credit:

  • A mock without a factory keeps the credit, because the test runner can still load the original module.
  • vi.doMock and jest.doMock keep the credit, because they are not hoisted and depend on the order of the code.

The coverage-gaps rule sets the severity, and it is off by default. To leave one file out, put // fallow-ignore-file coverage-gaps in the file.

Runtime coverage

With --runtime-coverage, the output has runtime_coverage with the verdict of the run, the findings for each function and the hot paths. Runtime coverage explains the data and the capture. See Evidence fields.

Degraded inputs

An input that fallow cannot read gives zeros, for example a project without git or an unreadable snapshot. To tell a measured zero from a missing measurement, read workspace_diagnostics: an entry with degrades_analysis: true marks a missing input. Select on that field, and not on a list of kinds.

fallow health --format json --quiet | jq '.workspace_diagnostics[] | select(.degrades_analysis)'

Fallow writes each entry with or without --quiet. These kinds come from the health inputs:

kindMeaningdegrades_analysis
file-scores-unavailableThe file score pass failed. The score list is empty, and each number from the scores is zero.true
hotspots-skippedThe hotspot, churn and ownership sections report nothing. cause is not-a-repository, invalid-since or churn-file-unreadable.true
shallow-cloneThe churn covers only the fetched history. ownership_requested tells if the run asked for ownership.true
unpinned-clockNo commit time is available, so the recency weights move between two runs on the same commit.true
ownership-unavailableThe ownership inputs did not load. cause is invalid-bot-pattern or codeowners-parse-failed.true
trend-snapshot-unreadableFallow could not read a saved snapshot, so the trend uses fewer snapshots.true
change-coupling-skippedchange_coupling.pairs is empty. cause is shallow-clone or too-few-commits. The other sections still measure.absent
trend-group-baseline-unavailableThe baseline snapshot has no group data for the --group-by mode. See Group trends.absent
coverage-auto-detectedNot a failure: path names the coverage file that fallow found on disk.absent

The set of kinds is open. Read a kind that you do not know as one more diagnostic, not as an error.

Vital signs

FieldContent
dead_file_pct, dead_export_pctThe percentage of unused files and of unused value exports.
avg_cyclomatic, p90_cyclomatic, critical_complexity_pctThe average and the 90th percentile of the cyclomatic complexity, and the percentage of functions with a cyclomatic complexity of 50 or more.
cyclomatic_population, total_locThe count, sum and maximum of the cyclomatic complexity for functions, module scopes and templates, and the lines of code.
duplication_pctThe percentage of duplicated code. null without --score.
hotspot_count, hotspot_top_pct_countThe files with a hotspot score of 50 or more, and the files with a positive score in the top 1 percent of the ranking. hotspot_count feeds the health score. groups[].hotspot_count of a --group-by run is a different count: the length of the ranked hotspot list of the group, before --top. Do not compare the two counts.
maintainability_avg, maintainability_low_pctThe average maintainability index, and the percentage of files below 70.
unused_dep_count, unused_deps_per_k_filesThe unused dependencies.
circular_dep_count, circular_deps_per_k_filesThe circular dependencies.
unit_size_profile, functions_over_60_loc_per_kThe distribution of the functions by lines, in percent: low_risk (1 to 15), medium_risk (16 to 30), high_risk (31 to 60) and very_high_risk (more than 60). functions_over_60_loc_per_k is the number of functions over 60 lines for each 1,000 functions.
unit_interfacing_profileThe distribution of the functions by parameter count, in percent: low_risk (0 to 2), medium_risk (3 to 4), high_risk (5 to 6) and very_high_risk (7 or more).
p95_fan_in, coupling_high_pctThe 95th percentile of the fan-in, and the percentage of files with a fan-in above the larger of p95_fan_in and 10.
countsThe numbers behind each percentage.

Health score

The score starts at 100. Fallow subtracts each penalty in health_score.penalties, rounds to one decimal, and keeps the result between 0 and 100. A penalty of an analysis that did not run is null and subtracts nothing.

PenaltyFormulaMaximum
dead_filesdead_file_pct × 0.215
dead_exportsdead_export_pct × 0.215
complexitycritical_complexity_pct × 420
p90_complexity(p90_cyclomatic − 10), only when critical_complexity_pct is absent10
maintainabilitymaintainability_low_pct × 1.515
hotspotshotspot_count ÷ (1 percent of the files, rounded up, at least 1) × 1010
unused_depsunused_deps_per_k_files × 0.525
circular_depscircular_deps_per_k_files × 0.525
unit_sizefunctions_over_60_loc_per_k × 0.510
couplingcoupling_high_pct × 0.55
duplicationduplication_pct − 510
prop_drilling1 for each prop-drilling chain, only with the prop-drilling rule5

The grade is A for a score of 85 or more, B for 70, C for 55, D for 40 and F below 40. formula_version is 3.

Maintainability index

maintainability_index of a file is:

MI = 100 − complexity_density × 30 × min(lines ÷ 50, 1) − dead_code_ratio × 20 − min(ln(fan_out + 1) × 4, 15)
  • complexity_density is the sum of the cyclomatic complexity of the file divided by its lines.
  • dead_code_ratio is the share of the value exports that nothing uses. It is 1 for an unused file, and 0 for a file without value exports.
  • Fallow keeps the result between 0 and 100.

CRAP

CRAP = CC² × (1 − coverage)³ + CC

CC is the cyclomatic complexity of the function. With a coverage file, coverage is the measured coverage of the function (coverage_model istanbul). Without one, fallow estimates it (coverage_model static_estimated): 85 percent for a function that a test imports, 40 percent for another function in a file that a test reaches, and 0 for a function that no test reaches. Only a value import counts as a direct test reference, not an import type. An old snapshot can also have static_binary, a model that the current version does not produce.

A function with full coverage scores its CC, and a function without coverage scores CC² + CC. With the default estimate, an untested function with a cyclomatic complexity of 5 scores 5² + 5 = 30, which is the default limit.

Each finding has coverage_tier: none (no coverage), partial (below 70 percent) or high (70 percent or more). The first action of a CRAP finding follows from the formula:

ConditionFirst action
cyclomatic is below maxCrap, and coverage_tier is noneadd-tests
cyclomatic is below maxCrap, and coverage_tier is partial or highincrease-coverage
cyclomatic is maxCrap or more: full coverage cannot bring the score below the limitrefactor-function

A CRAP-only finding also gets a second refactor-function action when its cyclomatic complexity is within health.crapRefactorBand (default 5) of maxCyclomatic, and its cognitive complexity is half of maxCognitive or more. The cognitive condition keeps this advice away from a flat switch, which has many paths and is easy to read.

The actions of a finding have no suppress-line hint when a baseline is active, or when health.suggestInlineSuppression is false. The output then has actions_meta with "suppression_hints_omitted": true and a reason of baseline-active or config-disabled.

Refactoring targets

priority = min(complexity_density, 1) × 30 + hotspot_score ÷ 100 × 25 + dead_code_ratio × 20 + min(fan_in ÷ fan_in_p95, 1) × 15 + min(fan_out ÷ fan_out_p95, 1) × 10
efficiency = priority ÷ effort

effort is 1 for low, 2 for medium and 3 for high. The targets are sorted by efficiency, highest first.

  • high effort: 500 lines or more, a fan-in of fan_in_p95 or more, or 15 functions or more with a complexity density above 0.5.
  • low effort: fewer than 100 lines, 3 functions or fewer, and a fan-in below the 25th percentile (at least 2).
  • medium effort: each other file.

target_thresholds holds the percentiles of the project: fan_in_p95 (at least 5), fan_in_p75 (at least 3), fan_out_p95 (at least 8) and fan_out_p90 (at least 5).

Fallow checks the rules of this table in order, and gives a file the category of the first rule that matches. The human output shows the label. The JSON factors still list each signal of the file.

categoryLabelRuleconfidence
urgent_churn_complexitychurn+complexityA hotspot score of 50 or more, the trend Accelerating, and a complexity density above 0.5.low
break_circular_dependencycircular dependencyThe file is in an import cycle, and has a fan-in of 5 or more.high
split_high_impacthigh impactA complexity density above 0.3, and a fan-in of fan_in_p95 or more, or of fan_in_p75 or more with 5 functions or more.medium
remove_dead_codedead codeHalf or more of the value exports are unused, and the file has 3 value exports or more.high
extract_complex_functionscomplexityA function with a cognitive complexity of 30 or more.high
extract_dependenciescouplingA fan-out of fan_out_p90 or more and a maintainability index below 60. Entry points do not match.medium
add_test_coverageuntested risk2 functions or more at or above maxCrap, and a complexity density above 0.3.high
break_circular_dependencycircular dependencyEach other file in an import cycle.high
resolve_hidden_couplinghidden couplingA strong change coupling pair (degree 0.5 or more). Only a file that no other rule claims.medium

A strong pair also adds the hidden_coupling factor to the targets of both files, whatever their category. The factor has the degree as value and 0.5 as threshold.

The evidence object links a target to the data behind it. Fallow leaves out evidence when it has no data.

FieldContent
unused_exportsFor remove_dead_code: the names of the unused exports.
complex_functionsname, line and cognitive of each function. For extract_complex_functions, the functions with a cognitive complexity of 30 or more. For add_test_coverage, up to 3 functions with the highest cognitive complexity.
cycle_pathFor break_circular_dependency: the files of the cycle.
co_change_partnersFor resolve_hidden_coupling: up to 5 files that change together with the target, strongest first, with path, shared_revisions and degree.
direct_callersUp to 5 files that import the target, with the symbols that they import.
clone_siblingsUp to 5 other instances of the clones in the file, with their dup: handle for fallow dupes --trace.

Hotspots

The hotspot score is the weighted commits of the file divided by the largest weighted commits, times its complexity density divided by the largest complexity density, times 100. Each hotspot has path, score (0 to 100), commits, weighted_commits (with a half-life of 90 days), lines_added, lines_deleted, complexity_density, fan_in, trend (Accelerating when the newer half of the window has more than 1.5 times the commits of the older half, Cooling below 0.67 times, else Stable) and is_test_path. hotspot_summary has since, min_commits, files_analyzed, files_excluded and shallow_clone.

With --ownership, each hotspot also has these fields:

FieldContent
bus_factorThe smallest number of authors that made half of the weighted commits.
contributor_countThe number of authors, without bots.
top_contributor, recent_contributorsThe authors with the largest share: identifier, format, share, stale_days, commits.
suggested_reviewersThe recent contributors that committed in the last 90 days.
declared_owner, unownedThe owner in CODEOWNERS. unowned is null when the project has no CODEOWNERS file.
ownership_stateactive, unowned, declared_inactive or drifting.
drift, drift_reasontrue when the first author has less than 10 percent of the weighted commits of a file that is 30 days old or older.

The actions of a hotspot can then have low-bus-factor, unowned-hotspot and ownership-drift. The health.ownership config key sets the bot patterns and the email mode.

ActionWhenNext step
low-bus-factorbus_factor is 1.Add a second reviewer. The note names candidates from suggested_reviewers when they exist.
unowned-hotspotunowned is true: a CODEOWNERS file exists, and no rule matches.Add a CODEOWNERS entry. suggested_pattern gives the deepest directory of the file, and heuristic is directory-deepest.
ownership-driftownership_state is drifting.Update CODEOWNERS to the new top contributor.

The human output marks the bus factor of each hotspot.

In the handle mode, fallow also removes a GitHub noreply prefix: 12345+alice@users.noreply.github.com shows as alice. The anonymized mode keeps raw emails out of CI artifacts, but it is not strong privacy: a person with a list of the emails of an organization can compute the same names. The default bot patterns do not include *noreply*, because most people commit from a GitHub noreply address.

Fallow computes the ownership signals only for files that pass --min-commits. Squash merges make one author look more dominant, and a shallow clone distorts the signals more.

The [test] tag and is_test_path follow the test path rules.

Change coupling

The change_coupling section lists hidden pairs: two files that change together, without an import or re-export chain between them. The section is present when the hotspot section ran on git history, and sections then has change-coupling. The section is advisory: it has no weight in the health score and never fails a run. With --group-by, it stays at the root of the output.

Without --since, change coupling and change dispersion read 12 months of history, and hotspots read 6 months. With --since, the three read the same window. A commit that changes more analyzed files than health.changeCoupling.maxFilesPerCommit does not count.

FieldContent
sinceThe window that the section read, for example "12 months".
commits_analyzed, commits_skippedThe commits that count, and the commits with too many files.
total_pairsThe pairs before --top.
thresholdsmax_files_per_commit, min_revisions, min_shared_revisions, min_degree and strong_degree (0.5).
pairs[]path_a (sorts first), path_b, revisions_a, revisions_b, shared_revisions, degree (0 to 1, two decimals) and strong (present and true at strong_degree or more). Sorted by degree, then shared_revisions, highest first, then by path.

Each hotspot also has median_files_per_commit and median_lines_per_commit: the median number of analyzed files, and of added plus deleted lines, in the commits that change the file. They use the change coupling window. They are absent when the history has no commit ids, for example a churn file without commit fields. In a churn file, the events with the same commit form one commit.

The markdown format adds a Hidden Change Coupling table after the hotspots, when pairs exist. The compact format has one line for each pair:

change-coupling:src/a.ts:src/b.ts:degree=1.00,shared=6,commits_a=6,commits_b=6,strong=true

Snapshot and churn files

Health files gives the format of the snapshot file that --save-snapshot writes, and of the churn file that --churn-file reads for history from a VCS other than git.

Exit codes

RunExit code 0 whenExit code 1 when
fallow healthno finding has a complexity-* rule at errora finding has a rule at error, which is the default
--fail-on-issuesthe run has no findingthe run has a finding, also with a rule at warn
--min-score Nthe score is N or higherthe score is lower than N
--min-severity LEVELno finding is at LEVEL or highera finding is at LEVEL or higher
--report-onlyalwaysnever

With --min-score and --min-severity together, the run fails when one of them fails. With --min-score alone, the findings do not set the exit code. --report-only together with --min-score or --min-severity exits with code 2.

CodeMeaning
2Invalid input, for example an invalid --mutation-report file or --trend-from file.
3 to 6With --runtime-coverage: the license is not valid, or the runtime coverage step failed.

Exit codes has the meaning of each code.

Examples

# Report the functions above the thresholds
fallow health

# Show only the 10 most complex functions, sorted by cognitive complexity
fallow health --complexity --top 10 --sort cognitive

# Use measured coverage for the CRAP scores
fallow health --coverage coverage/coverage-final.json

# Show the hotspots of the last 3 months, with their owners
fallow health --hotspots --ownership --since 3m

# Fail when the health score is lower than 70
fallow health --min-score 70

# Show the results without a failure
fallow health --report-only

# Save a snapshot, then compare a later run with it
fallow health --save-snapshot
fallow health --trend