ansible/test/sanity/code-smell/boilerplate.sh
Brian Coca 74842adc07 1st part of ansible config, adds ansible-config to view/manage configs (#12797)
* Start of ansible config project

moved configuration definitions to external yaml file vs hardcoded
 * updated constants to be a data strcutures that are looped over and also return origin of setting
changed to manager/data scheme for base classes
new cli ansible-config to view/manage ansible configuration settings
 * prints green for default/unchanged and yellow for those that have been overriden
 * added list action to show all configurable settings and their associated ini and env var names
 * allows specifying config file to see what result would look like
 * TBD update, edit and view options

removed test for functions that have been removed

env_Vars are now list of dicts
allows for version_added and deprecation in future
added a couple of descriptions for future doc autogeneration
ensure test does not fail if delete_me exists
normalized 'path expansion'
added yaml config to setup packaging
removed unused imports
better encoding handling

updated as per feedback

* pep8
2017-06-14 11:08:34 -04:00

60 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
metaclass1=$(find ./bin -type f -exec grep -HL '__metaclass__ = type' '{}' '+')
future1=$(find ./bin -type f -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' '{}' '+')
metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \
-o -path ./lib/ansible/modules/__init__.py \
-o -path ./lib/ansible/config/__init__.py \
-o -path ./lib/ansible/module_utils -prune \
-o -path ./lib/ansible/module_utils/six/_six.py -prune \
-o -path ./lib/ansible/compat/selectors/_selectors2.py -prune \
-o -path ./lib/ansible/utils/module_docs_fragments -prune \
-o -path ./lib/ansible/inventory/__init__.py \
-o -path ./lib/ansible/vars/__init__.py \
-o -name '*.py' -exec grep -HL '__metaclass__ = type' '{}' '+')
future2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \
-o -path ./lib/ansible/modules/__init__.py \
-o -path ./lib/ansible/config/__init__.py \
-o -path ./lib/ansible/module_utils -prune \
-o -path ./lib/ansible/module_utils/six/_six.py -prune \
-o -path ./lib/ansible/compat/selectors/_selectors2.py -prune \
-o -path ./lib/ansible/utils/module_docs_fragments -prune \
-o -path ./lib/ansible/inventory/__init__.py \
-o -path ./lib/ansible/vars/__init__.py \
-o -name '*.py' -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' '{}' '+')
### TODO:
### - contrib/
### - module_utils that are py2.6+
if test -n "$metaclass1" -o -n "$metaclass2" ; then
printf "\n== Missing __metaclass__ = type ==\n"
fi
if test -n "$metaclass1" ; then
printf "$metaclass1\n"
fi
if test -n "$metaclass2" ; then
printf "$metaclass2\n"
fi
if test -n "$future1" -o -n "$future2" ; then
printf "\n== Missing from __future__ import (absolute_import, division, print_function) ==\n"
fi
if test -n "$future1" ; then
printf "$future1\n"
fi
if test -n "$future2" ; then
printf "$future2\n"
fi
if test -n "$future1$future2$metaclass1$metaclass2" ; then
failures=$(printf "$future1$future2$metaclass1$metaclass2"| wc -l)
failures=$(expr $failures + 2)
exit $failures
fi
exit 0