diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/doc/rustc-dev-guide/ci/check_line_lengths.sh | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/rustc-dev-guide/ci/check_line_lengths.sh')
-rwxr-xr-x | src/doc/rustc-dev-guide/ci/check_line_lengths.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/doc/rustc-dev-guide/ci/check_line_lengths.sh b/src/doc/rustc-dev-guide/ci/check_line_lengths.sh new file mode 100755 index 000000000..31cda5c65 --- /dev/null +++ b/src/doc/rustc-dev-guide/ci/check_line_lengths.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +if [ "$1" == "--help" ]; then + echo 'Usage:' "[MAX_LINE_LENGTH=n] $0 [file ...]" + exit 1 +fi + +if [ "$MAX_LINE_LENGTH" == "" ]; then + MAX_LINE_LENGTH=100 +fi + +if [ "$1" == "" ]; then + shopt -s globstar + files=( src/**/*.md ) +else + files=( "$@" ) +fi + +echo "Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..." + +echo "Offending files and lines:" +(( bad_lines = 0 )) +(( inside_block = 0 )) +for file in "${files[@]}"; do + echo "$file" + (( line_no = 0 )) + while IFS="" read -r line || [[ -n "$line" ]] ; do + (( line_no++ )) + if [[ "$line" =~ ^'```' ]] ; then + (( inside_block = !$inside_block )) + continue + fi + if ! (( $inside_block )) \ + && ! [[ "$line" =~ " | "|"-|-"|"://"|"]:"|\[\^[^\ ]+\]: ]] \ + && (( "${#line}" > $MAX_LINE_LENGTH )) ; then + (( bad_lines++ )) + echo -e "\t$line_no : $line" + fi + done < "$file" +done + +echo "$bad_lines offending lines found." +(( $bad_lines == 0 )) |