]> git.ipfire.org Git - thirdparty/git.git/commit
chainlint: make error messages self-explanatory
authorEric Sunshine <sunshine@sunshineco.com>
Tue, 10 Sep 2024 04:10:12 +0000 (00:10 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Sep 2024 17:01:40 +0000 (10:01 -0700)
commite44f15ba3ee873b5df5e8e5d8cc018df288472ef
tree8718076d76999f67df5c99c70f6a211709976c45
parent588ef84ecef2c9782598529ba6511d4cb72ec158
chainlint: make error messages self-explanatory

The annotations emitted by chainlint to indicate detected problems are
overly terse, so much so that developers new to the project -- those who
should most benefit from the linting -- may find them baffling. For
instance, although the author of chainlint and seasoned Git developers
may understand that "?!AMP?!" is an abbreviation of "ampersand" and
indicates a break in the &&-chain, this may not be obvious to newcomers.

The "?!LOOP?!" case is particularly serious because that terse single
word does nothing to convey that the loop body should end with
"|| return 1" (or "|| exit 1" in a subshell) to ensure that a failing
command in the body aborts the loop immediately. Moreover, unlike
&&-chaining which is ubiquitous in Git tests, the "|| return 1" idiom is
relatively infrequent, thus may be harder for a newcomer to discover by
consulting nearby code.

Address these shortcomings by emitting human-readable messages which
both explain the problem and give a strong hint about how to correct it.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
44 files changed:
t/chainlint.pl
t/chainlint/arithmetic-expansion.expect
t/chainlint/block.expect
t/chainlint/broken-chain.expect
t/chainlint/case.expect
t/chainlint/chain-break-false.expect
t/chainlint/chained-block.expect
t/chainlint/chained-subshell.expect
t/chainlint/command-substitution.expect
t/chainlint/complex-if-in-cuddled-loop.expect
t/chainlint/cuddled.expect
t/chainlint/for-loop.expect
t/chainlint/function.expect
t/chainlint/here-doc-body-indent.expect
t/chainlint/here-doc-body-pathological.expect
t/chainlint/here-doc-body.expect
t/chainlint/here-doc-double.expect
t/chainlint/here-doc-indent-operator.expect
t/chainlint/here-doc-multi-line-command-subst.expect
t/chainlint/here-doc-multi-line-string.expect
t/chainlint/if-condition-split.expect
t/chainlint/if-in-loop.expect
t/chainlint/if-then-else.expect
t/chainlint/inline-comment.expect
t/chainlint/loop-detect-failure.expect
t/chainlint/loop-in-if.expect
t/chainlint/multi-line-string.expect
t/chainlint/negated-one-liner.expect
t/chainlint/nested-cuddled-subshell.expect
t/chainlint/nested-here-doc.expect
t/chainlint/nested-loop-detect-failure.expect
t/chainlint/nested-subshell-comment.expect
t/chainlint/nested-subshell.expect
t/chainlint/not-heredoc.expect
t/chainlint/one-liner-for-loop.expect
t/chainlint/one-liner.expect
t/chainlint/pipe.expect
t/chainlint/semicolon.expect
t/chainlint/subshell-here-doc.expect
t/chainlint/subshell-one-liner.expect
t/chainlint/token-pasting.expect
t/chainlint/unclosed-here-doc-indent.expect
t/chainlint/unclosed-here-doc.expect
t/chainlint/while-loop.expect