ISSUE DESCRIPTION [BUG][auto] deadcode-trailing-semicolon-empty-stmt: trailing-semicolon…
- User
ISSUE DESCRIPTION
[BUG][auto] deadcode-trailing-semicolon-empty-stmt: trailing-semicolon empty statement reported as unreachable warning (code=";", col 0-0)
Description
The dead-code detector emits a
warning-severityunreachable_branchfinding whosecodefield is a bare;(an empty statement) whenever areturn/raisestatement is written with a trailing semicolon. In Python a trailing;is a valid (if unusual) statement separator, soraise X;parses asraise Xfollowed by an empty statement. That empty statement is technically unreachable, but reporting a no-op as actionable dead code is pure noise — there is nothing for the user to "remove" beyond a stylistic semicolon, and the finding points at literal;with an impossible0-0column range.Repro
Minimal synthetic Python (
semi_repro.py):def f(x): if x is None: raise ValueError("nope"); return x def g(y): return y;Run:
pyscn analyze --json --no-open semi_repro.pyActual output
Two dead-code findings (from the generated JSON report):
{"function_name": "f", "location": {"start_line": 3, "start_column": 0, "end_column": 0}, "code": ";", "reason": "unreachable_branch", "severity": "warning"} {"function_name": "g", "location": {"start_line": 8, "start_column": 0, "end_column": 0}, "code": ";", "reason": "unreachable_branch", "severity": "warning"}Expected behavior
Empty statements (the no-op produced by a trailing
;) should be filtered out before emitting dead-code findings — they carry no actionable signal. At most this is a low-severity style hint ("redundant trailing semicolon"), not awarning-severity unreachable-code finding. The0-0column range is also a symptom of the synthetic/empty node being reported.Priority rationale
P2 (visible but bounded inaccuracy, per the FP-audit rubric): the gist isn't wrong (the
;truly follows a terminating statement), but the output is misleading — awarningthat points at literal;with a0-0column range reads as a real defect when there is none. Bounded impact: only fires on the rare trailing-semicolon style.Suggested fix (good first issue)
Skip CFG nodes that correspond to empty statements (Python
pass-equivalent / bare;separators) when collecting unreachable-branch findings in the dead-code analyzer.
pyscn version:
v1.22.5(commitbac7f16)Found via the FP-audit skill in repo
bioconvert/bioconvert@92f4655(4 real occurrences:bioconvert/utils/biocode/gff.py:618,tbl.py:114,things.py:753and:780).Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /pyscn, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and locating the dead-code analyzer that emits unreachable findings for trailing semicolons.
- Assistant
Let me search more specifically for dead code related files.
- Assistant
Interesting - rg didn't find anything, maybe there's an issue with the tool. Let me try differently.
- Assistant
I'll inspect the dead-code analyzer and how it maps unreachable blocks into findings.
- Assistant
Let me continue reading the dead_code.go file, especially the part that converts blocks to findings.
- Assistant
Let me continue reading analyzeDeadBlock and how code is extracted.
- Assistant
I'll look at statement representation and how empty statements / trailing semicolons appear in the CFG.
- Assistant
Next I'll check how empty/expression statements are handled and try to reproduce the bug.
- Assistant
The finding's
codeis literally;, so I'll track down how empty/semicolon statements are parsed into AST nodes. - Assistant
I'll inspect the AST builder's handling of unknown nodes and Keeping statements after terminators.
- Assistant
Let me see the default case of buildNode
- Assistant
I'll build the tool and run a minimal reproduction for trailing-semicolon dead-code findings.
- Assistant
Need to set GOPATH
- Assistant
Need GOCACHE and HOME too.
- Assistant
Build succeeded — now I'll reproduce the trailing-semicolon findings with a synthetic file.
- Assistant
Let me check the JSON report for the dead code findings.
- Assistant
Confirmed. Let me look at the full finding details and then also understand what the node type is for ";".
- Assistant
I'll inspect how the ";" token becomes a statement and how locations are set for those empty nodes.
- Assistant
The escaping got weird with quotes. Let me be more careful.
- Assistant
I'll check the existing dead-code tests and how CFG builder treats
;nodes and pass statements. - Assistant
So when there's a ";" after a raise/return, the ";" is treated as a statement added to the unreachable block.
- Assistant
I'll implement filtering for empty
;statements in the dead-code path and mirror how domain findings are built. - Assistant
I'll implement empty-statement filtering in the dead-code analyzer and add a small unit test via a temp script.
- Assistant
I'll update
DetectandanalyzeDeadBlockto ignore empty;statements when building findings. - Assistant
I'll harden
analyzeDeadBlockand teach the helpers to skip empty;statements. - Assistant
There's leftover duplicate code from the old function — removing it next.
- Assistant
Next I'll add the helper functions and update the block code/location helpers.
- Assistant
I'll replace getBlockStartLine, getBlockEndLine, getBlockCode and add the helpers after analyzeDeadBlock or near getBlockCode.
- Assistant
Rebuilding and verifying the reproduction is fixed.
- Assistant
Dead code is clean now. I'll verify JSON output and dead-code-after-semicolon edge cases next.
- Assistant
3 issues, 2 critical for mixed case. Let me see the findings.
- Assistant
Mixed-case behavior looks right; next I’ll run the dead-code unit tests.
- Assistant
Tests pass. Let me also run service-level dead code tests.
- Assistant
All tests passed. I'll check the diff and confirm the final state of the changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →