mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Support ignore_changes
in code-smell tests.
This commit is contained in:
parent
b8a7e35b22
commit
06d83bae05
3 changed files with 32 additions and 15 deletions
|
@ -255,6 +255,7 @@ class SanityCodeSmellTest(SanityTest):
|
||||||
files = self.config.get('files')
|
files = self.config.get('files')
|
||||||
always = self.config.get('always')
|
always = self.config.get('always')
|
||||||
text = self.config.get('text')
|
text = self.config.get('text')
|
||||||
|
ignore_changes = self.config.get('ignore_changes')
|
||||||
|
|
||||||
if output == 'path-line-column-message':
|
if output == 'path-line-column-message':
|
||||||
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
|
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
|
||||||
|
@ -263,7 +264,11 @@ class SanityCodeSmellTest(SanityTest):
|
||||||
else:
|
else:
|
||||||
pattern = ApplicationError('Unsupported output type: %s' % output)
|
pattern = ApplicationError('Unsupported output type: %s' % output)
|
||||||
|
|
||||||
paths = sorted(i.path for i in targets.include)
|
if ignore_changes:
|
||||||
|
paths = sorted(i.path for i in targets.targets)
|
||||||
|
always = False
|
||||||
|
else:
|
||||||
|
paths = sorted(i.path for i in targets.include)
|
||||||
|
|
||||||
if always:
|
if always:
|
||||||
paths = []
|
paths = []
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
{
|
{
|
||||||
"always": true,
|
"ignore_changes": true,
|
||||||
|
"prefixes": [
|
||||||
|
"lib/ansible/modules/",
|
||||||
|
"lib/ansible/plugins/action/"
|
||||||
|
],
|
||||||
|
"extensions": [
|
||||||
|
".py"
|
||||||
|
],
|
||||||
"output": "path-message"
|
"output": "path-message"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"""Test to verify action plugins have an associated module to provide documentation."""
|
"""Test to verify action plugins have an associated module to provide documentation."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -40,31 +41,35 @@ def main():
|
||||||
'vyos',
|
'vyos',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
paths = sys.argv[1:] or sys.stdin.read().splitlines()
|
||||||
|
|
||||||
module_names = set()
|
module_names = set()
|
||||||
|
|
||||||
for root, dirs, files in os.walk('lib/ansible/modules'):
|
for path in paths:
|
||||||
for filename in files:
|
if not path.startswith('lib/ansible/modules/'):
|
||||||
name, ext = os.path.splitext(filename)
|
continue
|
||||||
|
|
||||||
if ext == '.py' and name != '__init__':
|
name = os.path.splitext(os.path.basename(path))[0]
|
||||||
if name.startswith('_'):
|
|
||||||
name = name[1:]
|
|
||||||
|
|
||||||
module_names.add(name)
|
if name != '__init__':
|
||||||
|
if name.startswith('_'):
|
||||||
|
name = name[1:]
|
||||||
|
|
||||||
|
module_names.add(name)
|
||||||
|
|
||||||
action_plugin_dir = 'lib/ansible/plugins/action'
|
|
||||||
unused_skip = set(skip)
|
unused_skip = set(skip)
|
||||||
|
|
||||||
for filename in os.listdir(action_plugin_dir):
|
for path in paths:
|
||||||
name, ext = os.path.splitext(filename)
|
if not path.startswith('lib/ansible/plugins/action/'):
|
||||||
|
continue
|
||||||
|
|
||||||
if ext == '.py' and name not in module_names:
|
name = os.path.splitext(os.path.basename(path))[0]
|
||||||
|
|
||||||
|
if name not in module_names:
|
||||||
if name in skip:
|
if name in skip:
|
||||||
unused_skip.remove(name)
|
unused_skip.remove(name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path = os.path.join(action_plugin_dir, filename)
|
|
||||||
|
|
||||||
print('%s: action plugin has no matching module to provide documentation' % path)
|
print('%s: action plugin has no matching module to provide documentation' % path)
|
||||||
|
|
||||||
for filename in sorted(unused_skip):
|
for filename in sorted(unused_skip):
|
||||||
|
|
Loading…
Add table
Reference in a new issue