summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2016-11-03 23:30:27 -0700
committerMatt Clay <matt@mystile.com>2016-11-03 23:56:30 -0700
commitbb3801bafd2886bf04f7903245b8e82e151f105e (patch)
tree9aa47f6d17a46a8b853c4dd310cfa5e9e560e04f
parent2d43b20eb994522629bd355c6d917fa0b4f7d685 (diff)
downloadansible-bb3801bafd2886bf04f7903245b8e82e151f105e.tar.gz
Cleanup and fixes for code smell scripts.
- Fix shellcheck issues. - Add .tox exclusions.
-rwxr-xr-xtest/sanity/code-smell/inappropriately-private.sh2
-rwxr-xr-xtest/sanity/code-smell/line-endings.sh2
-rwxr-xr-xtest/sanity/code-smell/no-basestring.sh14
-rwxr-xr-xtest/sanity/code-smell/replace-urlopen.sh2
-rwxr-xr-xtest/sanity/code-smell/shebang.sh1
-rwxr-xr-xtest/sanity/code-smell/use-compat-six.sh2
6 files changed, 17 insertions, 6 deletions
diff --git a/test/sanity/code-smell/inappropriately-private.sh b/test/sanity/code-smell/inappropriately-private.sh
index a50949632f..9ee3342179 100755
--- a/test/sanity/code-smell/inappropriately-private.sh
+++ b/test/sanity/code-smell/inappropriately-private.sh
@@ -15,4 +15,4 @@
# that violate this.
#
# 23-10-2015: Count was 508 lines
-grep -Pri '(?<!self)\._(?!_)' $1|grep -v modules
+grep -Pri '(?<!self)\._(?!_)' "$1" | grep -v modules
diff --git a/test/sanity/code-smell/line-endings.sh b/test/sanity/code-smell/line-endings.sh
index 4d8b5f3849..d97b1143dc 100755
--- a/test/sanity/code-smell/line-endings.sh
+++ b/test/sanity/code-smell/line-endings.sh
@@ -2,6 +2,8 @@
grep -RIPl '\r' . 2>/dev/null \
--exclude-dir .git \
+ | grep -v -E \
+ -e '/.tox/' \
| grep -v -F \
-e './test/integration/targets/win_regmerge/templates/win_line_ending.j2'
diff --git a/test/sanity/code-smell/no-basestring.sh b/test/sanity/code-smell/no-basestring.sh
index ee5a58343e..59a6c9bf55 100755
--- a/test/sanity/code-smell/no-basestring.sh
+++ b/test/sanity/code-smell/no-basestring.sh
@@ -6,10 +6,18 @@ BASEDIR=${1-"."}
# * basestring is still present and harmless in comments
# * basestring is also currently present in modules. Porting of modules is more
# of an Ansible 2.3 or greater goal.
-BASESTRING_USERS=$(grep -r basestring $BASEDIR |grep isinstance| grep -v lib/ansible/compat/six/_six.py|grep -v lib/ansible/module_utils/six.py|grep -v lib/ansible/modules/core|grep -v lib/ansible/modules/extras)
+BASESTRING_USERS=$(grep -r basestring "${BASEDIR}" \
+ | grep isinstance \
+ | grep -v \
+ -e lib/ansible/compat/six/_six.py \
+ -e lib/ansible/module_utils/six.py \
+ -e lib/ansible/modules/core \
+ -e lib/ansible/modules/extras \
+ -e '/.tox/' \
+ )
-if test -n "$BASESTRING_USERS" ; then
- printf "$BASESTRING_USERS"
+if test -n "${BASESTRING_USERS}"; then
+ printf "%s" "${BASESTRING_USERS}"
exit 1
else
exit 0
diff --git a/test/sanity/code-smell/replace-urlopen.sh b/test/sanity/code-smell/replace-urlopen.sh
index 3973ca64b1..5bef3bc21e 100755
--- a/test/sanity/code-smell/replace-urlopen.sh
+++ b/test/sanity/code-smell/replace-urlopen.sh
@@ -6,7 +6,7 @@ URLLIB_USERS=$(find "$BASEDIR" -name '*.py' -exec grep -H urlopen \{\} \;)
URLLIB_USERS=$(echo "$URLLIB_USERS" | sed '/\(\n\|lib\/ansible\/module_utils\/urls.py\|lib\/ansible\/module_utils\/six.py\|lib\/ansible\/compat\/six\/_six.py\|.tox\)/d')
URLLIB_USERS=$(echo "$URLLIB_USERS" | sed '/^[^:]\+:#/d')
if test -n "$URLLIB_USERS" ; then
- printf "$URLLIB_USERS"
+ printf "%s" "$URLLIB_USERS"
exit 1
else
exit 0
diff --git a/test/sanity/code-smell/shebang.sh b/test/sanity/code-smell/shebang.sh
index 15c0c31781..9e9943db6b 100755
--- a/test/sanity/code-smell/shebang.sh
+++ b/test/sanity/code-smell/shebang.sh
@@ -1,6 +1,7 @@
#!/bin/sh
grep '^#!' -RIn . 2>/dev/null | grep ':1:' | sed 's/:1:/:/' | grep -v -E \
+ -e '/.tox/' \
-e '^\./lib/ansible/modules/' \
-e '^\./test/integration/targets/[^/]*/library/[^/]*:#!powershell$' \
-e ':#!/bin/sh$' \
diff --git a/test/sanity/code-smell/use-compat-six.sh b/test/sanity/code-smell/use-compat-six.sh
index d1d9961eef..cdce0ec0e3 100755
--- a/test/sanity/code-smell/use-compat-six.sh
+++ b/test/sanity/code-smell/use-compat-six.sh
@@ -10,7 +10,7 @@ WHITELIST='(lib/ansible/modules/core/cloud/digital_ocean/digital_ocean.py)'
SIX_USERS=$(find "$BASEDIR" -name '*.py' -exec grep -wH six \{\} \;|grep import |grep -v ansible.compat| grep -v ansible.module_utils.six| egrep -v "^$WHITELIST:")
if test -n "$SIX_USERS" ; then
- printf "$SIX_USERS"
+ printf "%s" "$SIX_USERS"
exit 1
else
exit 0