Remove code no control flow can reach, and the check that proves it - #4
Merged
Merged
Conversation
playwright_scraper.py carried fifteen lines whose `def` line had been lost. What remained -- a docstring and a `try: return page.content()` -- was indented at function level, so Python attached it to the end of _mask_credentials, after that function's own return. It parses, it imports, --help works, compileall passes and this suite was green, because unreachable code is still valid code. Nothing called it, and _content_when_settled directly below does the same job. The same fifteen lines are in six repos of this family, byte for byte, and have been since each one's first commit -- so this is inheritance rather than authorship, the shape CLAUDE.md §16 describes. The check added with it: a statement sitting after a return/raise/break/continue in the SAME block. Deliberately narrow, claiming nothing about reachability in general. The undefined-name walk beside it cannot catch this class, and correctly so -- it pools every binding in the file rather than tracking scopes, so `page` used inside the dead block resolves against the `page` parameter of a real function elsewhere in the module. That coarseness is the right trade for what that check is for, which is why this is a separate check rather than a tightening of it. Measured across the eighteen repos of this family: six problems reported, zero false positives. Verified by control -- appending a function whose body is `return 1` then `x = 2` turns the suite red. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
playwright_scraper.py carried fifteen lines whose
defline had beenlost. What remained -- a docstring and a
try: return page.content()--was indented at function level, so Python attached it to the end of
_mask_credentials, after that function's own return. It parses, it
imports, --help works, compileall passes and this suite was green,
because unreachable code is still valid code. Nothing called it, and
_content_when_settled directly below does the same job.
The same fifteen lines are in six repos of this family, byte for byte,
and have been since each one's first commit -- so this is inheritance
rather than authorship, the shape CLAUDE.md §16 describes.
The check added with it: a statement sitting after a
return/raise/break/continue in the SAME block. Deliberately narrow,
claiming nothing about reachability in general. The undefined-name walk
beside it cannot catch this class, and correctly so -- it pools every
binding in the file rather than tracking scopes, so
pageused insidethe dead block resolves against the
pageparameter of a real functionelsewhere in the module. That coarseness is the right trade for what
that check is for, which is why this is a separate check rather than a
tightening of it.
Measured across the eighteen repos of this family: six problems
reported, zero false positives. Verified by control -- appending a
function whose body is
return 1thenx = 2turns the suite red.Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code