From e44f15ba3ee873b5df5e8e5d8cc018df288472ef Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 10 Sep 2024 00:10:12 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- t/chainlint/nested-loop-detect-failure.expect | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/chainlint/nested-loop-detect-failure.expect') diff --git a/t/chainlint/nested-loop-detect-failure.expect b/t/chainlint/nested-loop-detect-failure.expect index c13c4d2f90..b4aaa621a2 100644 --- a/t/chainlint/nested-loop-detect-failure.expect +++ b/t/chainlint/nested-loop-detect-failure.expect @@ -2,8 +2,8 @@ 3 do 4 for j in 0 1 2 3 4 5 6 7 8 9; 5 do -6 echo "$i$j" >"path$i$j" ?!LOOP?! -7 done ?!LOOP?! +6 echo "$i$j" >"path$i$j" ?!LINT: missing '|| return 1'?! +7 done ?!LINT: missing '|| return 1'?! 8 done && 9 10 for i in 0 1 2 3 4 5 6 7 8 9; @@ -18,7 +18,7 @@ 19 do 20 for j in 0 1 2 3 4 5 6 7 8 9; 21 do -22 echo "$i$j" >"path$i$j" ?!LOOP?! +22 echo "$i$j" >"path$i$j" ?!LINT: missing '|| return 1'?! 23 done || return 1 24 done && 25 -- cgit v1.2.3