From a94ee08d5068ec58fd08679dd4ae4ef27b977d26 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Tue, 4 Dec 2018 13:45:38 -0600 Subject: [PATCH] Improve pylint checking in stx-config Previously when pylint was invoked, all warnings were suppressed. Now, the only warnings suppressed are the ones that are failing. By making this change, fixed issues will not be reintroduced by later commits. Additional tasks will be created in the future to address the currently suppressed warnings and errors. This also adds a zuul job for pylint in sysinv. Story: 2004515 Task: 28268 Change-Id: Ie162c08a9e70a70bfc089ebee711ef9d6a374f2b Signed-off-by: Al Bailey --- .zuul.yaml | 17 +++++ controllerconfig/controllerconfig/pylint.rc | 23 ++++++- sysinv/cgts-client/cgts-client/pylint.rc | 30 ++++++++- sysinv/sysinv/sysinv/pylint.rc | 70 +++++++++++++++++++-- sysinv/sysinv/sysinv/tox.ini | 33 +++++----- 5 files changed, 147 insertions(+), 26 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 7670fe843e..e85fd53e04 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -9,6 +9,7 @@ - openstack-tox-linters - sysinv-tox-py27 - sysinv-tox-flake8 + - sysinv-tox-pylint - controllerconfig-tox-flake8 - controllerconfig-tox-py27 - controllerconfig-tox-pylint @@ -25,6 +26,7 @@ - openstack-tox-linters - sysinv-tox-py27 - sysinv-tox-flake8 + - sysinv-tox-pylint - controllerconfig-tox-flake8 - controllerconfig-tox-py27 - controllerconfig-tox-pylint @@ -64,6 +66,21 @@ tox_envlist: flake8 tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini +- job: + name: sysinv-tox-pylint + parent: tox + description: | + Run pylint test for sysinv + required-projects: + - openstack/stx-update + - openstack/stx-fault + - openstack/stx-integ + files: + - sysinv/sysinv/* + vars: + tox_envlist: pylint + tox_extra_args: -c sysinv/sysinv/sysinv/tox.ini + - job: name: controllerconfig-tox-flake8 parent: tox diff --git a/controllerconfig/controllerconfig/pylint.rc b/controllerconfig/controllerconfig/pylint.rc index a66004ed6e..ce5f87ad62 100755 --- a/controllerconfig/controllerconfig/pylint.rc +++ b/controllerconfig/controllerconfig/pylint.rc @@ -29,9 +29,28 @@ load-plugins= # https://pylint.readthedocs.io/en/latest/user_guide/output.html#source-code-analysis-section # We are disabling (C)onvention # We are disabling (R)efactor -# We are probably disabling (W)arning +# We are selectively disabling (W)arnings # We are not disabling (F)atal, (E)rror -disable=C, R, W +# The following suppressed warnings should be fixed: +# fixme: (notes, xxx, fixme) +# W0101: unreachable-code +# W0105: pointless-string-statement +# W0110: deprecated-lambda +# W0120: useless-else-on-loop +# W0201: attribute-defined-outside-init +# W0211: bad-staticmethod-argument +# W0212: protected-access +# W0311: bad-indentation +# W0403: relative-import +# W0612: unused-variable +# W0613: unused-argument +# W0621: redefined-outer-name +# W0622: redefined-builtin +# W0631: undefined-loop-variable +# W0703: broad-except +# W1501: bad-open-mode +disable=C, R, fixme, W0101, W0105, W0110, W0120, W0201, W0211, W0212, W0311, W0403, + W0612, W0613, W0621, W0622, W0631, W0703, W1501 [REPORTS] diff --git a/sysinv/cgts-client/cgts-client/pylint.rc b/sysinv/cgts-client/cgts-client/pylint.rc index 16a03be5a9..f02ee018e8 100755 --- a/sysinv/cgts-client/cgts-client/pylint.rc +++ b/sysinv/cgts-client/cgts-client/pylint.rc @@ -29,10 +29,34 @@ load-plugins= # https://pylint.readthedocs.io/en/latest/user_guide/output.html#source-code-analysis-section # We are disabling (C)onvention # We are disabling (R)efactor -# We are probably disabling (W)arning +# We are selectively disabling (W)arning # We are not disabling (F)atal, (E)rror -#disable=C,R,W -disable=C,R,W +# The following warnings are disabled and should be fixed: +# fixme (notes, todo, xxx) +# W0102: dangerous-default-value +# W0105: pointless-string-statement +# W0108: unnecessary-lambda +# W0110: deprecated-lambda +# W0120: useless-else-on-loop +# W0123: eval-used +# W0201: attribute-defined-outside-init +# W0212: protected-access +# W0231: super-init-not-called +# W0235: useless-super-delegation +# W0402: deprecated-module +# W0403: relative-import +# W0603: global-statement +# W0611: unused-import +# W0612: unused-variable +# W0613: unused-argument +# W0621: redefined-outer-name +# W0622: redefined-builtin +# W0631: undefined-loop-variable +# W0703: broad-except +# W1201: logging-not-lazy +# W1401: anomalous-backslash-in-string +disable=C, R, fixme, W0102, W0105, W0108, W0110, W0120, W0123, W0201, W0212, W0231, W0235, + W0402, W0403, W0603, W0611, W0612, W0613, W0621, W0622, W0631, W0703, W1201, W1401 [REPORTS] diff --git a/sysinv/sysinv/sysinv/pylint.rc b/sysinv/sysinv/sysinv/pylint.rc index 157bdbfc3a..78ef8f1540 100755 --- a/sysinv/sysinv/sysinv/pylint.rc +++ b/sysinv/sysinv/sysinv/pylint.rc @@ -29,11 +29,73 @@ load-plugins= # https://pylint.readthedocs.io/en/latest/user_guide/output.html#source-code-analysis-section # We are disabling (C)onvention # We are disabling (R)efactor -# We are probably disabling (W)arning +# We are selectively disabling (W)arning # We are not disabling (F)atal, (E)rror -disable=C,R,W -#disable=C,R - +# The following warnings should be fixed: +# fixme (todo, xxx, fixme) +# W0101: unreachable +# W0102: dangerous-default-value +# W0105: pointless-string-statement +# W0106: expression-not-assigned +# W0107: unnecessary-pass +# W0108: unnecessary-lambda +# W0110: deprecated-lambda +# W0120: useless-else-on-loop +# W0123: eval-used +# W0150: lost-exception +# W0201: attribute-defined-outside-init +# W0211: bad-staticmethod-argument +# W0212: protected-access +# W0221: arguments-differ +# W0223: abstract-method +# W0231: super-init-not-called +# W0235: useless-super-delegation +# W0311: bad-indentation +# W0402: deprecated-module +# W0403: relative-import +# W0404: reimported +# W0603: global-statement +# W0611: unused-import +# W0612: unused-variable +# W0613: unused-argument +# W0621: redefined-outer-name +# W0622: redefined-builtin +# W0631: undefined-loop-variable +# W0632: unbalanced-tuple-unpacking +# W0701: bad-except-order +# W0703: broad-except +# W1113: keyword-arg-before-vararg +# W1201: logging-not-lazy +# W1401: anomalous-backslash-in-string +# W1505: deprecated-method +# All these errors should be fixed: +# E0202: method-hidden +# E0203: access-member-before-definition +# E0213: no-self-argument +# E0401: import-error +# E0602: undefined-variable +# E0604: invalid-all-object +# E0611: no-name-in-module +# E0633: unpacking-non-sequence +# E0701: bad-except-order +# E0702: raising-bad-type +# E0712: catching-non-exception +# E1003: bad-super-call +# E1101: no-member +# E1102: not-callable +# E1111: assignment-from-no-return +# E1120: no-value-for-parameter +# E1121: too-many-function-args +# E1124: redundant-keyword-arg +# E1136: unsubscriptable-object +# E1205: logging-too-many-args +# E1305: too-many-format-args +disable=C, R, fixme, W0101, W0102, W0105, W0106, W0107, W0108, W0110, W0120, W0123, W0150, + W0201, W0211, W0212, W0221, W0223, W0231, W0235, W0311, W0402, W0403, W0404, + W0603, W0611, W0612, W0613, W0621, W0622, W0631, W0632, W0701, W0703, + W1113, W1201, W1401, W1505, + E0202, E0203, E0213, E0401, E0602, E0604, E0611, E0633, E0701, E0702, E0712, + E1003, E1101, E1102, E1111, E1120, E1121, E1124, E1136, E1205, E1305 [REPORTS] # Set the output format. Available formats are text, parseable, colorized, msvs diff --git a/sysinv/sysinv/sysinv/tox.ini b/sysinv/sysinv/sysinv/tox.ini index 95040f3dc4..51db912b22 100644 --- a/sysinv/sysinv/sysinv/tox.ini +++ b/sysinv/sysinv/sysinv/tox.ini @@ -1,13 +1,12 @@ [tox] -envlist = flake8,py27 +envlist = flake8,py27, pylint minversion = 1.6 # skipsdist = True #,pip-missing-reqs # tox does not work if the path to the workdir is too long, so move it to /tmp toxworkdir = /tmp/{env:USER}_sysinvtox -wrsdir = {toxinidir}/../../../../../../../../.. -cgcsdir = {toxinidir}/../../../.. +stxdir = {toxinidir}/../../../.. distshare={toxworkdir}/.tox/distshare [testenv] @@ -38,13 +37,13 @@ setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt - -e{[tox]cgcsdir}/stx-update/tsconfig/tsconfig - -e{[tox]cgcsdir}/stx-config/configutilities/configutilities - -e{[tox]cgcsdir}/stx-fault/fm-api - -e{[tox]cgcsdir}/stx-fault/python-fmclient/fmclient - -e{[tox]cgcsdir}/stx-config/controllerconfig/controllerconfig - -e{[tox]cgcsdir}/stx-update/cgcs-patch/cgcs-patch - -e{[tox]cgcsdir}/stx-integ/utilities/platform-util/platform-util + -e{[tox]stxdir}/stx-update/tsconfig/tsconfig + -e{[tox]stxdir}/stx-config/configutilities/configutilities + -e{[tox]stxdir}/stx-fault/fm-api + -e{[tox]stxdir}/stx-fault/python-fmclient/fmclient + -e{[tox]stxdir}/stx-config/controllerconfig/controllerconfig + -e{[tox]stxdir}/stx-update/cgcs-patch/cgcs-patch + -e{[tox]stxdir}/stx-integ/utilities/platform-util/platform-util commands = find . -type f -name "*.pyc" -delete @@ -136,19 +135,19 @@ basepython = python2.7 sitepackages = False deps = {[testenv]deps} - pylint + pylint commands = pylint {posargs} sysinv --rcfile=./pylint.rc --extension-pkg-whitelist=lxml.etree,greenlet [testenv:cover] basepython = python2.7 deps = {[testenv]deps} - -e{[tox]cgcsdir}/stx-update/tsconfig/tsconfig - -e{[tox]cgcsdir}/stx-config/configutilities/configutilities - -e{[tox]cgcsdir}/stx-fault/fm-api - -e{[tox]cgcsdir}/stx-config/controllerconfig/controllerconfig - -e{[tox]cgcsdir}/stx-update/cgcs-patch/cgcs-patch - -e{[tox]cgcsdir}/stx-integ/utilities/platform-util/platform-util + -e{[tox]stxdir}/stx-update/tsconfig/tsconfig + -e{[tox]stxdir}/stx-config/configutilities/configutilities + -e{[tox]stxdir}/stx-fault/fm-api + -e{[tox]stxdir}/stx-config/controllerconfig/controllerconfig + -e{[tox]stxdir}/stx-update/cgcs-patch/cgcs-patch + -e{[tox]stxdir}/stx-integ/utilities/platform-util/platform-util commands = find . -type f -name "*.pyc" -delete