ansible/test/sanity/code-smell/use-argspec-type-path.sh
Matt Clay cf1337ca9a Update ansible-test sanity command. (#31958)
* Use correct pip version in ansible-test.
* Add git fallback for validate-modules.
* Run sanity tests in a docker container.
* Use correct python version for sanity tests.
* Pin docker completion images and add default.
* Split pylint execution into multiple contexts.
* Only test .py files in use-argspec-type-path test.
* Accept identical python interpeter name or binary.
* Switch cloud tests to default container.
* Remove unused extras from pip install.
* Filter out empty pip commands.
* Don't force running of pip list.
* Support delegation for windows and network tests.
* Fix ansible-test python version usage.
* Fix ansible-test python version skipping.
* Use absolute path for log in ansible-test.
* Run vyos_command test on python 3.
* Fix windows/network instance persistence.
* Add `test/cache` dir to classification.
* Enable more python versions for network tests.
* Fix cs_router test.
2017-10-26 00:21:46 -07:00

42 lines
1.5 KiB
Bash
Executable file

#!/bin/sh
# Add valid uses of expanduser to this list
WHITELIST='cloud/lxc/lxc_container.py
cloud/rackspace/rax_files_objects.py
database/mongodb/mongodb_parameter.py
database/mongodb/mongodb_user.py
database/postgresql/postgresql_db.py
files/synchronize.py
source_control/git.py
system/puppet.py
utilities/logic/async_status.py
utilities/logic/async_wrapper.py
web_infrastructure/ansible_tower/tower_host.py
web_infrastructure/ansible_tower/tower_group.py
web_infrastructure/jenkins_plugin.py'
# Modules which need to be ported to get rid of expanduser. See: https://github.com/ansible/ansible/projects/12
GRANDFATHERED_NEED_PORTING='cloud/rackspace/rax.py
cloud/rackspace/rax_scaling_group.py
files/find.py
files/archive.py'
for FILE in $WHITELIST ; do
GREP_FORMAT_WHITELIST="$GREP_FORMAT_WHITELIST -e $FILE"
done
for FILE in $GRANDFATHERED_NEED_PORTING ; do
GREP_FORMAT_WHITELIST="$GREP_FORMAT_WHITELIST -e $FILE"
done
# GREP_FORMAT_WHITELIST has been formatted so that wordsplitting is wanted. Therefore no double quotes around the var
# shellcheck disable=SC2086
egrep -r 'expanduser' lib/ansible/modules | egrep '\.py:' | egrep -v $GREP_FORMAT_WHITELIST
if [ $? -ne 1 ]; then
printf 'The module(s) listed above use expanduser.\n'
printf 'This may indicate the module should be using an argpsec type="path" instead of type="str"\n'
printf 'If this is a false positive, add to the whitelist in:\n'
printf ' test/sanity/code-smell/use-argspec-type-path.sh\n'
exit 1
fi