Skip to content

fix: coverage and coupling metrics miscount test files #7

@bntvllnt

Description

@bntvllnt

Summary

Two related metric quality issues where test files pollute rankings meant for source files.

1. Coverage metric includes test files as "uncovered"

find_hotspots(metric='coverage') returns test files with score: 1 and reason "no test file found":

analyzer/index.test.ts  → score: 1 → "no test file found"
graph/index.test.ts     → score: 1 → "no test file found"
parser/index.test.ts    → score: 1 → "no test file found"

These files ARE tests. They shouldn't appear in the "needs tests" list.

Location: src/mcp/index.ts:248-251

Fix: Filter files matching *.test.ts / *.spec.ts from coverage hotspot results.

2. Coupling metric — test files and entry points always rank highest

analyzer/index.test.ts → coupling: 1.0 (fan_in: 0, fan_out: 4)
cli.ts                 → coupling: 1.0 (fan_in: 0, fan_out: 6)

Files with fan_in: 0 always get coupling: 1.0. Test files and entry points are leaf consumers by design — ranking them as "most coupled" is misleading.

Fix options:

  • Exclude test files from coupling rankings
  • Or separate "source coupling" vs "test coupling" views
  • Or weight coupling to deprioritize leaf consumers (fan_in=0)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions