ansible/test/sanity/code-smell/no-list-cmp.sh
kkjang 5c43bd3bae Cmp python3 compat (#25008)
* Use double-quotes for expect integration tests

* Cast user input to string for expect integration tests

* Remove usage of cmp() for python3 compatibility

- Add code smell test to look for cmp usage

- Fixes #24756
2017-05-24 15:59:59 -07:00

15 lines
385 B
Bash
Executable file

#!/bin/sh
CMP_USERS=$(grep -rI ' cmp[^a-zA-Z0-9_]' . \
--exclude-dir .tox \
| grep -v \
-e lib/ansible/module_utils/six/_six.py \
-e test/sanity/code-smell/no-list-cmp.sh
)
if [ "${CMP_USERS}" ]; then
echo 'cmp has been removed in python3. Alternatives:'
echo ' http://python3porting.com/preparing.html#when-sorting-use-key-instead-of-cmp'
echo "${CMP_USERS}"
exit 1
fi