# The rules that `strings` finds by pattern in string literals shaped like sentences, in the format of `docs.txt`.
#
# A message is terse and often built from fragments, so these rules are narrower than those of docs. Each rejects
# only a shape that a sound message does not take, and each says what to write instead.
# A relative clause whose subject is something new, as in "U+00E9, which a click copies".
[which subject]
verdict = reject
pattern = ,\s+which\s+(?:(?:a|an|the|this|that|these|those|its|their|one|each|every|some|any|it|they|you|we)\s|X\b|[A-Z][A-Za-z]+\s+[a-z]|[a-z]+\s+(?:does|do|did|may|might|must|can|cannot|will|would|could|should)\s+not\b)
words = ", which"
advice = Say it directly, as in "because `c` narrows it" or "but `x` might not", since a clause with a new subject is read twice.
# A clause that only sets up a "which" that says the point, as in "`x` is a list, which may not be called".
[restated which]
verdict = reject
pattern = \b(?:is|are)\s+[^,]{1,80},\s+which\s+(?:is|are|may|might)\s+not\b
words = ", which"
advice = Say the point alone, as in "a list may not be called" for "`x` is a list, which may not be called".
# A negation put on the noun, as in "2**63 is no int64" or "sets no field".
[noun negation]
verdict = reject
pattern = (?i)\b(?:is|are|was|were)\s+no\s+(?!longer\b|more\b|less\b|one\b|need\b)[a-z]|\b(?:names|holds|reads|carries|spells|bounds|writes|lists|sets|gives|says|states|knows|declares|answers|serves|keeps)\s+no\b
words = s no|e no
advice = Put the negation on the verb, as in "is not an int64", or start with what is missing, as in "No name to rename here".
# A "what" that stands for a thing, as in "wrote what is not text" or "what is free is the run's".
[vague what]
verdict = reject
pattern = (?i)(?:\b[a-z]+\s+what\s+(?:is|was|are|were)\b|^what\s+(?:is|was|are|were)\s+[a-z]+\s+(?:is|was|are|were)\b|\bis\s+what\b)(?![^?]*\?)
words = what is|what was|what are|what were|is what
advice = Name the thing, as in "wrote output that is not text" for "wrote what is not text".
# A sentence whose subject is a generic thing, which states a rule or an invariant as a fact, as in
# "a dict's key is a string literal" for an error or "a parameter's name is interned" for an invariant.
# A clause after a comma and a conjunction starts as a sentence does.
[generic statement]
verdict = reject
pattern = (?:^|[.!?;]\s+|,\s+(?:but|and|so|since|because|while|where|though|although|or)\s+)(?i:(?:an?|each)\s+\w+'s\s+(?:[\w-]+\s+){0,3}?(?:is|are|has|have|takes|take)\s+(?:an?\s+\w|its\b|[a-z]+ed\b|(?:known|read|shown|given|kept|found|done|set|built|run|written|taken)\b|(?:in|on|at|inside|outside|within)\s))
words = 's
words = "a |an |each "
advice = Say what is wrong with this value, as in "`k` is not a string literal", or the rule as a permission, as in "a dict's key must be a string literal".
# A sentence that starts with an "It" or a "There" whose referent is elsewhere, as in "It is over 64 MB".
[pronoun opener]
verdict = reject
pattern = (?:^|[.!?]\s+)(?:It|There)\s+(?:is|are|was|were|would|will|has|does|can|cannot|could)\b
words = "it |there "
advice = Start with the thing that the sentence is about, since the reader does not know what "It" or "There" stands for.
# An action narrated as what an input does, as in "a click copies it".
[narrated input]
verdict = reject
pattern = (?i)\b(?:a|the|each)\s+(?:click|double-click|right-click|tap|press|drag|hover)\s+(?:copies|opens|closes|shows|selects|reveals|runs|saves|deletes|moves|does|will)\b
words = click|tap|press|drag|hover
advice = Name the action, as in "Click to copy".
# A word that adds length but nothing that the reader needs.
[filler]
verdict = reject
pattern = (?i)\b(?:successfully|please note|in order to|feel free to|simply)\b|(?:^|[.!?]\s+)Note that\b
words = successfully|please note|in order to|feel free|simply|note that
advice = Delete it, as in "Saved" for "Successfully saved" and "to" for "in order to".
# A failure that does not say what failed.
[empty failure]
verdict = reject
pattern = (?i)\b(?:something went wrong|an? (?:unexpected |unknown )?error (?:has )?occurred|unexpected error)\b
words = went wrong|occurred|unexpected error
advice = Say what failed and, where it helps, what to do next.