Skip to content

fix(linting): don't flag sentence-initial "Backup" before a modal - #3794

Open
AnayGarodia wants to merge 3 commits into
Automattic:masterfrom
AnayGarodia:fix/backup-sentence-initial-3661
Open

fix(linting): don't flag sentence-initial "Backup" before a modal#3794
AnayGarodia wants to merge 3 commits into
Automattic:masterfrom
AnayGarodia:fix/backup-sentence-initial-3661

Conversation

@AnayGarodia

Copy link
Copy Markdown

Disclaimer: This PR was produced with LLM assistance, reviewed and verified by me before submission (per Harper's agent-PR policy).

What

Fixes #3661. PhrasalVerbAsCompoundNoun flagged sentence-initial "Backup" and suggested "back up" in sentences like "Backup will run automatically."

Why

The rule already treats a following present/simple-past/past verb form as evidence that the compound noun is the subject (ItsFollowedByVerb), e.g. "Backup is scheduled" and "Backup has finished" are correctly left alone. But modal/auxiliary verbs weren't covered, so "Backup will run", "Backup can be restored", and "Backup should complete" were still flagged.

How

Add next_tok.kind.is_auxiliary_verb() to the existing "followed by a verb" check. Modals (will/can/should/…) are tagged as auxiliary verbs, so this closes the gap without new control flow. True positives are unaffected — they are followed by a preposition or end of clause ("I backup", "you checkout"), not by an auxiliary.

Testing

Added dont_flag_backup_before_modal_3661. Full rule suite green, no regressions:

cargo test -p harper-core --lib phrasal_verb_as_compound_noun   # 65 passed, 1 ignored
cargo fmt -- --check                                            # clean
cargo clippy -- -Dwarnings ...                                  # clean

Compatibility

Narrows one false positive; no public API or other-input behavior change.

Copilot AI review requested due to automatic review settings July 8, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hippietrail hippietrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this but there are subtle things that the coding AIs are not yet good at in relation to grammar checking.


// If the next word is a present or simple past verb form compatible with a 3rd person singular noun
// If the next word is a present or simple past verb form compatible with a 3rd person singular noun,
// or an auxiliary/modal verb ("Backup will run", "Backup can be restored"), the word is the subject noun.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an assumption that a modal verb can't also be used after a phrasal verb. These kinds of assumptions need to be verified. AIs are terrible at this. I use Google manually and I think they are not able to even if they hadn't already "made up their minds". Here's what I found:

  • The data you back up should be determined by how important it is to you
  • The number of files you back up can affect both the time required to run the backup and the size of the resulting backup.
  • But if your estate is going to attract inheritance tax, any gift you leave to Back Up will be deducted from your estate before any tax liability is calculated.
  • The photos you back up might capture quiet moments at home
  • Swimming to the bottom, touching your elbows to a fresh fuel canister, and immediately swimming back up would probably be enough to kill you.
  • The data you can back up may vary depending on your operating system or phone version.

These all read very naturally and give the impression that legit use of "back up" followed by a modal is common

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 622a87a: the modal signal no longer fires mid-sentence — it's restricted to sentence-initial position (maybe_prev_tok.is_none()), i.e. the "Backup will run" case. All six of your back-up-before-modal sentences are in the test suite as of aad85f1 and stay unflagged.

@AnayGarodia

Copy link
Copy Markdown
Author

fair caution. the subtle bug you're pointing at: I put the modal check in the general ItsFollowedByVerb block, so it fired mid-sentence too — but the test only justifies the sentence-initial case. mid-sentence "will/can/might" are as often nouns as modals, so that was broader than the reasoning behind it.

tightened it: the auxiliary/modal signal now only applies with nothing before the word (maybe_prev_tok.is_none()), which is the "Backup will run" case the test covers. the existing 3rd-person/past-form checks stay as they were. still suppression-only, no corpus snapshot changes.

if there's a specific construction you had in mind that's still off, point me at it — happy to add it as a test.

@hippietrail

Copy link
Copy Markdown
Collaborator

fair caution. the subtle bug you're pointing at: I put the modal check in the general ItsFollowedByVerb block, so it fired mid-sentence too — but the test only justifies the sentence-initial case. mid-sentence "will/can/might" are as often nouns as modals, so that was broader than the reasoning behind it.

tightened it: the auxiliary/modal signal now only applies with nothing before the word (maybe_prev_tok.is_none()), which is the "Backup will run" case the test covers. the existing 3rd-person/past-form checks stay as they were. still suppression-only, no corpus snapshot changes.

Yep if you've already got something like maybe_prev_tok that's a good approach. When you don't already have it, there's the AnchorStart expression.

if there's a specific construction you had in mind that's still off, point me at it — happy to add it as a test.

I'm on the road right now so might not have the brain space to dedicate to think it through fully but I'll definitely let you know if one does pop into my head.

@hippietrail hippietrail left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More tests would help a lot.

);
}

