Skip to content

Commit a13ff41

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e44f15b commit a13ff41

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

t/chainlint.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ sub check_test {
651651
$self->{nerrs} += @$problems;
652652
return unless $emit_all || @$problems;
653653
my $c = main::fd_colors(1);
654+
my ($erropen, $errclose) = -t 1 ? ("$c->{rev}$c->{red}", $c->{reset}) : ('?!', '?!');
654655
my $start = 0;
655656
my $checked = '';
656657
for (sort {$a->[1]->[2] <=> $b->[1]->[2]} @$problems) {
@@ -659,7 +660,7 @@ sub check_test {
659660
my $err = format_problem($label);
660661
$checked .= substr($body, $start, $pos - $start);
661662
$checked .= ' ' unless $checked =~ /\s$/;
662-
$checked .= "$c->{rev}$c->{red}?!LINT: $err?!$c->{reset}";
663+
$checked .= "${erropen}LINT: $err$errclose";
663664
$checked .= ' ' unless $pos >= length($body) ||
664665
substr($body, $pos, 1) =~ /^\s/;
665666
$start = $pos;

t/test-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
16061606
test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0
16071607
then
16081608
"$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" ||
1609-
BUG "lint error (see '?!...!? annotations above)"
1609+
BUG "lint error (see 'LINT' annotations above)"
16101610
fi
16111611

16121612
# Last-minute variable setup

0 commit comments

Comments
 (0)