Unreachable code
This is how the comment reads inline, under the flagged line.
Why it matters
Code after a return never runs. It misleads readers and usually means a merge or edit went wrong.
What to do
Delete it, or move it before the return if it was meant to run.
Examples
return total; log(total);
log(total); return total;
What it catches
It reads the shape of the code: functions, blocks, loops and calls. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
function f() {
return 1;
go();
}
src/app.py
def f():
return 1
go()
Left alone
function f() {
go();
return 1;
}
Research
Unreachable code after `return`, `throw` or `raise`. Dead code is read and kept for nothing, and it hides which path is live.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"unreachable-code"
],
"severity": {
"unreachable-code": "low"
}
}
}
return/throwin the same block, so it never runs.