Skip to content

feat: add corpus subcommand to harper-cli#3013

Open
majiayu000 wants to merge 1 commit intoAutomattic:masterfrom
majiayu000:feat/issue-2629-corpus-mode
Open

feat: add corpus subcommand to harper-cli#3013
majiayu000 wants to merge 1 commit intoAutomattic:masterfrom
majiayu000:feat/issue-2629-corpus-mode

Conversation

@majiayu000
Copy link
Contributor

Summary

Adds a corpus subcommand to harper-cli that reads a file of marked sentences and detects false positives and negatives.

  • Lines prefixed with ✅ are expected to produce no lints (pass)
  • Lines prefixed with ❌ are expected to produce one or more lints (fail)
  • Supports optional --rule flag to restrict testing to a single linter
  • Supports inline `RuleName` syntax per line (as described in the issue)
  • Outputs colored [PASS]/[FAIL] per line with a summary
  • Exits non-zero if any expectations are violated (CI-friendly)
  • Blank lines and # comments are skipped

Example corpus file

# Test basic grammar rules
✅ This sentence is perfectly grammatical.
❌ This sentance has one or more problems.
❌ `AnA` This is an test.
✅ `SpellCheck` This sentence is correct.

Example output

[PASS] This sentence is perfectly grammatical.
[PASS] This sentance has one or more problems.
[PASS] This is an test.
[PASS] This sentence is correct.

4 total, 4 passed, 0 failed

Closes #2629

Test plan

  • cargo test -p harper-cli — all 18 tests pass (9 new corpus tests)
  • cargo fmt -- --check — clean
  • cargo clippy -- -Dwarnings — clean
  • cargo check -p harper-cli and cargo check -p harper-cli --features training — clean
  • cargo build -p harper-cli — clean

Add a `corpus` subcommand that reads marked sentences (✅ pass / ❌ fail)
and detects false positives and negatives. Supports optional `--rule`
flag to test a specific linter and inline `` `RuleName` `` syntax per line.

Closes Automattic#2629

Signed-off-by: majiayu000 <1835304752@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Corpus mode for harper-cli

1 participant