mirror of https://github.com/ansible/ansible.git
Clean up code-smell sanity scripts. (#18407)
- Replace find ';' with '+' for faster execution. - Replace grep -R with -r to avoid recursive warnings. - Exclude .git and .tox directories from recursive grep. - Improve messaging on failed sanity checks. - Add no-basestring check to Shippable.pull/13938/merge
parent
8c270ac75f
commit
912d6ed8cc
@ -1,24 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=${1-"."}
|
||||
|
||||
# Not entirely correct but
|
||||
# * 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}" \
|
||||
BASESTRING_USERS=$(grep -r basestring . \
|
||||
--exclude-dir .git \
|
||||
--exclude-dir .tox \
|
||||
| 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/' \
|
||||
-e lib/ansible/modules/core/ \
|
||||
-e lib/ansible/modules/extras/ \
|
||||
-e '^[^:]*:#'
|
||||
)
|
||||
|
||||
if test -n "${BASESTRING_USERS}"; then
|
||||
printf "%s" "${BASESTRING_USERS}"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
if [ "${BASESTRING_USERS}" ]; then
|
||||
echo "${BASESTRING_USERS}"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1,13 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=${1-"."}
|
||||
urllib_users=$(find . -name '*.py' -exec grep -H urlopen '{}' '+' | grep -v \
|
||||
-e '^[^:]*/.tox/' \
|
||||
-e '^\./lib/ansible/module_utils/urls.py:' \
|
||||
-e '^\./lib/ansible/module_utils/six.py:' \
|
||||
-e '^\./lib/ansible/compat/six/_six.py:' \
|
||||
-e '^[^:]*:#'
|
||||
)
|
||||
|
||||
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 "%s" "$URLLIB_USERS"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
if [ "${urllib_users}" ]; then
|
||||
echo "${urllib_users}"
|
||||
echo "One or more file(s) listed above use urlopen."
|
||||
echo "Use open_url from module_utils instead of urlopen."
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue