Add mccabe complexity testing (#64623)
* Add mccabe complexity testing * Make mccabe complexity an optional error * Add mccabe to new sanity pylint requirements * Add a changelog fragment. Co-authored-by: Matt Clay <matt@mystile.com>
This commit is contained in:
parent
0ae4dac65a
commit
4a4a11d282
3 changed files with 6 additions and 1 deletions
2
changelogs/fragments/ansible-test-pytest-mccabe.yml
Normal file
2
changelogs/fragments/ansible-test-pytest-mccabe.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- ansible-test now includes the ``pylint`` plugin ``mccabe`` in optional sanity tests enabled with ``--enable-optional-errors``
|
|
@ -1,2 +1,3 @@
|
||||||
pylint ; python_version < '3.9' # installation fails on python 3.9.0b1
|
pylint ; python_version < '3.9' # installation fails on python 3.9.0b1
|
||||||
pyyaml # needed for collection_detail.py
|
pyyaml # needed for collection_detail.py
|
||||||
|
mccabe # pylint complexity testing
|
||||||
|
|
|
@ -56,6 +56,7 @@ class PylintTest(SanitySingleVersion):
|
||||||
super(PylintTest, self).__init__()
|
super(PylintTest, self).__init__()
|
||||||
self.optional_error_codes.update([
|
self.optional_error_codes.update([
|
||||||
'ansible-deprecated-date',
|
'ansible-deprecated-date',
|
||||||
|
'too-complex',
|
||||||
])
|
])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -225,7 +226,7 @@ class PylintTest(SanitySingleVersion):
|
||||||
config = dict()
|
config = dict()
|
||||||
|
|
||||||
disable_plugins = set(i.strip() for i in config.get('disable-plugins', '').split(',') if i)
|
disable_plugins = set(i.strip() for i in config.get('disable-plugins', '').split(',') if i)
|
||||||
load_plugins = set(plugin_names) - disable_plugins
|
load_plugins = set(plugin_names + ['pylint.extensions.mccabe']) - disable_plugins
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
python,
|
python,
|
||||||
|
@ -233,6 +234,7 @@ class PylintTest(SanitySingleVersion):
|
||||||
'--jobs', '0',
|
'--jobs', '0',
|
||||||
'--reports', 'n',
|
'--reports', 'n',
|
||||||
'--max-line-length', '160',
|
'--max-line-length', '160',
|
||||||
|
'--max-complexity', '20',
|
||||||
'--rcfile', rcfile,
|
'--rcfile', rcfile,
|
||||||
'--output-format', 'json',
|
'--output-format', 'json',
|
||||||
'--load-plugins', ','.join(load_plugins),
|
'--load-plugins', ','.join(load_plugins),
|
||||||
|
|
Loading…
Reference in a new issue