Documentation
¶
Overview ¶
Package score ranks static-analysis findings so renderers can lead with the ones that matter. The score is severity weight × file centrality: errors outweigh warnings outweigh notes, and production code outweighs internal/test code. Used by pkg/view to order Findings before rendering.
Weights are constants (no runtime flag) — tuning means editing the package, not configuring fo.
Index ¶
Constants ¶
const ( SeverityWeightError = 3 SeverityWeightWarning = 2 SeverityWeightNote = 1 )
Severity weights used by Score. Tunable as constants — no runtime flag.
const ( CentralityRoot = 1.0 // cmd/* or pkg/* roots CentralityInternal = 0.5 // internal/* paths CentralityTest = 0.25 // any *_test.go file CentralityDefault = 1.0 // anything else (treat as root-equivalent) )
File centrality factors used by Score. Tests get the lowest weight so that production code defects sort above test-file defects of equal severity.
Variables ¶
This section is empty.
Functions ¶
func FileCentrality ¶
FileCentrality returns the centrality factor for path.
Precedence (first match wins):
- *_test.go → CentralityTest (test files, even under cmd/ or pkg/)
- internal/ → CentralityInternal
- cmd/ or pkg/ → CentralityRoot
- anything else → CentralityDefault
Test-file precedence is intentional: a defect inside a *_test.go file under pkg/ is still test code and should sort below production defects of equal severity.
func Score ¶
Score is the deterministic priority score for a finding:
score = severityWeight × occurrenceCount × fileCentrality(path)
Higher scores sort first. Inputs are expected to be non-negative; callers that pass an occurrenceCount of 0 will get a score of 0.
func SeverityWeight ¶
SeverityWeight maps a SARIF level string to its score weight. Unknown levels (including empty and "none") get the note weight.
Types ¶
This section is empty.