Dead code

Dead code lists the methods your agents measured in a running environment that nothing ever executed. It is coverage in production read backwards: a method here shipped, was loaded, and was never reached. Open it when you want a list of code that is safe to question or delete, ideally scoped to production.

Where to find it

Sidebar, group Analyse → Dead code. The page also links to Code graph (Code tab), which draws the same methods as a map.

What it shows

Window and environment

A toolbar at the top holds the window (7 days, 30 days, 90 days; 30 is the default) and, once any environment is known, an Environment row with All and one chip per environment. Clicking an active chip again returns to All.

Only unreferenced

This switch appears only when the project has a code map. Its label carries the number of listed dead methods that nothing in the code references. Next to it a sentence says how many of the listed methods the code map knows and how many of those are referenced by nothing.

Summary numbers

  • Dead methods: measured methods whose best hit count in the window is zero.
  • Of measured: dead methods as a share of all measured methods, with dead / measured methods underneath.
  • Runs scanned: runs that started in the window (with an environment selected, only runs with a participant in that environment). The hint repeats the window length and the environment.

In the source

A panel that compares what the stored source contains with what coverage saw. Its hint gives the number of methods across indexed files, and how many files are still being indexed.

  • Ran: methods that a trace named or whose lines coverage hit, at any time.
  • Measured, never ran: methods in files that coverage measured, with nothing inside them reached.
  • Never measured: methods the source holds in files no coverage ever mentioned.

The panel stresses that Never measured is not dead: no agent loaded those files, so nothing can be said about them. When every stored source file is one that coverage already named (the source was uploaded by the agents because coverage asked for it, and no repository is connected), the panel says the third column can only read zero and that connecting the repository makes it count.

This panel is not scoped by the window or the environment. It is hidden when there is no indexed source.

Dead methods per week

A bar per week for the last 12 weeks: how many of the methods measured that week never ran. Hovering a bar shows dead of measured for that week. The header shows the change against the previous week (an up arrow in red, a down arrow in green). The chart appears only when there are at least two weeks of data.

The package and file tree

Folders and files that hold at least one dead method, as an expandable tree:

  • Folders roll up the dead and total counts of everything beneath them. The bar fills with the dead share, so a long red bar is a package where much of the measured code never ran.
  • Chains of folders with a single child folder are collapsed into one row.
  • Rows are sorted by dead count, folders before files, then by name. The top two levels open by default.
  • Each row shows N dead, a bar, and dead/total · %.

Opening a file lists its dead methods. Each method row shows the line number, the text of that line from the stored source (with the method name beside it), and a badge when a code map is available:

  • unreferenced: nothing in the code references this method.
  • N refs: the code references it N times, and none of those paths ever ran.

When a line is longer than 300 characters the file is treated as a minified build: the row shows the method name and asks you to enable source maps instead of printing the line. When a file has more dead methods than are listed, the list ends with …and N more.

When nothing is dead the page says so; when nothing was measured at all, it tells you to attach an agent to a running service.

How it works

  • Data source: per-method coverage that agents report for each run (method name, line and hit count per file). Only methods an agent actually measured are counted.
  • Method identity: a method is identified by its file and its name, not its line. Lines move as a file is edited between deployments; grouping by line would turn one method into several. For each method the page takes the highest hit count across every report in the window. Zero means it never ran. The line shown is the one from the newest report, so the source opens at the code as it is now.
  • Window: reports from runs that started within the chosen number of days.
  • Environment filter: keeps only reports uploaded by a participant in that environment. Production coverage means coverage a production replica reported, even in a monitoring window that test pods shared. The environment list combines the environments declared by participants (set on the agent, or taken from its token) and the environments of every agent token, so a new environment is offered before its first report. Names are compared in lower case.
  • Weekly trend: the last 84 days grouped by calendar week, using the same file-plus-name identity, so a refactor week does not double-count moved methods.
  • Caps: at most 200 files (most dead first), at most 4,000 dead methods in total and at most 100 per file are listed. The totals at the top are never capped.
  • References: when a code map exists for the project, each listed dead method is matched by file and name to the map, and the number of incoming references from other symbols is counted. Structural links (a class containing its methods) do not count as references.

Metadata-only projects

In a project that keeps metadata only, In the source counts the methods that source outlines name (Java agent: from bytecode; coverageops outline: parsed), and the method rows show the line number and method name without the line's text.

What you can do

  • Switch the window between 7, 30 and 90 days.
  • Pick an environment, or All.
  • Turn on Only unreferenced to keep only methods nothing references (the delete list).
  • Expand and collapse folders and files.
  • Click a method row to open the file's source with every listed dead method of that file marked.
  • Follow the link to Code graph to see the same methods drawn as a map.

Limits and good to know

  • A method no agent ever loaded is not on this page at all. Use In the source to see how much of the codebase that leaves out.
  • The In the source panel reads Java, TypeScript and JavaScript source only.
  • The weekly chart's caption says it covers all environments, but the chart follows the selected environment.
  • When the list is capped the page says "Showing the worst offenders". The 4,000-method cap is applied in file path order, so files late in that order can show only …and N more.
  • The reference badges and the Only unreferenced count cover the listed methods only.
  • Agents report anonymous functions as (anonymous); the source line next to the number is what tells them apart.