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 so we can reproduce the trailing-semicolon false positive.
- Assistant
Let me search more specifically for dead code related files.
- Assistant
Hmm, rg didn't find anything. Let me look in internal/analyzer
- Assistant
I'll inspect dead_code.go next to see how unreachable findings are produced.
- Assistant
Let me continue reading the dead code detector logic.
- Assistant
Let me continue reading analyzeDeadBlock and related functions.
- Assistant
I'll check how block code is extracted and how empty statements show up in the CFG.
- Assistant
Let me check getBlockCode and also searching for empty/pass statement handling.
- Assistant
I'll look up how empty statements and pass nodes are modeled in the parser.
- Assistant
rg is not available? Earlier it returned empty. Let me use grep.
- Assistant
I'll inspect the AST builder next for how semicolon-separated statements are handled.
- Assistant
I'll inspect unrecognized-node handling and CFG statement processing.
- Assistant
I'll reproduce the bug and inspect the CFG empty-statement nodes.
- Assistant
Need to set up Go environment.
- Assistant
Seems like the build might still be running or finished without output. Let me check.
- Assistant
Good, build succeeded. Let's reproduce.
- Assistant
Reproduced. Let me look at the JSON findings.
- Assistant
Confirmed. Let me look at the full finding structure and also understand how the CFG handles the empty statement.
- Assistant
I'll dump AST/CFG nodes for a trailing-semicolon sample to confirm the empty-statement shape.
- Assistant
Let me look at how CFG is built and how dead code tests work.
- Assistant
Let me look at processStatement for how return/raise create successor blocks for the empty statement after semicolon, and also what seimcolon node looks like.
- Assistant
Oops, wrong sed syntax.
- Assistant
I'll check how statement lists and semicolon separators are parsed into the AST.
- Assistant
Let me write a proper inspection program affirmatively using the test package approach, or just a unit test style script.
- Assistant
Let me also look at isTrivia and what tree-sitter does with
;. The tree-sitter python grammar has;as a statement separator, and empty statements might appear as nodes of type;. - Assistant
Can't import internal package from outside. I'll put a test file in the analyzer package temporarily.
- Assistant
I'll drop the bare
;case and re-run on valid trailing-semicolon samples. - Assistant
I'll check how findings are mapped into the domain model next.
- Assistant
Let me look at the mapping in dead_code_service.go
- Assistant
I'll inspect how unreachable blocks with statements are collected before implementing the filter.
- Assistant
Implementing the filter in the dead-code analyzer so empty
;/passstatements don't produce findings. - Assistant
I'll apply the empty-statement filter in dead_code.go now.
- Assistant
Next I'll add the statement helpers and simplify the no-op check.
- Assistant
Updating block helpers to ignore no-ops and introduce statement-slice variants.
- Assistant
Simplifying isNoOpStatement and verifying compilation.
- Assistant
There's an extra
}at line 259 — removing it. - Assistant
There's a duplicate comment line. Let me fix that.
- Assistant
There's still an extra
}on line 259. Let me fix it carefully. - Assistant
There's a duplicated function signature. Let me fix by removing line 262.
- Assistant
File looks clean. Compiling and running the inspect test plus dead-code tests.
- Assistant
Tests passed. Verifying the original repro is fixed and rechecking edge cases.
- Assistant
Trailing-semicolon-only case is fixed. Checking the mixed real-dead-code cases next.
- Assistant
Results look correct. Removing the temp test and running the full analyzer suite.
- Assistant
All tests passed. Reviewing the final diff before submit.
- Assistant
Formatting looks good. Submitting the fix.
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 →