Skip to content

fix(core): catch less common that comparisons#3763

Open
terminalchai wants to merge 1 commit into
Automattic:masterfrom
terminalchai:fix-that-than-common-comparison
Open

fix(core): catch less common that comparisons#3763
terminalchai wants to merge 1 commit into
Automattic:masterfrom
terminalchai:fix-that-than-common-comparison

Conversation

@terminalchai

Copy link
Copy Markdown

AI/agent assistance was used to prepare this patch.

This fixes #3736 by extending the existing ThatThan linter to catch the reported less common that mp3 comparison shape without enabling the broader more/less adjective that pattern that already has known false positives.

The matcher now supports the existing comparative-adjective pattern and a constrained more/less common that <token containing a digit> pattern. I also updated match_to_lint to locate the matched that token dynamically, then added true-positive tests for the reported MP3 comparison and false-positive tests for valid less/more common that ... clauses.

Verification:

  • cargo test -p harper-core that_than -- --nocapture
  • cargo run -p harper-cli -- lint "This format is way less common that mp3."
  • cargo run -p harper-cli -- lint "It is less common that people configure this manually."
  • cargo fmt -- harper-core\src\linting\that_than.rs
  • git diff --check

@hippietrail

Copy link
Copy Markdown
Collaborator

I'm pretty sure this is going to have false positives along the lines of:

  • it's less common that mp3 players break than CD players

@terminalchai terminalchai force-pushed the fix-that-than-common-comparison branch from 581d299 to 0516606 Compare July 5, 2026 16:05
@terminalchai

Copy link
Copy Markdown
Author

Good catch, thanks. I narrowed this so the new branch only matches the digit-bearing comparison target at the end of the chunk/sentence, with optional trailing punctuation. That keeps the reported less common that mp3 case covered but avoids cases like it's less common that mp3 players break than CD players.

I added your example as a no-lint regression test and reran:

  • cargo test -p harper-core --lib that_than -- --nocapture
  • CLI lint checks for the reported typo and the false-positive example
  • git diff --check

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.

False negative missing "that" as a typo for "than"

2 participants