Skip to content

Commit c8decfa

Browse files
committed
Add more formatting checks of this repository's files
- Files starting with a blank line - Non-Unix line endings - Blank lines at end of file - Some minor formatting improvements to the previous checks
1 parent 7cdc050 commit c8decfa

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

.travis.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,19 @@ before_install:
4343
# Check for issues in the script
4444
- bash -c 'shopt -s globstar; shellcheck arduino-ci-script.sh'
4545

46-
# Check for trailing whitespace in all files in the repository
47-
- "if grep --line-number --recursive --exclude-dir=.git '[[:blank:]]$' .; then echo 'Trailing whitespace found.'; false; fi"
48-
# Check for tabs in all files in the repository
49-
- "if grep --line-number --recursive --exclude-dir=.git $'\t' .; then echo 'Tab found.'; false; fi"
50-
# Check if all files in the repository end in a newline (https://stackoverflow.com/a/25686825)
51-
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'if test "$(tail --bytes=1 "$0")"; then echo "No new line at end of $0"; false; fi'
46+
# Formatting checks:
47+
# Check for files starting with a blank line
48+
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'head -1 "$0" | grep --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at start of $0."; false; fi'
49+
# Check for tabs
50+
- "if grep --line-number --recursive --exclude-dir=.git --regexp=$'\t' .; then echo 'Tab found.'; false; fi"
51+
# Check for trailing whitespace
52+
- "if grep --line-number --recursive --binary-files=without-match --exclude-dir=.git --regexp='[[:blank:]]$' .; then echo 'Trailing whitespace found.'; false; fi"
53+
# Check for non-Unix line endings
54+
- "if grep --files-with-matches --recursive --binary-files=without-match --exclude-dir=.git --regexp=$'\r$' .; then echo 'Non-Unix EOL detected.'; false; fi"
55+
# Check for blank lines at end of files
56+
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'tail -1 "$0" | grep --regexp="^$"; if [[ "$?" == "0" ]]; then echo "Blank line found at end of $0."; false; fi'
57+
# Check for files that don't end in a newline (https://stackoverflow.com/a/25686825)
58+
- find . -path ./.git -prune -o -type f -print0 | xargs -0 -L1 bash -c 'if test "$(tail --bytes=1 "$0")"; then echo "No new line at end of $0."; false; fi'
5259

5360
- source "${TRAVIS_BUILD_DIR}/arduino-ci-script.sh"
5461

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

0 commit comments

Comments
 (0)