Class DetectorDefaultSeverity
Why this exists. IssueSeverity.fromReport(String) recovers a
finding's severity by matching markers in the report text, and returned IssueSeverity.HIGH when it found none. 86 of the 142 built-in detectors write no marker, so a
merge gate on failOn = HIGH failed on all of them alike: a spin loop that should yield,
an explicit System.gc() and a lost update were ranked identically, because none of the
three said anything and the default said HIGH. That made failOn = HIGH close to "fail on
anything", which is the same as no gate at all.
From 1.9.7 every one of those detectors stated its severity here, chosen against
IssueSeverity's own definitions: CRITICAL where the report's primary claim is
that something will not make progress, HIGH where it claims corruption or an incorrect
result, MEDIUM for degradation and leaks, LOW for an inefficiency. Where two
readings were defensible the higher was taken, because under-ranking a real bug costs more than
over-ranking a benign one.
A detector's own report always wins. This table is consulted only when the
report carries no structured severity (see structuredIn(java.lang.Object)) and its text marks none, so a
detector that learns to state one per finding overrides it
without touching this file, and its entry then has to be removed:
DetectorSeverityMarkerTest fails on an entry for a detector that marks its own reports,
so the table can only shrink as the detectors improve.
The table is empty. Since #801 every built-in detector keeps its findings as
Violations at the severity its text used to resolve to, so none falls back to an entry
here; the structured severities are the ones this table, or a marker, gave them. of(DetectorType) stays for callers and yields empty for every type; a detector added without
a structured severity of its own still fails DetectorSeverityMarkerTest unless it marks
its text or regains an entry.
Third-party detectors arriving through the SPI are not in this table and keep the historical
HIGH default. The library has no basis for ranking somebody else's finding.
- Since:
- 1.9.7
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic IssueSeverityReturns the severity a finding should be gated on, from its text alone.static IssueSeverityof(String detectorName, String report, @Nullable IssueSeverity structured) Returns the severity a finding should be gated on.static Optional<IssueSeverity> of(DetectorType type) Returns the declared severity for a built-in detector that marks none itself, if any.structuredFindingsIn(@Nullable Object report) Returns a report's structured findings, in its order; empty when it keeps none.static Optional<IssueSeverity> structuredIn(@Nullable Object report) Returns the most severe severity among a report's structured findings, when it keeps any.
-
Field Details
-
STRUCTURED_FIELD
The public field built-in reports keep theirViolations in.- Since:
- 1.12.3
- See Also:
-
-
Method Details
-
of
Returns the declared severity for a built-in detector that marks none itself, if any.- Parameters:
type- the detector;nullyields empty- Returns:
- the declared severity for a built-in detector that marks none itself, if any
-
of
Returns the severity a finding should be gated on, from its text alone.Precedence: what the report text marks, then what the detector declares here, then
IssueSeverity.HIGHfor anything this library does not know, which is every third-party detector. Callers that hold the report object useof(String, String, IssueSeverity)withstructuredIn(java.lang.Object), which the text cannot override.- Parameters:
detectorName- the reporting detector's name, as it appears in the report mapreport- the report text- Returns:
- the severity a finding should be gated on, from its text alone
-
of
@API(status=EXPERIMENTAL) public static IssueSeverity of(String detectorName, String report, @Nullable IssueSeverity structured) Returns the severity a finding should be gated on.The one place that answer is computed, so the
failOngate, the JSON report and the SARIF output cannot disagree about what a finding was worth. Precedence: the severity the detector put in its structured findings, thenof(String, String).The structured severity comes first because it is the one the detector chose per finding. Text matching only guesses:
ThreadLocalCacheDegradationDetectorrates every findingMEDIUMin itsViolation, writes no marker, and has no entry here, so the text route alone reached theHIGHfallback and failed afailOn = HIGHbuild.- Parameters:
detectorName- the reporting detector's name, as it appears in the report mapreport- the report textstructured- the most severe structured severity of this report, ornull- Returns:
- the severity a finding should be gated on
- Since:
- 1.12.3
-
structuredIn
@API(status=EXPERIMENTAL) public static Optional<IssueSeverity> structuredIn(@Nullable Object report) Returns the most severe severity among a report's structured findings, when it keeps any.Built-in reports that hold their findings as
Violations beside the text expose them in a publicList<Violation> structuredViolationsfield. There is no shared interface for it, so the field is read by name, the way the SPI bridge readanalyze()until 1.13.0. A report without the field, or with an empty list, yields empty and the caller falls back to the text.DetectorSeverityMarkerTestrelies on the same field name to decide which detectors state their own severity.- Parameters:
report- a detector's report object;nullyields empty- Returns:
- the most severe severity among a report's structured findings, when it keeps any
- Since:
- 1.12.3
-
structuredFindingsIn
@API(status=EXPERIMENTAL) public static List<Violation> structuredFindingsIn(@Nullable Object report) Returns a report's structured findings, in its order; empty when it keeps none.Read from the same
structuredViolationsfield asstructuredIn(java.lang.Object). The runner's one-line summary of a folded block counts and heads with these, because a report's text also lists context and advice as bullets, and counting those read advice as a finding (#773).- Parameters:
report- a detector's report object;nullyields empty- Returns:
- a report's structured findings, in its order; empty when it keeps none
- Since:
- 1.12.4
-