From d184c69b7c6c0f2cf93facf888182670211460ad Mon Sep 17 00:00:00 2001 From: Don Penney Date: Wed, 15 Jan 2020 14:22:45 -0500 Subject: [PATCH] Update tox.ini bashate to test all bash scripts Currently, the tox.ini file is only running bashate against files that end in a .sh extension. However, many of the build tools do not have an extension, and therefore don't have bashate executed against them. This commit enhances the tox command to search for shell scripts regardless of file extension. The bashate ignore list has been updated to ignore all existing warnings. Future updates can perform cleanup to address the outstanding issues and remove items from the ignore list one by one. The original check of .sh is maintained with a smaller ignore list, to ensure new issues are not introduced. Change-Id: I07e8ac83c6ed3d81e7bfad19da1eee1747d60802 Signed-off-by: Don Penney --- .gitignore | 1 + tox.ini | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index df27462f..1e2185d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.swp +.tox /cgcs-centos-repo /cgcs-tis-repo /cgcs-3rd-party-repo diff --git a/tox.ini b/tox.ini index 4777d23c..c413db46 100644 --- a/tox.ini +++ b/tox.ini @@ -13,20 +13,34 @@ deps = -r{toxinidir}/test-requirements.txt [testenv:linters] basepython = python3 -# ignore below cases -# E006 Line too long -# E010: Do not on same line as it commands whitelist_externals = bash +# Bashate warnings +# E001 Trailing Whitespace +# E002 Tab indents +# E003 Indent not multiple of 4 +# E006 Line too long +# E010 The "do" should be on same line as for +# E011 Then keyword is not on same line as if or elif keyword +# E020 Function declaration not in format ^function name {$ +# E042 local declaration hides errors commands = - bash -c "find {toxinidir} \ + bash -c "find {toxinidir}/build-tools \ -not \( -type d -name .?\* -prune \) \ -type f \ -not -name \*~ \ -not -name \*.md \ -name \*.sh \ -print0 | xargs --no-run-if-empty -0 bashate -v -e 'E*' -i E006,E010" + bash -c "find {toxinidir}/build-tools \ + -not \( -type d -name .?\* -prune \) \ + -type f \ + -not -name \*~ \ + -not -name \*.md \ + \( -exec bash -c 'file \{\} | grep -q shell' \; \ + -a ! -name '*.sh' \) \ + -print0 | xargs --no-run-if-empty -0 bashate -v -e 'E*' -i E001,E002,E003,E006,E010,E011,E020,E042" bash -c "find {toxinidir} \ - \( -name middleware/io-monitor/recipes-common/io-monitor/io-monitor/io_monitor/test-tools/yaml/* -prune \) \ + \( -name stx -prune \) \ -o \( -name .tox -prune \) \ -o -type f -name '*.yaml' \ -print0 | xargs -0 yamllint"