From e9a75b923e07efc80561cab027eeed54124231ad Mon Sep 17 00:00:00 2001 From: Salatskyi Serhii Date: Tue, 14 Apr 2020 11:11:16 +0200 Subject: [PATCH 1/4] Add testing by pylint *CLOUDBLD-72 Signed-off-by: Salatskyi Serhii --- .pylintrc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.sh | 9 +++++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .pylintrc diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..49f7c3c --- /dev/null +++ b/.pylintrc @@ -0,0 +1,63 @@ +[MASTER] + +# Use multiple processes to speed up Pylint. +jobs=1 + +# Pickle collected data for later comparisons. +persistent=no + +# Activate the evaluation score. +score=no + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +enable=all, + python3 +disable=I, + R, # refactoring checks + arguments-differ, # nice to have + bad-continuation, # pep8 + bad-whitespace, # pep8, nice to have + invalid-name + no-self-use + +[REPORTS] + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg})' + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio).You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=colorized + +[TYPECHECK] + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=requests.structures.LookupDict + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules=requests.packages, + responses, + docker, + http.client, + six.moves \ No newline at end of file diff --git a/test.sh b/test.sh index 9f7fd30..9a98721 100755 --- a/test.sh +++ b/test.sh @@ -44,7 +44,7 @@ if [[ $($ENGINE ps -qa -f name="$CONTAINER_NAME" | wc -l) -eq 0 ]]; then elif [[ $($ENGINE ps -q -f name="$CONTAINER_NAME" | wc -l) -eq 0 ]]; then echo found stopped existing container, restarting. volume mounts cannot be updated. $ENGINE container start "$CONTAINER_NAME" - fi +fi # Install dependencies $RUN $PKG install -y $PKG_EXTRA @@ -84,6 +84,13 @@ case ${ACTION} in $RUN $PIP install bandit TEST_CMD="bandit-baseline -r dockerfile_parse -ll -ii" ;; +"pylint") + # This can run only at fedora because pylint is not packaged in centos + # use distro pylint to not get too new pylint version + $RUN $PKG install -y "${PYTHON}-pylint" + PACKAGES='dockerfile_parse tests' + TEST_CMD="${PYTHON} -m pylint ${PACKAGES}" + ;; *) echo "Unknown action: ${ACTION}" exit 2 From 76767f3af925df84a77de12e24023448cf02318a Mon Sep 17 00:00:00 2001 From: Salatskyi Serhii Date: Tue, 14 Apr 2020 11:16:52 +0200 Subject: [PATCH 2/4] Update travis CI for testing by pylint *CLOUDBLD-72 Signed-off-by: Salatskyi Serhii --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index eac0d49..f1ecab4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,16 @@ env: OS_VERSION=31 PYTHON_VERSION=3 ENGINE=docker + - ACTION=pylint + OS=fedora + OS_VERSION=29 + PYTHON_VERSION=2 + ENGINE=docker + - ACTION=pylint + OS=fedora + OS_VERSION=31 + PYTHON_VERSION=3 + ENGINE=docker - OS=centos OS_VERSION=7 PYTHON_VERSION=2 From cccb52ca3595ac8fc079d25daa5e6e9b2ab41e3b Mon Sep 17 00:00:00 2001 From: Salatskyi Serhii Date: Wed, 15 Apr 2020 12:04:10 +0200 Subject: [PATCH 3/4] Import absolute_import *CLOUDBLD-72 Signed-off-by: Salatskyi Serhii --- dockerfile_parse/__init__.py | 1 + dockerfile_parse/constants.py | 2 +- dockerfile_parse/parser.py | 2 +- dockerfile_parse/util.py | 2 +- tests/fixtures.py | 2 +- tests/test_parser.py | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dockerfile_parse/__init__.py b/dockerfile_parse/__init__.py index 95d9b88..b901691 100644 --- a/dockerfile_parse/__init__.py +++ b/dockerfile_parse/__init__.py @@ -10,6 +10,7 @@ # This file is generated from template: rel-eng/version_init.template # +from __future__ import absolute_import from .parser import DockerfileParser __version__ = "0.0.16" diff --git a/dockerfile_parse/constants.py b/dockerfile_parse/constants.py index 1f784d2..aaca611 100644 --- a/dockerfile_parse/constants.py +++ b/dockerfile_parse/constants.py @@ -6,7 +6,7 @@ This software may be modified and distributed under the terms of the BSD license. See the LICENSE file for details. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import from sys import version_info diff --git a/dockerfile_parse/parser.py b/dockerfile_parse/parser.py index e07c200..04c734d 100644 --- a/dockerfile_parse/parser.py +++ b/dockerfile_parse/parser.py @@ -7,7 +7,7 @@ of the BSD license. See the LICENSE file for details. """ -from __future__ import print_function, unicode_literals +from __future__ import print_function, unicode_literals, absolute_import import json import logging diff --git a/dockerfile_parse/util.py b/dockerfile_parse/util.py index a6acc1c..49c78b8 100644 --- a/dockerfile_parse/util.py +++ b/dockerfile_parse/util.py @@ -7,7 +7,7 @@ of the BSD license. See the LICENSE file for details. """ -from __future__ import print_function, unicode_literals +from __future__ import print_function, unicode_literals, absolute_import import shlex from io import StringIO diff --git a/tests/fixtures.py b/tests/fixtures.py index 537241a..dfedb10 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -7,7 +7,7 @@ of the BSD license. See the LICENSE file for details. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import pytest import six diff --git a/tests/test_parser.py b/tests/test_parser.py index f95713e..21b7fe5 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -7,7 +7,7 @@ of the BSD license. See the LICENSE file for details. """ -from __future__ import unicode_literals +from __future__ import unicode_literals, absolute_import import inspect import json From 668f4915c52291329d09e35983254d707daeb53e Mon Sep 17 00:00:00 2001 From: Salatskyi Serhii Date: Wed, 15 Apr 2020 12:50:05 +0200 Subject: [PATCH 4/4] Update .pylintrc *CLOUDBLD-72 Signed-off-by: Salatskyi Serhii --- .pylintrc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 49f7c3c..ac70f46 100644 --- a/.pylintrc +++ b/.pylintrc @@ -31,8 +31,19 @@ disable=I, arguments-differ, # nice to have bad-continuation, # pep8 bad-whitespace, # pep8, nice to have - invalid-name - no-self-use + comprehension-escape, + import-outside-toplevel, + invalid-name, + missing-class-docstring, + missing-docstring, + missing-function-docstring, + no-self-use, + protected-access, + redefined-outer-name, + too-many-lines, + wrong-import-order, + wrong-import-position + [REPORTS]