Skip to content

Commit eb546e5

Browse files
committed
refactor: stop asking the verb list whether a subject passes
The IMPERATIVES fast path was protecting exactly four words -- embed, feed, ping, speed -- and all four are already in NON_IMPERATIVE_LOOKALIKES, so it changed no verdict. Checked over the 2,333 distinct first words in git.git's history: zero differences, 576 rejections either way. Removing it leaves the morphology as the only thing that decides, and moves the lookalike check into _is_inflected where it belongs, since those words exist because of the suffix test rather than beside it. IMPERATIVES stays for the -s stem test, which genuinely needs it, but its header no longer tells contributors to treat a rejected subject as a missing entry. That contract is what #526 was about, and it is gone: an absent verb now costs a missed violation, never a false rejection.
1 parent f6ecd9f commit eb546e5

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

‎commit_check/engine.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,6 @@ def _validate_subject(self, subject: str) -> ValidationResult:
422422

423423
first_word = match.group(1).lower()
424424

425-
# Fast path, and the words whose spelling would trip the test below.
426-
if first_word in IMPERATIVES or first_word in NON_IMPERATIVE_LOOKALIKES:
427-
return ValidationResult.PASS
428-
429425
if self._is_inflected(first_word):
430426
self._print_failure(subject)
431427
return ValidationResult.FAIL
@@ -435,6 +431,8 @@ def _validate_subject(self, subject: str) -> ValidationResult:
435431
@classmethod
436432
def _is_inflected(cls, word: str) -> bool:
437433
"""Whether *word* carries past-tense, gerund or third-person marking."""
434+
if word in NON_IMPERATIVE_LOOKALIKES:
435+
return False
438436
if word.endswith(cls._INFLECTED):
439437
return True
440438
return cls._is_third_person(word)

‎commit_check/imperatives.py‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
# https://github.com/crate-ci/imperative/blob/master/assets/imperatives.txt
33
# and extended since.
44
#
5-
# Some of these are more commonly encountered as nouns, but leaving them out
6-
# rejects a subject that is written correctly, which is the worse failure: the
7-
# contributor has to reword something that was never wrong, and the only way
8-
# they learn which words are acceptable is by trial and error.
5+
# This is NOT an allow-list, and a subject is never rejected for being absent
6+
# from it. CC003 decides on the word's form (see SubjectImperativeValidator),
7+
# and the only thing this set is still consulted for is the stem test behind
8+
# the third-person -s rule: "fixes" is a verb because "fix" is in here, while
9+
# "status" is not, because dropping its -s leaves nothing this set contains.
910
#
10-
# For the same reason both spellings of every -ize/-ise verb are listed. A
11-
# project writing British English is not making a mistake.
12-
#
13-
# Additions are welcome and cheap. The list can only ever approximate "is this
14-
# an English imperative verb", so treat a rejected-but-correct subject as a bug
15-
# in this file rather than as something the author should work around.
11+
# So a missing verb costs a missed violation, never a false rejection -- there
12+
# is nothing to keep up with, and no need to send a patch adding the verb you
13+
# just used. Additions still help the -s rule catch more, and cost nothing.
1614

1715
IMPERATIVES = {
1816
"abort",

0 commit comments

Comments
 (0)