From 95092971ab46147cb57da9ee6eaaf2ff3bd0f171 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Fri, 23 Feb 2018 21:51:29 +0000 Subject: [PATCH] Added check for all source files to ensure they have no lines longer than 80 chars. --- .travis.yml | 2 ++ ci/check_line_lengths.sh | 19 +++++++++++++++++++ ci/install.sh | 1 + 3 files changed, 22 insertions(+) create mode 100755 ci/check_line_lengths.sh mode change 100644 => 100755 ci/install.sh diff --git a/.travis.yml b/.travis.yml index 5ca97ba7..da9c1ed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: rust cache: - cargo +before_install: +- MAX_LINE_LENGTH=80 bash ci/check_line_lengths.sh src/**/*.md install: - source ~/.cargo/env || true - bash ci/install.sh diff --git a/ci/check_line_lengths.sh b/ci/check_line_lengths.sh new file mode 100755 index 00000000..8001ea9a --- /dev/null +++ b/ci/check_line_lengths.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..." + +echo "Offending files and lines:" +(( success = 1 )) +for file in "$@" ; do + echo "$file" + (( line_no = 0 )) + while IFS="" read -r line || [[ -n "$line" ]] ; do + (( line_no++ )) + if (( "${#line}" > $MAX_LINE_LENGTH )) ; then + (( success = 0 )) + echo -e "\t$line_no : $line" + fi + done < "$file" +done + +(( $success )) && echo "No offending lines found." diff --git a/ci/install.sh b/ci/install.sh old mode 100644 new mode 100755 index 975857a9..ea90e853 --- a/ci/install.sh +++ b/ci/install.sh @@ -1,4 +1,5 @@ #!/bin/bash + set -ex function cargo_install() {