Skip to content

software-writer: sweeping-dead-code reports helpers defined in test files as test-only #58

Open

Description

@SpiGAndromeda

plugins/software-writer/skills/sweeping-dead-code enumerates definitions in test files the same way as in production files. The Go search is --include='*.go' (references/tools/go.md), so it covers *_test.go. The Python search is --include='*.py', so it covers test_*.py. No step excludes test files or gives their definitions a class of their own.

The class table in SKILL.md:138 then assigns:

| `test-only` | Not reachable, not uncertain, and at least one test reference. |

Every helper, fixture factory or builder that is defined in a test file and called from tests meets this definition. Step 8 lists those rows under "test-only rows" (SKILL.md:157). They sit next to production code that only tests reach, which is the case the class exists for. Each such row also costs a refutation in Step 6.

The skill also has no per-stack definition of a test file. All five references/stacks/*/indirect-references.md say "references from test files do not count as callers" (line 3), and nothing says which files those are.

Relation to #48: the fix for #48 enumerates .bats files. It defines a bats test file as *.bats, setup_suite.bash, or a helper under the test directory, and it counts every reference inside a test file as a test reference. With that fix, every .bats helper that tests call is reported test-only. The fix applies the rule to bats only. This issue covers the other stacks and the class table.

Proposed fix:

  • Define the test files per framework in each *-referenced-by-name.md.
  • Classify a definition inside a test file by its own rule. For example: live when a test references it, dead when nothing references it. The test-only class would then keep its meaning: production code that only tests reach.
  • Change the class table, Step 6 and the Step 8 report to match.

Activity

  1. SpiGAndromeda commented on Nov 5, 2026

    @SpiGAndromeda
    ContributorAuthor

    A second case for the same test-file rule, found while reviewing #60.

    After #60, sweeping-dead-code/references/tools/bash.md defines:

    A bats test file is a .bats file, or another file under a directory that holds .bats files, unless production code sources or runs it.

    An entry script that sits next to its tests, for example install.sh beside install.bats, matches this rule. Users run install.sh; no production code sources or runs it. So the sweep treats it as a test file:

    • install.sh gets no file row (the Files line skips test files).
    • Every reference inside it is a test reference, so its top-level calls are not production references from root.
    • A function that only install.sh calls then comes out test-only instead of live. Step 6 refutation may or may not catch it.

    This consequence is reasoned from the rule text, not reproduced in a sweep run.

    It is the inverse of the helper case above: there a test helper lands in test-only, here a production entry script does. Both come from the same test-file definition, so one change to that definition and to the class table should cover both. An executable file or a file with a shebang in a test directory is a candidate signal for "entry script", but test helpers can be executable too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions