Skip to content

Commit ba057b3

Browse files
Alexander Regueiromark-i-m
Alexander Regueiro
authored andcommitted
Ignore line check on certain types of lines or in certain blocks.
1 parent 61a3f53 commit ba057b3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ci/check_line_lengths.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33
echo "Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..."
44

55
echo "Offending files and lines:"
6-
(( success = 1 ))
6+
(( bad_lines = 0 ))
7+
(( inside_block = 0 ))
78
for file in "$@" ; do
89
echo "$file"
910
(( line_no = 0 ))
1011
while IFS="" read -r line || [[ -n "$line" ]] ; do
1112
(( line_no++ ))
12-
if (( "${#line}" > $MAX_LINE_LENGTH )) ; then
13-
(( success = 0 ))
13+
if [[ "$line" =~ ^'```' ]] ; then
14+
(( inside_block = !$inside_block ))
15+
continue
16+
fi
17+
if ! (( $inside_block )) && ! [[ "$line" =~ " | "|"://"|\[\^[^\ ]+\]: ]] && (( "${#line}" > $MAX_LINE_LENGTH )) ; then
18+
(( bad_lines++ ))
1419
echo -e "\t$line_no : $line"
1520
fi
1621
done < "$file"
1722
done
1823

19-
(( $success )) && echo "No offending lines found."
24+
echo "$bad_lines offending lines found."
25+
(( $bad_lines == 0 ))

0 commit comments

Comments
 (0)