Skip to main content

Module priority

Module priority 

Source
Expand description

What a clone group is worth attending to, as separated measures.

A ranking that collapses to one number cannot be argued with. Three different questions decide where a finding belongs in a report, and they have different answers and different evidence:

Priority::final_priority composes them into one order, because a report has to be printed in some order. It never replaces them: every view carries all four, and Priority::inputs carries the values they were read from, so a reader who disagrees with the ranking can see exactly which input produced it.

§Why the composition multiplies rather than adds

Risk and difficulty are statements about a finding that is real. Added to confidence they can outvote it, and a lookalike with many copies then outranks a genuine duplication with two — which is the failure mode the separation exists to prevent. Multiplying makes confidence the leading term: the maintenance argument moves a finding within the band its confidence puts it in, and cannot lift it out of that band.

Measured over the labelled corpora, an additive composition costs mean average precision against a multiplicative one at the same weights; see precision_at_k in the evaluation harness, which pins the comparison.

§Why the values do not depend on the other findings

Every measure here is computed from one group’s own facts. Nothing is ranked against the rest of the run, and nothing is scaled by the run’s maximum. A rank-based composition reads well on one report and falls apart across two: adding a single group renumbers every other group’s rank, so a finding’s priority would move for reasons that have nothing to do with it, and codehelion audit could not say whether a priority rose because the duplication got worse or because something else was found. Absolute values are comparable between runs; ranks are not.

Counts are mapped onto 0..1 by saturating, which has no cliff to calibrate and no ceiling to saturate against: a value twice the reference scores two-thirds, ten times the reference scores ten-elevenths, and nothing ever reaches 1. That last part is deliberate — none of these measures is ever certain.

Structs§

GroupFacts
What the ranking reads about one clone group.
Priority
Where one clone group belongs in a report, and on what grounds.
Weights
How the separated measures are weighted against each other when they are composed into one order.

Constants§

RECIPE_VERSION
Version of the ranking recipe, recorded with every run.

Functions§

clone_confidence
How sure the finding is duplication worth reporting.
maintenance_risk
What keeping the copies in step costs.
rank
Rank one clone group: every measure, and the facts they came from.
refactoring_difficulty
What removing the duplication would cost.
saturating
A count mapped onto 0..1 by how far past half it reaches.