ansible/test/sanity/code-smell/no-dict-iteritems.sh
Toshio Kuratomi 0b440a9289 Code smell test for iteritems and itervalues (#19292)
* Code smell test for iteritems and itervalues

* Change the keydict object in authorized_keys so it doesn't throw a false postive

keydict is a bad data structure anyway.  We don't use the iteritems and
itervalues methods so just disable them so that the code-smell tests do
not trigger on it.

* Change release templates so they work with py3
2016-12-14 12:16:16 -08:00

21 lines
699 B
Bash
Executable file

#!/bin/sh
ITERITEMS_USERS=$(grep -rI '\.iteritems' . \
--exclude-dir .git \
--exclude-dir .tox \
--exclude-dir docsite \
| grep -v \
-e 'six\.iteritems' \
-e lib/ansible/compat/six/_six.py \
-e lib/ansible/module_utils/six.py \
-e test/sanity/code-smell/no-dict-iteritems.sh \
)
if [ "${ITERITEMS_USERS}" ]; then
echo 'iteritems has been removed in python3. Alternatives:'
echo ' for KEY, VALUE in DICT.items():'
echo ' from ansible.module_utils.six import iteritems ; for KEY, VALUE in iteritems(DICT):'
echo ' from ansible.compat.six import iteritems ; for KEY, VALUE in iteritems(DICT):'
echo "${ITERITEMS_USERS}"
exit 1
fi