#[test]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it was in this thread where I posted half a dozen counterexamples earlier? Those were real-word sentences found by Googling so I would add at least one of them and in this case possibly all of them as additional tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in aad85f1: all six are in dont_flag_back_up_verb_before_modal_3661, alongside still-flagged guards pinning the assumption ("Backup your files daily." -> "Back up your files daily.", "You should backup before upgrading." -> "back up").

@AnayGarodia

Copy link
Copy Markdown
Author

added the tests. pulled in all six of your back-up-before-modal sentences as real-world cases — they stay unflagged, as they should.

also widened the sentence-initial check past "will" to "can"/"should", and added the bit that actually pins down the assumption: a bare "backup" with no modal after it still gets flagged ("Backup your files daily" → "Back up your files daily", "You should backup before upgrading" → "back up"). so the exception only fires sentence-initial with a modal right after, and real errors still come through.

one honest note: your six are already two words, so the rule never considers them candidates in the first place — they pass trivially. i kept them because they document that "back up" + modal is legit, but the sentence-initial and still-flagged cases are the ones that actually exercise the change. happy to drop the trivial ones if you'd rather.

pratyushsinghal7 and others added 3 commits July 17, 2026 12:31
PhrasalVerbAsCompoundNoun rewrote "Backup" to "back up" in sentences
like "Backup will run automatically." The rule already treats a
following present/past verb form as a signal that the word is the
subject noun, but modal/auxiliary verbs ("will", "can", "should") were
not covered, so a compound noun followed by a modal was still flagged.
Add is_auxiliary_verb() to that check.

Closes Automattic#3661.
…-initial

an auxiliary/modal after the word (e.g. "Backup will run") signals a preceding
subject noun, but only with nothing before it. mid-sentence will/can/might are
just as often nouns, so gate the modal case on maybe_prev_tok.is_none() to match
what the test actually claims. refs Automattic#3661.
…ption

verify the Automattic#3661 modal exception with real data rather than a single case:
- sentence-initial "Backup" before will/can/should stays unflagged (the fix)
- six real "back up" + modal sentences (from @hippietrail's review) stay
  unflagged, documenting that a following modal isn't itself noun evidence
- a genuine "backup" verb error with no modal after it is still flagged, so
  the exception stays narrow. refs Automattic#3661.
@AnayGarodia
AnayGarodia force-pushed the fix/backup-sentence-initial-3661 branch from 3bce11a to aad85f1 Compare July 17, 2026 19:38
@AnayGarodia

AnayGarodia commented Jul 23, 2026

Copy link
Copy Markdown
Author

@hippietrail Following up after the earlier revision: the modal guard remains limited to sentence-initial backup cases, and the reviewer-provided real-world back up + modal examples were added as regression tests. Could you please re-review?

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.

"Backup" is flagged to become "back up" when it's the first word of a sentence and followed by a modal verb

4 participants