Skip to content

prose_lint reads a bash ${#array[@]} as a comment opener #1646

Closed

Description

@ptr727

prose_lint.py's comment extractor reads a bash parameter expansion as the start of a comment, so a shell line inside a workflow run: block is judged as prose it is not.

Repro

import sys; sys.path.insert(0, ".github/actions/prose-gate")
from pathlib import Path
import prose_lint as pl
print(pl.extracted_comments(Path("x.yml"), ['            count=${#items[@]}']))
print(pl.extracted_comments(Path("x.yml"), ['            echo "::error::${#items[@]} open issues. Close them by hand."']))

Both return a comment body beginning items[@]}, because the extractor treats the # inside ${#...} as a comment opener. The second then fails comment-wrap with "two sentences on one comment line", against an echo string that is not a comment at all.

The quoted form, [ "${#items[@]}" -gt 1 ], returns no comment, so the false positive depends on where the expansion sits rather than on it being there. That makes the rule's answer inconsistent across two spellings of one construct.

Why it matters

Every .github/workflows/*.yml in this repository carries bash in a run: block, and counting an array is ordinary bash. The failure is a gate reporting a violation in text it has no business reading, and the workaround, avoiding the construct, is the gate deciding the code rather than the prose.

Scope

comment-case reads the same extraction, so it has the same exposure. The fix belongs in extracted_comments, which needs to skip a # that opens a parameter expansion, and to know it is inside a quoted string.

Found by

The local review pass on the branch adding .github/workflows/canonical-review-sweep.yml, which hit it on an echo line and worked around it rather than fixing the gate.

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

    gatescript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions