Automattic / Automattic/harper

False positive: `ItsPossessive` flags `it's` heading a complement clause ("I have heard it's good news")

Open
#4,038 4 comments 0 reactions 0 assignees View on GitHub
bug false-positive harper-core linting
Dominant language
Rust
Stars
15.4k
Forks
627
Avg merge
1d 12h
Merged PRs (30d)
106

Description

**What got flagged?**

`ItsPossessive` flags `it's` in "I have heard it's good news."

```
harper-cli lint "I have heard it's good news."

1 │ I have heard it's good news.
│ ──┬─
│ ╰─── [Agreement::ItsPossessive] (pri 31): Use the possessive
│ pronoun `its` (without an apostrophe) to show ownership.
```

**Why is this incorrect?**

Here `it's` genuinely means "it is". The sentence is "I have heard \[that\] it is good news." Rewriting it to `its` produces "I have heard its good news.", which changes the meaning.

The `mid_sentence` expression in `harper-core/src/linting/its_possessive.rs` matches `VERB`/`ADP` + `it's` + optional `ADJ` + `NOUN`. In this sentence "heard" is the `VERB`, "good" the `ADJ` and "news" the `NOUN`, so the pattern matches even though `it's` is heading a complement clause rather than modifying "news".

**Example of correct usage:**

* "I have heard it's good news."
* "They said it's bad weather today."

Contrast with the true positives the rule is aimed at, which still work correctly:

* "The engine lost it's compression." -> should be `its`
* "I admired the sculpture for it's intricacy." -> should be `its`

**Notes**

Found while working on Automattic/harper#3627 / [#4035](). This reproduces on `master` and is not caused by that change, which only affects a preceding `has`/`had`.

Contributor guide

Open the contributing guide

Research direction

Start by reading harper-core/src/linting/its_possessive.rs, especially the mid_sentence expression, and reproduce the report with harper-cli lint "I have heard it's good news.". Done means the complement-clause example is no longer flagged while the listed possessive examples still produce the intended result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.