mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Add empty-init code-smell script. (#18406)
Also removed boilerplate from otherwise empty __init__.py files which should not contain any code (checked by empty-init script).
This commit is contained in:
@@ -4,6 +4,7 @@ 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/core -prune \
|
||||
-o -path ./lib/ansible/modules/__init__.py \
|
||||
-o -path ./lib/ansible/modules/extras -prune \
|
||||
-o -path ./lib/ansible/module_utils -prune \
|
||||
-o -path ./lib/ansible/compat/six/_six.py -prune \
|
||||
@@ -11,6 +12,7 @@ metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules/core -prune \
|
||||
-o -name '*.py' -exec grep -HL '__metaclass__ = type' \{\} \;)
|
||||
|
||||
future2=$(find ./lib/ansible -path ./lib/ansible/modules/core -prune \
|
||||
-o -path ./lib/ansible/modules/__init__.py \
|
||||
-o -path ./lib/ansible/modules/extras -prune \
|
||||
-o -path ./lib/ansible/module_utils -prune \
|
||||
-o -path ./lib/ansible/compat/six/_six.py -prune \
|
||||
|
||||
17
test/sanity/code-smell/empty-init.sh
Executable file
17
test/sanity/code-smell/empty-init.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
found=''
|
||||
|
||||
for path in lib/ansible/modules/ test/units/; do
|
||||
files=$(find "${path}" -name __init__.py -size '+0')
|
||||
|
||||
if [ "${files}" ]; then
|
||||
echo "${files}"
|
||||
found=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${found}" ]; then
|
||||
echo "One or more __init__.py file(s) listed above are non-empty."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user