Bug
codelens dead-code reports false positives on this common Python pattern:
if condition:
return None
return {"key": "value"} # ← flagged as unreachable — but it IS reachable when condition is False
Evidence
PR #96 (fix for issue #93) found 7 of 18 reported 'unreachable' blocks in scripts/commands/analyze.py were this pattern. The worker 'fixed' them by adding else: after the early return — which Python style guides discourage — purely to satisfy the scanner, not because the code was actually unreachable.
Root Cause
Dead-code scanner in scripts/deadcode_engine.py (or equivalent) classifies any code following a return inside an if block as unreachable, without checking that the code is in the else branch (i.e., only reachable when the if condition is False).
Expected Behaviour
if x: return early_value\nreturn normal_value should NOT be flagged as unreachable. Only code after an unconditional return (not guarded by if) should be reported.
Impact
- False positives create noise and cause workers to make unnecessary 'style' refactors
- Adds
else: after early returns — an antipattern per PEP 8
Bug
codelens dead-codereports false positives on this common Python pattern:Evidence
PR #96 (fix for issue #93) found 7 of 18 reported 'unreachable' blocks in
scripts/commands/analyze.pywere this pattern. The worker 'fixed' them by addingelse:after the early return — which Python style guides discourage — purely to satisfy the scanner, not because the code was actually unreachable.Root Cause
Dead-code scanner in
scripts/deadcode_engine.py(or equivalent) classifies any code following areturninside anifblock as unreachable, without checking that the code is in theelsebranch (i.e., only reachable when theifcondition is False).Expected Behaviour
if x: return early_value\nreturn normal_valueshould NOT be flagged as unreachable. Only code after an unconditionalreturn(not guarded byif) should be reported.Impact
else:after early returns — an antipattern per PEP 8