Skip to content

harden(branding-lint): clap-aware sub-rule to catch /// doc-comment leaks before they reach --help #75

Closed

Description

@thehoff

Problem

The allowlist-style branding lint (#67) has a known weakness: the rustdoc-comment mention (///) rule accepts ALL /// lines because hundreds of legitimate project-name mentions exist. The trade-off: NEW user-visible RTK phrasings in clap /// doc comments (which become --help output) silently pass the lint and only fail via FORBIDDEN_TOKENS if the exact phrasing already lives in the regression-pin list.

This is how RTK savings, RTK adoption, RTK equivalent, RTK artifacts, RTK and native (v0.1.7 round-3 sweep) all reached production before being caught.

Goal

Add a clap-aware sub-rule to `tests/branding_lint.rs` that scans `///` lines immediately preceding clap macros — `#[derive(Parser)]`, `#[command(...)]`, `#[arg(...)]`, `#[clap(...)]`, struct fields used as clap targets — and rejects case-insensitive `\brtk\b` unless the line is explicitly allowlisted with `// branding-lint: allow legacy`.

Detection heuristic

A `///` line N is "clap-doc-adjacent" if any of:

  • Line N+k (for k=1..3, skipping blank lines and other `///` lines) starts with `#[` and contains `Parser`, `Subcommand`, `Args`, `ValueEnum`, `arg(`, `command(`, `clap(`
  • Or: walk forward to the next non-`///` non-blank line; if it's a `#[arg]` / `#[command]` / `pub fn` inside an `impl` block on a clap-derived struct, the doc comment leaks to `--help`.

Definition of done

  • New `branding_lint_clap_doc_comments_fail_on_rtk` test in `tests/branding_lint.rs`
  • Audit existing clap docs in `src/` for current violations; fix them all (rebrand to `ContextCrawler` equivalent) before merging
  • Confirm test fails on a synthetic `/// RTK foo\n#[arg(long)]` fixture (sanity self-test in the test itself, like the existing `leak_simulations` block)
  • `cargo test --test branding_lint` passes on the branch

Why

v0.1.8 → v0.1.9 cycle had 3 user-report-triggered hotfix rounds for clap-help leaks. This closes the source instead of adding one FORBIDDEN_TOKENS row per discovered leak.

Out of scope

  • KNOWN_UNBRANDED_TEXT_NEEDLES debt reduction (separate issue)
  • Merge-driver / .gitattributes infrastructure (separate issue)
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