Skip to content

Dead code identified via coverage analysis #390

@ldayton

Description

@ldayton

Summary

Coverage analysis reveals 87% coverage on src/parable.py (917 of 7285 lines never hit). Most uncovered code is rare edge cases or defensive fallbacks, but some is provably unreachable.

Command

uv run --with coverage coverage run tests/bin/run-tests.py
uv run --with coverage coverage report --show-missing src/parable.py

Truly Dead Code

Lines Code Why Impossible
398-400 ContextStack.get_current() Method defined but never called
402-404 ContextStack.push() Method defined but never called
406-410 ContextStack.pop() Method defined but never called
7858-7859 self.pos = start; return None, "" in _parse_arithmetic_expansion Loop exits when depth==0 OR at_end(). If depth!=0, must be at_end() → raises MatchedPairError. The return path requires depth!=0 AND NOT at_end(), which is impossible.

Likely Dead (defensive code for impossible internal states)

Lines Code Notes
962-966 Param expansion fallback Called after seeing ${ — should always succeed or raise
1005-1009 Command sub fallback Called after seeing $(
1021-1025 Deprecated arith fallback Called after seeing $[
1045-1050 Process sub fallback Called after seeing <( or >(

Just Untested (rare but valid bash)

  • 756-783: POSIX [=x=] equivalence classes and [.x.] collating symbols
  • 3406-3440: Bash 5.1+ ${ cmd; } brace command substitution
  • 7502-7622: Heredocs inside backtick command substitutions
  • Arithmetic to_sexp() methods: Nodes created but serialization not tested

Recommendation

  1. Delete ContextStack.get_current(), push(), pop() — unused
  2. Delete lines 7858-7859 — unreachable
  3. Consider removing defensive fallbacks (962-966, 1005-1009, etc.) or converting to assertions
  4. Add tests for ${ cmd; } syntax and POSIX bracket expressions if supporting them

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions