chainlint: reduce annotation noise-factor

When chainlint detects a problem in a test definition, it highlights the offending code with a "?!...?!" annotation. The rather curious "?!" decoration was chosen to draw the reader's attention to the problem area and to act as a good "needle" when using the terminal's search feature to "jump" to the next problem. Later, chainlint learned to color its output when sent to a terminal. Problem annotations are colored with a red background which stands out well from surrounding text, thus easily draws the reader's attention. Together with the preceding change which gave all problem annotations a uniform "LINT:" prefix, the noisy "?!" decoration has become superfluous as a search "needle" so omit it when output is colored. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Sep 10, 2024 at 00:10 UTC a13ff419636c65321aee71ed000574a4a607be56
2 files changed +3 -2
t/chainlint.pl
+2 -1
@@ -651,6 +651,7 @@ sub check_test {
651 $self->{nerrs} += @$problems;
652 return unless $emit_all || @$problems;
653 my $c = main::fd_colors(1);
654 + my ($erropen, $errclose) = -t 1 ? ("$c->{rev}$c->{red}", $c->{reset}) : ('?!', '?!');
655 my $start = 0;
656 my $checked = '';
657 for (sort {$a->[1]->[2] <=> $b->[1]->[2]} @$problems) {
@@ -659,7 +660,7 @@ sub check_test {
660 my $err = format_problem($label);
661 $checked .= substr($body, $start, $pos - $start);
662 $checked .= ' ' unless $checked =~ /\s$/;
662 - $checked .= "$c->{rev}$c->{red}?!LINT: $err?!$c->{reset}";
663 + $checked .= "${erropen}LINT: $err$errclose";
664 $checked .= ' ' unless $pos >= length($body) ||
665 substr($body, $pos, 1) =~ /^\s/;
666 $start = $pos;
t/test-lib.sh
+1 -1
@@ -1606,7 +1606,7 @@ if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
1606 test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0
1607 then
1608 "$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" ||
1609 - BUG "lint error (see '?!...!? annotations above)"
1609 + BUG "lint error (see 'LINT' annotations above)"
1610 fi
1611
1612 # Last-minute variable setup