Qodana JVM resource-leak inspection: baseline legacy findings or gate on severity counts?
0 reputation · 19 May 2026, 20:05 UTC
0 reputation · 19 May 2026, 20:05 UTC
Assuming a recent JetBrains JVM linter image, the goal is to use its resource-leak inspections for unclosed Closeable values as a CI guard, so a leak-prone pattern cannot quietly return after a fix. Static analysis inspects source, not runtime behavior, so it complements rather than replaces profiler or heap-dump evidence.
Two constraints shape the setup:
The open decision is the gating policy. Qodana's quality gate supports a baseline, where pre-existing findings are recorded and only new problems count, and absolute severity thresholds via failThreshold in qodana.yaml. The policies define a verified fix differently: a baseline ignores legacy findings indefinitely, while an absolute count forces cleanup but adds churn.
Should the gate fail only on new resource-leak findings above a chosen severity, with current findings baselined? Or should an absolute threshold apply, and how would pre-existing findings be handled? Which pinned linter version and inspection ID should the policy reference so results stay comparable?
29775 reputation · 20 May 2026, 00:40 UTC
Use baseline mode for existing findings and add a low absolute failThreshold as a backstop. This blocks new resource-leak findings while allowing legacy leaks to be cleaned up gradually.
Baseline mode (baseline: true in qodana.yaml) records current findings in baseline.xml and only fails the gate on new problems. That prevents a leak pattern from silently passing after a fix. However, baseline alone lets the legacy count grow if developers ignore it. Adding a tight absolute threshold (e.g., ERROR: 0, WARNING: 5) caps net‑new leaks and forces gradual remediation of baselined items.
jetbrains/qodana-jvm:2024.3). Do not use latest.docker run --rm -v $(pwd):/data jetbrains/qodana-jvm:2024.3 --show-reportInspect qodana.sarif.json → rules[] for a rule whose name or shortDescription contains "ResourceLeak" or "resource leak". Note the ruleId (typically ResourceLeak or JavaResourceLeak) and defaultConfiguration.level (usually "warning").docker run --rm -v $(pwd):/data jetbrains/qodana-jvm:2024.3 --baseline baseline.xmlqodana.yaml with both mechanisms:version: 1.0
baseline: true
failThreshold:
error: 0
warning: 5
# weakWarning: 10 # optional, if you want to track lower‑severity drift
profile:
name: qodana.recommended
# Optionally restrict to the specific inspection ID you verified:
# include:
# - name: ResourceLeak # or JavaResourceLeak
Closeable in a test branch; the gate should fail. Confirm baselined findings do not fail the gate.If your team must achieve zero resource‑leak findings within a fixed sprint (e.g., compliance deadline), drop the baseline and set failThreshold: { error: 0, warning: 0 } immediately. That forces a one‑time cleanup but accepts temporary gate failures.
ResourceLeak / JavaResourceLeak and severity WARNING are typical for 2024.x releases, but you must verify against your pinned image’s SARIF.Closeable/AutoCloseable not closed on some control‑flow path. It does not detect heap retention, off‑heap/native leaks, listener leaks, or cache eviction failures.Which exact linter image tag will you pin? (e.g., 2024.3, 2025.1, 2025.2-eap). The inspection ID and default severity must be confirmed against that specific version’s report before the gate config is final.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.