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:
Matt Martz 2020-06-11 15:02:06 -05:00 committed by GitHub
parent 0ae4dac65a
commit 4a4a11d282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- ansible-test now includes the ``pylint`` plugin ``mccabe`` in optional sanity tests enabled with ``--enable-optional-errors``

View file

@ -1,2 +1,3 @@
pylint ; python_version < '3.9' # installation fails on python 3.9.0b1
pyyaml # needed for collection_detail.py
mccabe # pylint complexity testing

View file

@ -56,6 +56,7 @@ class PylintTest(SanitySingleVersion):
super(PylintTest, self).__init__()
self.optional_error_codes.update([
'ansible-deprecated-date',
'too-complex',
])
@property
@ -225,7 +226,7 @@ class PylintTest(SanitySingleVersion):
config = dict()
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 = [
python,
@ -233,6 +234,7 @@ class PylintTest(SanitySingleVersion):
'--jobs', '0',
'--reports', 'n',
'--max-line-length', '160',
'--max-complexity', '20',
'--rcfile', rcfile,
'--output-format', 'json',
'--load-plugins', ','.join(load_plugins),