Skip to content

Detect removed CLI flags as breaking changes #60

Description

@razakadam74

Follow-up to #49 (deferred from PR #58, which shipped rules 1 + 4). Detect when a public CLI flag is removed and append a BREAKING CHANGE: footer.

Detection rule

For files in known bin/CLI locations (e.g. src/cli.ts, bin/**, anything in package.json bin), scan removed lines for flag patterns (--[a-z][a-z0-9-]*). If a flag appears in removed lines but not in added lines, treat it as breaking.

Output

  • Header gets !: feat(cli)!: …
  • Footer: BREAKING CHANGE: remove CLI flag --foo (or remove CLI flags --foo, --bar)
  • Combine with rule 1/4 wording when both fire: BREAKING CHANGE: remove exported rotate; remove CLI flag --legacy-mode

Why deferred

CLI-flag regex on deleted lines is fragile — flags appear in help text, error messages, comments, READMEs, test fixtures. Scoping to a known bin-file allowlist mitigates but is repo-specific; needs careful fixture coverage.

Implementation notes

  • New helper in src/analyze/breaking.ts (or split into breaking/cli.ts if it grows)
  • Bin-file detection probably belongs alongside path patterns in src/analyze/patterns.ts
  • Need at least 3 fixtures: clean removal, flag-renamed (removed in same diff as a new one), false-positive guard (flag mentioned only in help string)
  • Update docs/heuristics.md §3.5 with a new sub-table

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions