prosecop 0.1.0

Checks identifiers and doc comments against a repository's house style
# The rules that `docs` finds by pattern in doc comments, docstrings and Markdown, in the order they are reported.
#
# - `let NAME = VALUE` defines a value that `{NAME}` stands for in a later pattern or words.
# - `[NAME]` starts a rule, then each of its fields is a line of `KEY = VALUE`:
#   - `verdict`: `reject`, or `warn` for a rule that finds a broken rule too loosely to reject.
#   - `markdown`: `true` where Markdown and plain text are checked for the rule, not only docs. It is `false` by default.
#   - `pattern`: the regular expression of a match, which may have negative lookaheads.
#   - `advice`: what to do about a match, which the check of strings prints once for each rule that it finds.
#   - `words`: a group of words separated by `|`, one of which every match has, in ASCII without case. A rule may
#     have several groups, and a line without a word of each one is skipped without running the pattern.
# - A VALUE in double quotes is the text between them, which keeps its spaces at either end.

# The verbs of a negative relative clause and of an object relative clause.
let negative_verbs = reads|writes|names|holds|spells|says|bounds|takes|sets|carries|declares|passes|knows|gives|moves|decides|lists|pins|keeps|serves|calls|sizes|states|asks|uses|makes|binds
let object_verbs = reads|writes|names|holds|spells|says|bounds|takes|sets|carries|declares|passes|knows|gives|lays|answers|asks|keeps|serves|sends|quotes|publishes|lists|prices|offers|calls|makes|builds|returns|resolves

# The constructions forbidden by house style, which Markdown is checked for too.

[no-negation]
verdict = reject
markdown = true
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|\bnothing\s+of\b
words = s no|e no|nothing of

[negative relative]
verdict = reject
markdown = true
pattern = (?i)\b(?:no|nothing|none)\s+(?:[a-z`'_.]+\s+){0,2}?(?:{negative_verbs})\b(?!\s+(?:a|an|the|its|this|that|any|every|each|to|of|in|on)\b)
words = "no |nothing |none "
words = {negative_verbs}

[object relative]
verdict = reject
markdown = true
pattern = (?i)\b(?:a|an|the|each|every)\s+[a-z]+(?:'s)?\s+(?:a|an|the|its|each|every|our)\s+[a-z]+(?:'s)?\s+(?:[a-z]+\s+)?(?:{object_verbs})\b(?!\s+(?:a|an|the|its|to|of|in|on|by|as|from|with|it|them|one|each|every|that|this|what|where|which|whether|how|nothing|no)\b)
words = {object_verbs}

[as clause]
verdict = reject
markdown = true
pattern = (?i)\bas\s+(?:[a-z`'\[\]_.]+\s+){1,3}?(?:spells?|writes?|says?|names?|reads?|shows?|holds?|quotes?)\s+(?:it|them)\b
words = "as "
words = spell|write|say|name|read|show|hold|quote

[vague what]
verdict = reject
markdown = true
pattern = (?i)\b(?:what\s+is|is\s+what)\b
words = what is|is what

[verbed of it]
verdict = reject
markdown = true
pattern = (?i)\b(?:[a-z]+ed|wrote|took|made|ran|found|held|kept|sent|built|told|gave|saw|chose|left|read|set|put)\s+(?:a|an|the|each|every|one|some)\s+(?!whole\b|rest\b)[a-z]+\s+of\s+it\b
words = " of it"

# The rules of docs alone.

[banned word]
verdict = reject
pattern = (?i)\b(?:hold|holds|held|handed|made(?!-up\b)|spells|spelled|beside)\b
words = hold|held|handed|made|spell|beside

[possessive chain]
verdict = reject
pattern = \b(?:its|[A-Za-z_]+'s)\s+(?:[A-Za-z_-]+\s+)?[A-Za-z_-]+'s\b
words = 's

[colon fragment]
verdict = warn
pattern = \w: [a-z]+ (?:by|in|of|at)\b
words = ": "
words = " by| in| of| at"