From f12b1310ef1e20e94332101c431d0a2b9fdc40b1 Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Mon, 26 Jun 2017 17:26:37 +1000 Subject: [PATCH] dib-lint: Ignore editor temp files for linting run When running dib-lint vi temp files .*.sw? files are included which leads to false positives. ALso all editor files are checked when looking at indents, again this results in false positives. Exclude those files by checking if they're in the user/project's .gitignore setup. Change-Id: I0a48174f22a8dad9e8f15bf3f70835d021a2d46f --- .gitignore | 1 + bin/dib-lint | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b2dc99e2a..b1e8511ef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ cover/* *~ .testrepository *.sw? +#*# *.pyc .tox *.egg diff --git a/bin/dib-lint b/bin/dib-lint index ba528bdb2..b76e78a4f 100755 --- a/bin/dib-lint +++ b/bin/dib-lint @@ -73,14 +73,15 @@ trap "rm -rf $TMPDIR" EXIT # note .py files are run through flake8 directly in tox.ini for i in $(find $ELEMENTS_DIR -type f \ - -not -name \*~ \ - -not -name \#\*\# \ - -not -name \*.orig \ -not -name \*.rst \ -not -name \*.yaml \ - -not -name \*.py \ - -not -name \*.pyc); do + -not -name \*.py); do + # Skip files in .gitignore + if git check-ignore -q "$i" ; then + echo Skipping $i + continue + fi echo "Checking $i" exclusions=("$(parse_exclusions $i)") @@ -232,6 +233,11 @@ echo "Checking indents..." for i in $(find $ELEMENTS_DIR -type f -and -name '*.rst' -or -type f -executable) \ $(find $LIB_DIR -type f); do + # Skip files in .gitignore + if git check-ignore -q "$i" ; then + echo Skipping $i + continue + fi # Check for tab indentation if ! excluded tabindent; then if grep -q $'^ *\t' ${i}; then