diff options
author | Matt Martz <matt@sivel.net> | 2020-06-11 22:02:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-11 22:02:06 +0200 |
commit | 4a4a11d2826d9a76b2e2d86147186b6c214dbd1c (patch) | |
tree | e43f953e8bee7320ad599abc35e48fcbe88595ab | |
parent | Fix copy module file perms with remote_src (#69993) (diff) | |
download | ansible-4a4a11d2826d9a76b2e2d86147186b6c214dbd1c.tar.xz ansible-4a4a11d2826d9a76b2e2d86147186b6c214dbd1c.zip |
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>
-rw-r--r-- | changelogs/fragments/ansible-test-pytest-mccabe.yml | 2 | ||||
-rw-r--r-- | test/lib/ansible_test/_data/requirements/sanity.pylint.txt | 1 | ||||
-rw-r--r-- | test/lib/ansible_test/_internal/sanity/pylint.py | 4 |
3 files changed, 6 insertions, 1 deletions
diff --git a/changelogs/fragments/ansible-test-pytest-mccabe.yml b/changelogs/fragments/ansible-test-pytest-mccabe.yml new file mode 100644 index 0000000000..e2f3fb9061 --- /dev/null +++ b/changelogs/fragments/ansible-test-pytest-mccabe.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test now includes the ``pylint`` plugin ``mccabe`` in optional sanity tests enabled with ``--enable-optional-errors`` diff --git a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt index 25f8038fde..1b800bd060 100644 --- a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt +++ b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt @@ -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 diff --git a/test/lib/ansible_test/_internal/sanity/pylint.py b/test/lib/ansible_test/_internal/sanity/pylint.py index 1ccf436d27..769a171728 100644 --- a/test/lib/ansible_test/_internal/sanity/pylint.py +++ b/test/lib/ansible_test/_internal/sanity/pylint.py @@ -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), |