From ace3fe36a4579ebb6f70ae78a374cce17b4df6ca Mon Sep 17 00:00:00 2001 From: Matthijs Wendelaar Date: Tue, 5 Nov 2019 11:51:12 +0100 Subject: [PATCH 01/20] changed copyright to Warpnet --- saltlint/__main__.py | 2 +- saltlint/cli.py | 2 +- saltlint/config.py | 2 +- saltlint/formatters/__init__.py | 2 +- saltlint/linter.py | 2 +- saltlint/rules/FileExtensionRule.py | 6 +++--- saltlint/rules/FileModeLeadingZeroRule.py | 6 +++--- saltlint/rules/FileModeQuotationRule.py | 6 +++--- saltlint/rules/JinjaCommentHasSpacesRule.py | 6 +++--- saltlint/rules/JinjaPillarGrainsGetFormatRule.py | 6 +++--- saltlint/rules/JinjaStatementHasSpacesRule.py | 6 +++--- saltlint/rules/JinjaVariableHasSpacesRule.py | 6 +++--- saltlint/rules/LineTooLongRule.py | 6 +++--- saltlint/rules/NoTabsRule.py | 6 +++--- saltlint/rules/TrailingWhitespaceRule.py | 2 +- saltlint/rules/YamlHasOctalValueRule.py | 6 +++--- saltlint/utils.py | 2 +- tests/__init__.py | 2 +- tests/unit/TestConfig.py | 2 +- tests/unit/TestFileExtension.py | 2 +- tests/unit/TestFileModeLeadingZeroRule.py | 2 +- tests/unit/TestFileModeQuotationRule.py | 2 +- tests/unit/TestJinjaCommentHasSpaces.py | 2 +- tests/unit/TestJinjaPillarGrainsGetFormatRule.py | 2 +- tests/unit/TestJinjaStatementHasSpaces.py | 2 +- tests/unit/TestJinjaVariableHasSpaces.py | 2 +- tests/unit/TestLineTooLong.py | 2 +- tests/unit/TestNoTabsRule.py | 2 +- tests/unit/TestRunner.py | 2 +- tests/unit/TestSkipRule.py | 2 +- tests/unit/TestTrailingWhitespaceRule.py | 2 +- tests/unit/TestYamlHasOctalValueRule.py | 2 +- 32 files changed, 52 insertions(+), 52 deletions(-) diff --git a/saltlint/__main__.py b/saltlint/__main__.py index 1479c67..3061793 100644 --- a/saltlint/__main__.py +++ b/saltlint/__main__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 Will Thames -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import sys import errno diff --git a/saltlint/cli.py b/saltlint/cli.py index 8ef1de8..a550cd0 100644 --- a/saltlint/cli.py +++ b/saltlint/cli.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 Will Thames -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. from __future__ import print_function diff --git a/saltlint/config.py b/saltlint/config.py index 65202f6..d384f5a 100644 --- a/saltlint/config.py +++ b/saltlint/config.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2019 Roald Nefs +# Copyright (c) 2019 Warpnet B.V. import yaml import os diff --git a/saltlint/formatters/__init__.py b/saltlint/formatters/__init__.py index ab7abf8..8b4e399 100644 --- a/saltlint/formatters/__init__.py +++ b/saltlint/formatters/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import json diff --git a/saltlint/linter.py b/saltlint/linter.py index 22290a8..aefe57f 100644 --- a/saltlint/linter.py +++ b/saltlint/linter.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 Will Thames -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. from __future__ import print_function diff --git a/saltlint/rules/FileExtensionRule.py b/saltlint/rules/FileExtensionRule.py index afe39f5..58255b8 100644 --- a/saltlint/rules/FileExtensionRule.py +++ b/saltlint/rules/FileExtensionRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Tsukinowa Inc. -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Tsukinowa Inc. +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule diff --git a/saltlint/rules/FileModeLeadingZeroRule.py b/saltlint/rules/FileModeLeadingZeroRule.py index fd1a71a..aa59c37 100644 --- a/saltlint/rules/FileModeLeadingZeroRule.py +++ b/saltlint/rules/FileModeLeadingZeroRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/FileModeQuotationRule.py b/saltlint/rules/FileModeQuotationRule.py index 367aabb..1425d44 100644 --- a/saltlint/rules/FileModeQuotationRule.py +++ b/saltlint/rules/FileModeQuotationRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/JinjaCommentHasSpacesRule.py b/saltlint/rules/JinjaCommentHasSpacesRule.py index efbe7f4..9d25efb 100644 --- a/saltlint/rules/JinjaCommentHasSpacesRule.py +++ b/saltlint/rules/JinjaCommentHasSpacesRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/JinjaPillarGrainsGetFormatRule.py b/saltlint/rules/JinjaPillarGrainsGetFormatRule.py index 88e8271..ff2ee59 100644 --- a/saltlint/rules/JinjaPillarGrainsGetFormatRule.py +++ b/saltlint/rules/JinjaPillarGrainsGetFormatRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/JinjaStatementHasSpacesRule.py b/saltlint/rules/JinjaStatementHasSpacesRule.py index da60159..bbd7e6e 100644 --- a/saltlint/rules/JinjaStatementHasSpacesRule.py +++ b/saltlint/rules/JinjaStatementHasSpacesRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/JinjaVariableHasSpacesRule.py b/saltlint/rules/JinjaVariableHasSpacesRule.py index 1b447ba..3957a90 100644 --- a/saltlint/rules/JinjaVariableHasSpacesRule.py +++ b/saltlint/rules/JinjaVariableHasSpacesRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/rules/LineTooLongRule.py b/saltlint/rules/LineTooLongRule.py index c3c999f..d3b5537 100644 --- a/saltlint/rules/LineTooLongRule.py +++ b/saltlint/rules/LineTooLongRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule diff --git a/saltlint/rules/NoTabsRule.py b/saltlint/rules/NoTabsRule.py index 97d4ea3..a143f52 100644 --- a/saltlint/rules/NoTabsRule.py +++ b/saltlint/rules/NoTabsRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule diff --git a/saltlint/rules/TrailingWhitespaceRule.py b/saltlint/rules/TrailingWhitespaceRule.py index 2dc2828..199e3d5 100644 --- a/saltlint/rules/TrailingWhitespaceRule.py +++ b/saltlint/rules/TrailingWhitespaceRule.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 Will Thames -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule diff --git a/saltlint/rules/YamlHasOctalValueRule.py b/saltlint/rules/YamlHasOctalValueRule.py index 7100a68..1ec3c9d 100644 --- a/saltlint/rules/YamlHasOctalValueRule.py +++ b/saltlint/rules/YamlHasOctalValueRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2016, Will Thames and contributors -# Copyright (c) 2018, Ansible Project -# Modified work Copyright (c) 2019 Roald Nefs +# Copyright (c) 2016 Will Thames and contributors +# Copyright (c) 2018 Ansible Project +# Modified work Copyright (c) 2019 Warpnet B.V. from saltlint.linter import SaltLintRule import re diff --git a/saltlint/utils.py b/saltlint/utils.py index c9a76ab..6d01e0e 100644 --- a/saltlint/utils.py +++ b/saltlint/utils.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2014 Will Thames -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import glob import imp diff --git a/tests/__init__.py b/tests/__init__.py index d20be8d..316e73a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import tempfile diff --git a/tests/unit/TestConfig.py b/tests/unit/TestConfig.py index 48094ba..b23c32a 100644 --- a/tests/unit/TestConfig.py +++ b/tests/unit/TestConfig.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2019 Roald Nefs +# Copyright (c) 2019 Warpnet B.V. import unittest import tempfile diff --git a/tests/unit/TestFileExtension.py b/tests/unit/TestFileExtension.py index 8852a37..667054c 100644 --- a/tests/unit/TestFileExtension.py +++ b/tests/unit/TestFileExtension.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2019 Roald Nefs +# Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestFileModeLeadingZeroRule.py b/tests/unit/TestFileModeLeadingZeroRule.py index 3ef8f05..30156bf 100644 --- a/tests/unit/TestFileModeLeadingZeroRule.py +++ b/tests/unit/TestFileModeLeadingZeroRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestFileModeQuotationRule.py b/tests/unit/TestFileModeQuotationRule.py index b98937c..13fcff1 100644 --- a/tests/unit/TestFileModeQuotationRule.py +++ b/tests/unit/TestFileModeQuotationRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestJinjaCommentHasSpaces.py b/tests/unit/TestJinjaCommentHasSpaces.py index da91c69..d8dae99 100644 --- a/tests/unit/TestJinjaCommentHasSpaces.py +++ b/tests/unit/TestJinjaCommentHasSpaces.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestJinjaPillarGrainsGetFormatRule.py b/tests/unit/TestJinjaPillarGrainsGetFormatRule.py index 4a843d0..84e9d7e 100644 --- a/tests/unit/TestJinjaPillarGrainsGetFormatRule.py +++ b/tests/unit/TestJinjaPillarGrainsGetFormatRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Jeffrey Bouter +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestJinjaStatementHasSpaces.py b/tests/unit/TestJinjaStatementHasSpaces.py index 375faea..9e965af 100644 --- a/tests/unit/TestJinjaStatementHasSpaces.py +++ b/tests/unit/TestJinjaStatementHasSpaces.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestJinjaVariableHasSpaces.py b/tests/unit/TestJinjaVariableHasSpaces.py index 6f8efb9..a066818 100644 --- a/tests/unit/TestJinjaVariableHasSpaces.py +++ b/tests/unit/TestJinjaVariableHasSpaces.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestLineTooLong.py b/tests/unit/TestLineTooLong.py index 86c2a7f..07b6169 100644 --- a/tests/unit/TestLineTooLong.py +++ b/tests/unit/TestLineTooLong.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestNoTabsRule.py b/tests/unit/TestNoTabsRule.py index 3fac152..ba336ff 100644 --- a/tests/unit/TestNoTabsRule.py +++ b/tests/unit/TestNoTabsRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestRunner.py b/tests/unit/TestRunner.py index 8e8cad5..62eea64 100644 --- a/tests/unit/TestRunner.py +++ b/tests/unit/TestRunner.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2019 Roald Nefs +# Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestSkipRule.py b/tests/unit/TestSkipRule.py index c290145..7264c29 100644 --- a/tests/unit/TestSkipRule.py +++ b/tests/unit/TestSkipRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestTrailingWhitespaceRule.py b/tests/unit/TestTrailingWhitespaceRule.py index e7b6dbc..6f54abf 100644 --- a/tests/unit/TestTrailingWhitespaceRule.py +++ b/tests/unit/TestTrailingWhitespaceRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest diff --git a/tests/unit/TestYamlHasOctalValueRule.py b/tests/unit/TestYamlHasOctalValueRule.py index 0921bf1..46b0495 100644 --- a/tests/unit/TestYamlHasOctalValueRule.py +++ b/tests/unit/TestYamlHasOctalValueRule.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2013-2018 Will Thames # Copyright (c) 2018 Ansible by Red Hat -# Modified work Copyright (c) 2019 Roald Nefs +# Modified work Copyright (c) 2019 Warpnet B.V. import unittest From ead17450835151728da38a09ec98eb349d1ca12f Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Thu, 7 Nov 2019 21:26:00 +0100 Subject: [PATCH 02/20] Add Python 3.8 job to Travis CI Add Python 3.8 job to Travis CI, which requires installing distro because there is still a bug in SaltStack with Python 3.8: https://github.com/saltstack/salt/issues/55029 This will also add pip cache and lower depth git clone in the Travis configuration. Signed-off-by: Roald Nefs --- .travis.yml | 16 ++++++++++++++++ tox.ini | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a384bc8..4e66f15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ dist: bionic language: python +cache: pip + +git: + depth: 100 + matrix: include: - env: TOXENV=flake8 @@ -38,6 +43,17 @@ matrix: script: - tox + - python: 3.8 + env: TOXENV=py38 + install: + # Required due to missing dependency in Python 3.8, for more + # information see: + # https://github.com/saltstack/salt/issues/55029 + - pip install distro + - pip install tox + script: + - tox + - language: generic sudo: false env: diff --git a/tox.ini b/tox.ini index e2a28e7..c1f9c40 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 3.5.3 -envlist = flake8-py{37,36,35,27}-salt +envlist = flake8-py{38,37,36,35,27}-salt skip_missing_interpreters = True [testenv] From f1b180e98887184a81da893a61f2399b86fd8571 Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Thu, 7 Nov 2019 21:34:55 +0100 Subject: [PATCH 03/20] Update py38 job in Travis configuration Signed-off-by: Roald Nefs --- .travis.yml | 4 ---- tox.ini | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e66f15..89135e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,10 +46,6 @@ matrix: - python: 3.8 env: TOXENV=py38 install: - # Required due to missing dependency in Python 3.8, for more - # information see: - # https://github.com/saltstack/salt/issues/55029 - - pip install distro - pip install tox script: - tox diff --git a/tox.ini b/tox.ini index c1f9c40..b85fe7b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,10 @@ skip_missing_interpreters = True [testenv] passenv = HOME TRAVIS TRAVIS_* deps = + # Required due to missing dependency in Python 3.8, for more + # information see: + # https://github.com/saltstack/salt/issues/55029 + distro salt coveralls -rtest-deps.txt From 98646bbc5637e31e86b9f7f6a3caf77ea03624d6 Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Fri, 8 Nov 2019 07:34:54 +0100 Subject: [PATCH 04/20] Add distro as a dependency for py38 Signed-off-by: Roald Nefs --- setup.py | 9 ++++++++- tox.ini | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index f5f2915..fe9d681 100644 --- a/setup.py +++ b/setup.py @@ -21,11 +21,18 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import io +import sys from setuptools import setup, find_packages from saltlint import (__author__, __license__, NAME, VERSION, DESCRIPTION) +REQUIRES = ['salt', 'pathspec>=0.6.0'] +if sys.version_info.major == 3 and sys.version_info.minor == 8: + # Required due to missing dependency in Python 3.8, for more + # information see: + # https://github.com/saltstack/salt/issues/55029 + REQUIRES = ['distro'] + REQUIRES # Read long description from the README.md file with io.open('README.md', 'r', encoding='utf-8') as readme_file: @@ -49,7 +56,7 @@ }, include_package_data=True, python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', - install_requires=['salt', 'pathspec>=0.6.0'], + install_requires=REQUIRES, license=__license__, zip_safe=False, classifiers=[ diff --git a/tox.ini b/tox.ini index b85fe7b..c1f9c40 100644 --- a/tox.ini +++ b/tox.ini @@ -6,10 +6,6 @@ skip_missing_interpreters = True [testenv] passenv = HOME TRAVIS TRAVIS_* deps = - # Required due to missing dependency in Python 3.8, for more - # information see: - # https://github.com/saltstack/salt/issues/55029 - distro salt coveralls -rtest-deps.txt From 6cb7a0b64f24dc1646139a53ef83222cb2ad4812 Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Fri, 8 Nov 2019 07:49:54 +0100 Subject: [PATCH 05/20] Remove salt as a tox depedency Signed-off-by: Roald Nefs --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index c1f9c40..f9a675c 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,6 @@ skip_missing_interpreters = True [testenv] passenv = HOME TRAVIS TRAVIS_* deps = - salt coveralls -rtest-deps.txt commands = From 8f082f4945ed8a172234f2ee414fb33092291cea Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Fri, 8 Nov 2019 11:27:18 +0100 Subject: [PATCH 06/20] Update Travis configuration Signed-off-by: Roald Nefs --- .travis.yml | 119 +++++++++++++++++++++++--------------------------- setup.py | 9 +--- test-deps.txt | 1 + tox.ini | 18 -------- 4 files changed, 57 insertions(+), 90 deletions(-) delete mode 100644 tox.ini diff --git a/.travis.yml b/.travis.yml index 89135e8..0a35a1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,75 +7,66 @@ cache: pip git: depth: 100 -matrix: +jobs: + fast_finish: true + include: - - env: TOXENV=flake8 - install: - - pip install tox - script: - - tox + - python: 3.7 + name: Running linters + script: + - flake8 + + - python: 3.8 + before_install: + - pip install distro + + - python: 3.7 - - python: 2.7 - env: TOXENV=py27 - install: - - pip install tox - script: - - tox + - python: 3.6 - - python: 3.5 - env: TOXENV=py35 - install: - - pip install tox - script: - - tox + - python: 3.5 - - python: 3.6 - env: TOXENV=py36 - install: - - pip install tox - script: - - tox + - python: 2.7 - - python: 3.7 - env: TOXENV=py37 - install: - - pip install tox - script: - - tox + - language: generic + name: Running hadolint + sudo: false + env: + HADOLINT: "${HOME}/hadolint" + install: + # Download hadolint binary and set it as executable + - curl -sL -o ${HADOLINT} "https://github.com/hadolint/hadolint/releases/download/v1.16.0/hadolint-$(uname -s)-$(uname -m)" + && chmod 700 ${HADOLINT} + script: + # List files which name starts with 'Dockerfile' + # eg. Dockerfile, Dockerfile.build, etc. + - git ls-files --exclude='Dockerfile*' --ignored | xargs --max-lines=1 ${HADOLINT} - - python: 3.8 - env: TOXENV=py38 - install: - - pip install tox - script: - - tox + - python: 3.7 + stage: Deploy + name: Publishing current Git tagged version of dist to PyPI + if: repo == "warpnet/salt-lint" AND tag IS present AND branch == "master" AND type NOT IN (cron, pull_request) + before_install: [] + # Deploy a new release to PyPi for every new tag on the 'master' branch on the + # repository 'warpnet/salt-lint'. + deploy: + provider: pypi + user: __token__ + password: + # A PyPI API token can be generated by a PyPi maintainer on: + # https://pypi.org/help/#apitoken + # The API token in encrypted using `travis encrypt api-token`. + secure: "fL3/pkTaRA+cmTdC5Qxo9xoDoxXv6VbwbT3fM5JwW1F0NPbqR7Kw+oMJl2ZKQZrbRxvtPps8dYzxqC0axZ+WRFeVz+FzFeosziU/1kk1U5Bks5VK1my0kPl9jlD1kM0gS8mSm6gdNHJ6Z8quEXuYCMtMhqyCMgw0PWRaMOuuQ5Yi6/olUPjDxkMsFeh+03VIXTXGHPk7GxR3OTbOUaIaQXkbt7RQ7usDHnd1W6jeW5a1Q2h2cvugHfk6B9UYaXnIacCSejD4NJHkE+j3lbVI6QuzBO3MdaEM6V/+P3zDh0ZF9SK2BfXdNqMtCij/u8q0er+Y6ZU1LGDrRuXe6bmRr6KyJfiOsgKOCyLXSNqGGim01eJHO14DUgGrc8qWo1KKywtxagIriMcTxAOccW8RDRy3zkKYdEHgdFs6MtVL2JV+wyhdxxoU6DOZsNn6N8d9WninpAcIPtfiYzBRerQqR0OiKmpDK4Oee9IKCfRhMhWAY7Rs/RV33YluEJbv4bWPcPMPciEUp/xXxwPMWFQ45VoR4ZiwBYz0KoOMb/QrVfN8m8pdEtQpSUX51PFTFzmrreB6OvwJ5aphMrxIpvCJNZ65mfZthDKJUhSo0EG6ix/g4nOR7qlLNMVsQF4qSRCKDJlqUlzXYpQuy0u/QXoihCReO5rI6nWdV/KTfHCYgdo=" + on: + repo: warpnet/salt-lint + tags: true + branch: master + python: 3.7 - - language: generic - sudo: false - env: - HADOLINT: "${HOME}/hadolint" - install: - # Download hadolint binary and set it as executable - - curl -sL -o ${HADOLINT} "https://github.com/hadolint/hadolint/releases/download/v1.16.0/hadolint-$(uname -s)-$(uname -m)" - && chmod 700 ${HADOLINT} - script: - # List files which name starts with 'Dockerfile' - # eg. Dockerfile, Dockerfile.build, etc. - - git ls-files --exclude='Dockerfile*' --ignored | xargs --max-lines=1 ${HADOLINT} +install: + - pip install -r test-deps.txt + - pip install . -# Deploy a new release to PyPi for every new tag on the 'master' branch on the -# repository 'warpnet/salt-lint'. -deploy: - provider: pypi - user: __token__ - password: - # A PyPI API token can be generated by a PyPi maintainer on: - # https://pypi.org/help/#apitoken - # The API token in encrypted using `travis encrypt api-token`. - secure: "fL3/pkTaRA+cmTdC5Qxo9xoDoxXv6VbwbT3fM5JwW1F0NPbqR7Kw+oMJl2ZKQZrbRxvtPps8dYzxqC0axZ+WRFeVz+FzFeosziU/1kk1U5Bks5VK1my0kPl9jlD1kM0gS8mSm6gdNHJ6Z8quEXuYCMtMhqyCMgw0PWRaMOuuQ5Yi6/olUPjDxkMsFeh+03VIXTXGHPk7GxR3OTbOUaIaQXkbt7RQ7usDHnd1W6jeW5a1Q2h2cvugHfk6B9UYaXnIacCSejD4NJHkE+j3lbVI6QuzBO3MdaEM6V/+P3zDh0ZF9SK2BfXdNqMtCij/u8q0er+Y6ZU1LGDrRuXe6bmRr6KyJfiOsgKOCyLXSNqGGim01eJHO14DUgGrc8qWo1KKywtxagIriMcTxAOccW8RDRy3zkKYdEHgdFs6MtVL2JV+wyhdxxoU6DOZsNn6N8d9WninpAcIPtfiYzBRerQqR0OiKmpDK4Oee9IKCfRhMhWAY7Rs/RV33YluEJbv4bWPcPMPciEUp/xXxwPMWFQ45VoR4ZiwBYz0KoOMb/QrVfN8m8pdEtQpSUX51PFTFzmrreB6OvwJ5aphMrxIpvCJNZ65mfZthDKJUhSo0EG6ix/g4nOR7qlLNMVsQF4qSRCKDJlqUlzXYpQuy0u/QXoihCReO5rI6nWdV/KTfHCYgdo=" - on: - repo: warpnet/salt-lint - tags: true - branch: master - python: 3.6 - condition: "$TOXENV = py36" +script: + - coverage run --source=saltlint setup.py test + - coveralls diff --git a/setup.py b/setup.py index fe9d681..f5f2915 100644 --- a/setup.py +++ b/setup.py @@ -21,18 +21,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import io -import sys from setuptools import setup, find_packages from saltlint import (__author__, __license__, NAME, VERSION, DESCRIPTION) -REQUIRES = ['salt', 'pathspec>=0.6.0'] -if sys.version_info.major == 3 and sys.version_info.minor == 8: - # Required due to missing dependency in Python 3.8, for more - # information see: - # https://github.com/saltstack/salt/issues/55029 - REQUIRES = ['distro'] + REQUIRES # Read long description from the README.md file with io.open('README.md', 'r', encoding='utf-8') as readme_file: @@ -56,7 +49,7 @@ }, include_package_data=True, python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', - install_requires=REQUIRES, + install_requires=['salt', 'pathspec>=0.6.0'], license=__license__, zip_safe=False, classifiers=[ diff --git a/test-deps.txt b/test-deps.txt index 4283f38..02187e2 100644 --- a/test-deps.txt +++ b/test-deps.txt @@ -1,2 +1,3 @@ +coveralls flake8 nose diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f9a675c..0000000 --- a/tox.ini +++ /dev/null @@ -1,18 +0,0 @@ -[tox] -minversion = 3.5.3 -envlist = flake8-py{38,37,36,35,27}-salt -skip_missing_interpreters = True - -[testenv] -passenv = HOME TRAVIS TRAVIS_* -deps = - coveralls - -rtest-deps.txt -commands = - coverage run --source=saltlint setup.py test - coveralls - -[testenv:flake8] -deps = flake8 -commands = flake8 -usedevelop = True From e1ed6a1506107d437909f6eb5704126308bb67c4 Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Fri, 8 Nov 2019 15:19:19 +0100 Subject: [PATCH 07/20] Add coverage configuration Signed-off-by: Roald Nefs --- .coveragerc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..5b324a2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,7 @@ +[run] +branch = True + +[report] +exclude_lines = + # Don't complain if non-runnable code isn't run: + if __name__ == .__main__.: From 4b34347cbbdcaddd8ec92c67002b005e28f5353b Mon Sep 17 00:00:00 2001 From: Jeffrey Bouter Date: Sun, 10 Nov 2019 17:45:16 +0100 Subject: [PATCH 08/20] Update README - Add list of plugins --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1052b4..69e3b3f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Options: -L list all the rules -r RULESDIR specify one or more rules directories using one or more -r arguments. Any -r flags override the default - rules in /path/to/salt-lint/saltlint/rules, unless + rules in /path/to/salt-lint/saltlint/rules, unless -R is also used. -R Use default rules in /path/to/salt-lint/saltlint/rules in addition to any @@ -163,6 +163,18 @@ Some rules are bit of a rule of thumb. To skip a specific rule for a specific ta - source: salt://{{unspaced_var}}/example # noqa: 206 ``` +# Plugins + +Currently, there is a `salt-lint` plugin available for the following applications: + +Application | GitHub Link | Store/Marketplace +:-:|:--|:-- +Visual Studio Code | https://github.com/warpnet/vscode-salt-lint | https://marketplace.visualstudio.com/items?itemName=warpnet.salt-lint +Sublime Text | https://github.com/warpnet/SublimeLinter-salt-lint | https://packagecontrol.io/packages/SublimeLinter-contrib-salt-lint + + +Wish to create a `salt-lint` extension for your favourite editor? We're always looking for [contributions](CONTRIBUTING.md)! + # Authors The project is heavily based on [ansible-lint](https://github.com/ansible/ansible-lint), with the modified work by [Warpnet B.V.](https://github.com/warpnet). [ansible-lint](https://github.com/ansible/ansible-lint) was created by [Will Thames](https://github.com/willthames) and is now maintained as part of the [Ansible](https://www.ansible.com/) by [Red Hat](https://www.redhat.com) project. From c29066a579e40aecbefe893f3ae008a80ab5513b Mon Sep 17 00:00:00 2001 From: Jeffrey Bouter Date: Sun, 10 Nov 2019 17:51:01 +0100 Subject: [PATCH 09/20] Update README - Make links prettier --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69e3b3f..caa168a 100644 --- a/README.md +++ b/README.md @@ -169,8 +169,8 @@ Currently, there is a `salt-lint` plugin available for the following application Application | GitHub Link | Store/Marketplace :-:|:--|:-- -Visual Studio Code | https://github.com/warpnet/vscode-salt-lint | https://marketplace.visualstudio.com/items?itemName=warpnet.salt-lint -Sublime Text | https://github.com/warpnet/SublimeLinter-salt-lint | https://packagecontrol.io/packages/SublimeLinter-contrib-salt-lint +Visual Studio Code | [warpnet/vscode-salt-lint](https://github.com/warpnet/vscode-salt-lint) | [VisualStudio Marketplace](https://marketplace.visualstudio.com/items?itemName=warpnet.salt-lint) +Sublime Text | [warpnet/SublimeLinter-salt-lint](https://github.com/warpnet/SublimeLinter-salt-lint) | [Package Control](https://packagecontrol.io/packages/SublimeLinter-contrib-salt-lint) Wish to create a `salt-lint` extension for your favourite editor? We're always looking for [contributions](CONTRIBUTING.md)! From 4c59ed1c37cfe7e68995838daf1fe0e3f4b9aaf6 Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Mon, 11 Nov 2019 22:35:35 +0100 Subject: [PATCH 10/20] Fix typos in saltlint/linter.py Signed-off-by: Roald Nefs --- saltlint/linter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saltlint/linter.py b/saltlint/linter.py index aefe57f..bb818f2 100644 --- a/saltlint/linter.py +++ b/saltlint/linter.py @@ -100,7 +100,7 @@ def run(self, statefile, tags=set(), skip_list=frozenset()): with codecs.open(statefile['path'], mode='rb', encoding='utf-8') as f: text = f.read() except IOError as e: - print("WARNING: Coudn't open %s - %s" % + print("WARNING: Couldn't open %s - %s" % (statefile['path'], e.strerror), file=sys.stderr) return matches @@ -111,7 +111,7 @@ def run(self, statefile, tags=set(), skip_list=frozenset()): rule_definition = set(rule.tags) rule_definition.add(rule.id) - # Check if the the file is in the rule specific ignore list. + # Check if the file is in the rule specific ignore list. for definition in rule_definition: if self.config.is_file_ignored(statefile['path'], definition): skip = True From 2d20ba41243ea91ce4e71e0d6bcb72098f220941 Mon Sep 17 00:00:00 2001 From: Henk Date: Wed, 13 Nov 2019 17:02:11 +0100 Subject: [PATCH 11/20] Added fixes for common issues Signed-off-by: Henk --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1052b4..482d46c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Options: -L list all the rules -r RULESDIR specify one or more rules directories using one or more -r arguments. Any -r flags override the default - rules in /path/to/salt-lint/saltlint/rules, unless + rules in /path/to/salt-lint/saltlint/rules, unless -R is also used. -R Use default rules in /path/to/salt-lint/saltlint/rules in addition to any @@ -134,7 +134,6 @@ To use salt-lint with [pre-commit](https://pre-commit.com), just add the follow # Rules - ## List of rules Rule | Description @@ -142,7 +141,7 @@ Rule | Description [201](https://github.com/warpnet/salt-lint/wiki/201) | Trailing whitespace [202](https://github.com/warpnet/salt-lint/wiki/202) | Jinja statement should have spaces before and after: `{% statement %}` [203](https://github.com/warpnet/salt-lint/wiki/203) | Most files should not contain tabs -[204](https://github.com/warpnet/salt-lint/wiki/204) | Lines should be no longer that 160 chars +[204](https://github.com/warpnet/salt-lint/wiki/204) | Lines should be no longer than 160 chars [205](https://github.com/warpnet/salt-lint/wiki/205) | Use ".sls" as a Salt State file extension [206](https://github.com/warpnet/salt-lint/wiki/206) | Jinja variables should have spaces before and after `{{ var_name }}` [207](https://github.com/warpnet/salt-lint/wiki/207) | File modes should always be encapsulated in quotation marks @@ -152,7 +151,6 @@ Rule | Description [211](https://github.com/warpnet/salt-lint/wiki/211) | `pillar.get` or `grains.get` should be formatted differently [212](https://github.com/warpnet/salt-lint/wiki/212) | Most files should not contain irregular spaces - ## False Positives: Skipping Rules Some rules are bit of a rule of thumb. To skip a specific rule for a specific task, inside your state add `# noqa [rule_id]` at the end of the line. You can skip multiple rules via a space-separated list. Example: @@ -163,6 +161,19 @@ Some rules are bit of a rule of thumb. To skip a specific rule for a specific ta - source: salt://{{unspaced_var}}/example # noqa: 206 ``` +# Fix common issues + +`sed` might be one of the better tools to fix common issues. + +Fix spacing arround `{{ var_name }}`, eg. `{{env}}` --> `{{ env }}`:\ +`sed -i -E "s/\{\{\s?([^}]*[^} ])\s?\}\}/\{\{ \1 \}\}/g" $(find salt -name '*.sls')` + +Make the `dir_mode`, `file_mode` and `mode` arguments in the desired syntax:\ +`sed -i -E "s/\b(dir_|file_|)mode: 0?([0-7]{3})/\1mode: '0\2'/" $(find salt -name '*.sls')` + +Add quotes arround numeric values that start with a `0`:\ +`sed -i -E "s/\b(minute|hour): (0[0-7]?)\$/\1: '\2'/" $(find salt -name '*.sls')` + # Authors The project is heavily based on [ansible-lint](https://github.com/ansible/ansible-lint), with the modified work by [Warpnet B.V.](https://github.com/warpnet). [ansible-lint](https://github.com/ansible/ansible-lint) was created by [Will Thames](https://github.com/willthames) and is now maintained as part of the [Ansible](https://www.ansible.com/) by [Red Hat](https://www.redhat.com) project. From 7d2a223eea45793dc8a56906420411d0f30930ed Mon Sep 17 00:00:00 2001 From: Jeffrey Bouter Date: Wed, 13 Nov 2019 21:23:44 +0100 Subject: [PATCH 12/20] Update documentation - Add explanation regarding sed commands. - Change to assume salt is CWD Signed-off-by: Jeffrey Bouter --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42cc9d8..ba54d56 100644 --- a/README.md +++ b/README.md @@ -174,16 +174,18 @@ Wish to create a `salt-lint` extension for your favourite editor? We're always l # Fix common issues -`sed` might be one of the better tools to fix common issues. +`sed` might be one of the better tools to fix common issues, as shown in commands below. + +**Note**: these commands assume your current working directory is the salt directory/repository. Fix spacing arround `{{ var_name }}`, eg. `{{env}}` --> `{{ env }}`:\ -`sed -i -E "s/\{\{\s?([^}]*[^} ])\s?\}\}/\{\{ \1 \}\}/g" $(find salt -name '*.sls')` +`sed -i -E "s/\{\{\s?([^}]*[^} ])\s?\}\}/\{\{ \1 \}\}/g" $(find . -name '*.sls')` Make the `dir_mode`, `file_mode` and `mode` arguments in the desired syntax:\ -`sed -i -E "s/\b(dir_|file_|)mode: 0?([0-7]{3})/\1mode: '0\2'/" $(find salt -name '*.sls')` +`sed -i -E "s/\b(dir_|file_|)mode: 0?([0-7]{3})/\1mode: '0\2'/" $(find . -name '*.sls')` Add quotes arround numeric values that start with a `0`:\ -`sed -i -E "s/\b(minute|hour): (0[0-7]?)\$/\1: '\2'/" $(find salt -name '*.sls')` +`sed -i -E "s/\b(minute|hour): (0[0-7]?)\$/\1: '\2'/" $(find . -name '*.sls')` # Authors From c66960f294f356f635c975e69938d8c247212c72 Mon Sep 17 00:00:00 2001 From: Jeffrey Bouter <6340770+jbouter@users.noreply.github.com> Date: Wed, 13 Nov 2019 21:25:25 +0100 Subject: [PATCH 13/20] Update README.md Add clarification on salt states. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba54d56..168aeec 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ Wish to create a `salt-lint` extension for your favourite editor? We're always l `sed` might be one of the better tools to fix common issues, as shown in commands below. -**Note**: these commands assume your current working directory is the salt directory/repository. +**Note**: these commands assume your current working directory is the salt (states) directory/repository. Fix spacing arround `{{ var_name }}`, eg. `{{env}}` --> `{{ env }}`:\ `sed -i -E "s/\{\{\s?([^}]*[^} ])\s?\}\}/\{\{ \1 \}\}/g" $(find . -name '*.sls')` From efbd29024c9df98e2f6d71a77d8e4206e721abd0 Mon Sep 17 00:00:00 2001 From: Chandler Newby Date: Thu, 14 Nov 2019 16:52:58 -0700 Subject: [PATCH 14/20] Add severity to standard output. Fixes #93 --- saltlint/config.py | 5 +++++ saltlint/formatters/__init__.py | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/saltlint/config.py b/saltlint/config.py index 65202f6..b64a59a 100644 --- a/saltlint/config.py +++ b/saltlint/config.py @@ -98,6 +98,11 @@ def _parse(self, content): # Parse json self.json = self._options.get('json', False) + # Parse add severity + self.add_severity = self._options.get('add_severity', False) + if 'add-severity' in config: + self.add_severity = config['add-severity'] + # Parse rule specific configuration, the configration can be listed by # the rule ID and/or tag. self.rules = dict() diff --git a/saltlint/formatters/__init__.py b/saltlint/formatters/__init__.py index ab7abf8..5dfa87d 100644 --- a/saltlint/formatters/__init__.py +++ b/saltlint/formatters/__init__.py @@ -14,12 +14,16 @@ class Formatter(object): - def process(self, matches, colored=False): + def process(self, matches, colored=False, add_severity=False): for match in matches: - print(self.format(match, colored)) + print(self.format(match, colored, add_severity)) + + def format(self, match, colored=False, add_severity=False): + if add_severity: + formatstr = u"{0}{sev} {1}\n{2}:{3}\n{4}\n" + else: + formatstr = u"{0} {1}\n{2}:{3}\n{4}\n" - def format(self, match, colored=False): - formatstr = u"{0} {1}\n{2}:{3}\n{4}\n" if colored: color = saltcolor.get_colors() return formatstr.format( @@ -31,7 +35,9 @@ def format(self, match, colored=False): color['ENDC']), u'{0}{1}{2}'.format(color['CYAN'], str(match.linenumber), color['ENDC']), - u'{0}{1}{2}'.format(color['MAGENTA'], match.line, color['ENDC']) + u'{0}{1}{2}'.format(color['MAGENTA'], match.line, color['ENDC']), + sev=u'{0}[{1}]{2}'.format(color['RED'], match.rule.severity, + color['ENDC']) ) else: return formatstr.format( @@ -39,7 +45,8 @@ def format(self, match, colored=False): match.message, match.filename, match.linenumber, - match.line) + match.line, + sev=match.rule.severity) class JsonFormatter(object): From cfbfd583012bc488c3f4664dd2d95001c17b92cb Mon Sep 17 00:00:00 2001 From: Chandler Newby Date: Thu, 14 Nov 2019 16:57:20 -0700 Subject: [PATCH 15/20] Add add-severity to README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1052b4..e3ca9e2 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Options: -L list all the rules -r RULESDIR specify one or more rules directories using one or more -r arguments. Any -r flags override the default - rules in /path/to/salt-lint/saltlint/rules, unless + rules in /path/to/salt-lint/saltlint/rules, unless -R is also used. -R Use default rules in /path/to/salt-lint/saltlint/rules in addition to any @@ -54,6 +54,7 @@ Options: path to directories or files to skip. This option is repeatable. --json parse the output as JSON + --add-severity add the severity to standard output -c C Specify configuration file to use. Defaults to ".salt-lint" ``` @@ -112,6 +113,7 @@ rules: *.jinja 210: ignore: 'exclude_this_file.sls' +add-severity: True ``` ## Pre-commit Setup From 7bbfb111e0a2865dd3b3527fad81e7530eda456d Mon Sep 17 00:00:00 2001 From: Chandler Newby Date: Thu, 14 Nov 2019 17:00:22 -0700 Subject: [PATCH 16/20] Json parameter now works in config file --- saltlint/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/saltlint/config.py b/saltlint/config.py index 65202f6..b7c4f8a 100644 --- a/saltlint/config.py +++ b/saltlint/config.py @@ -97,6 +97,8 @@ def _parse(self, content): # Parse json self.json = self._options.get('json', False) + if 'json' in config: + self.json = config['json'] # Parse rule specific configuration, the configration can be listed by # the rule ID and/or tag. From 8d936a4085b6585429d81907ef611f0290f698c2 Mon Sep 17 00:00:00 2001 From: Chandler Newby Date: Thu, 14 Nov 2019 17:25:49 -0700 Subject: [PATCH 17/20] Add brackets around severity in nocolor output --- saltlint/formatters/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saltlint/formatters/__init__.py b/saltlint/formatters/__init__.py index 5dfa87d..c887bfd 100644 --- a/saltlint/formatters/__init__.py +++ b/saltlint/formatters/__init__.py @@ -46,7 +46,7 @@ def format(self, match, colored=False, add_severity=False): match.filename, match.linenumber, match.line, - sev=match.rule.severity) + sev=u'[{0}]'.format(match.rule.severity)) class JsonFormatter(object): From 8bf8b3cf1ca76d04985da96074d7cc5819bbaebf Mon Sep 17 00:00:00 2001 From: Jeffrey Bouter Date: Fri, 15 Nov 2019 10:31:27 +0100 Subject: [PATCH 18/20] Update CLI options to support British - Add support for --nocolour and --force-colour Fixes #89 Signed-off-by: Jeffrey Bouter --- saltlint/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saltlint/cli.py b/saltlint/cli.py index a550cd0..56eb55c 100644 --- a/saltlint/cli.py +++ b/saltlint/cli.py @@ -52,11 +52,11 @@ def run(args=None): parser.add_option('-x', dest='skip_list', default=[], action='append', help="only check rules whose id/tags do not " + "match these values") - parser.add_option('--nocolor', dest='colored', + parser.add_option('--nocolor', '--nocolour', dest='colored', default=hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(), action='store_false', help="disable colored output") - parser.add_option('--force-color', dest='colored', + parser.add_option('--force-color', '--force-colour', dest='colored', action='store_true', help="Try force colored output (relying on salt's code)") parser.add_option('--exclude', dest='exclude_paths', action='append', From b611de71494b35c841d984a24a871e6c8000a790 Mon Sep 17 00:00:00 2001 From: Chandler Newby Date: Wed, 20 Nov 2019 15:38:30 -0700 Subject: [PATCH 19/20] Make severity formatter more in line with ansible-lint --- README.md | 4 ++-- saltlint/cli.py | 4 ++++ saltlint/config.py | 6 +++--- saltlint/formatters/__init__.py | 38 +++++++++++++++++++++++++++------ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e3ca9e2..046b49f 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Options: path to directories or files to skip. This option is repeatable. --json parse the output as JSON - --add-severity add the severity to standard output + --severity add the severity to the standard output -c C Specify configuration file to use. Defaults to ".salt-lint" ``` @@ -113,7 +113,7 @@ rules: *.jinja 210: ignore: 'exclude_this_file.sls' -add-severity: True +severity: True ``` ## Pre-commit Setup diff --git a/saltlint/cli.py b/saltlint/cli.py index 8ef1de8..eabbd42 100644 --- a/saltlint/cli.py +++ b/saltlint/cli.py @@ -65,6 +65,8 @@ def run(args=None): default=[]) parser.add_option('--json', dest='json', action='store_true', default=False, help='parse the output as JSON') + parser.add_option('--severity', dest='severity', action='store_true', default=False, + help='add the severity to the standard output') parser.add_option('-c', help='Specify configuration file to use. Defaults to ".salt-lint"') (options, parsed_args) = parser.parse_args(args if args is not None else sys.argv[1:]) @@ -111,6 +113,8 @@ def run(args=None): # Define the formatter if config.json: formatter = formatters.JsonFormatter() + elif config.severity: + formatter = formatters.SeverityFormatter() else: formatter = formatters.Formatter() diff --git a/saltlint/config.py b/saltlint/config.py index b64a59a..b45823a 100644 --- a/saltlint/config.py +++ b/saltlint/config.py @@ -99,9 +99,9 @@ def _parse(self, content): self.json = self._options.get('json', False) # Parse add severity - self.add_severity = self._options.get('add_severity', False) - if 'add-severity' in config: - self.add_severity = config['add-severity'] + self.severity = self._options.get('severity', False) + if 'severity' in config: + self.severity = config['severity'] # Parse rule specific configuration, the configration can be listed by # the rule ID and/or tag. diff --git a/saltlint/formatters/__init__.py b/saltlint/formatters/__init__.py index c887bfd..bd07f66 100644 --- a/saltlint/formatters/__init__.py +++ b/saltlint/formatters/__init__.py @@ -14,15 +14,41 @@ class Formatter(object): - def process(self, matches, colored=False, add_severity=False): + def process(self, matches, colored=False): for match in matches: - print(self.format(match, colored, add_severity)) + print(self.format(match, colored)) - def format(self, match, colored=False, add_severity=False): - if add_severity: - formatstr = u"{0}{sev} {1}\n{2}:{3}\n{4}\n" + def format(self, match, colored=False): + formatstr = u"{0} {1}\n{2}:{3}\n{4}\n" + if colored: + color = saltcolor.get_colors() + return formatstr.format( + u'{0}[{1}]{2}'.format(color['RED'], match.rule.id, + color['ENDC']), + u'{0}{1}{2}'.format(color['LIGHT_RED'], match.message, + color['ENDC']), + u'{0}{1}{2}'.format(color['BLUE'], match.filename, + color['ENDC']), + u'{0}{1}{2}'.format(color['CYAN'], str(match.linenumber), + color['ENDC']), + u'{0}{1}{2}'.format(color['MAGENTA'], match.line, color['ENDC']) + ) else: - formatstr = u"{0} {1}\n{2}:{3}\n{4}\n" + return formatstr.format( + u'[{0}]'.format(match.rule.id), + match.message, + match.filename, + match.linenumber, + match.line) + + +class SeverityFormatter(object): + def process(self, matches, colored=False): + for match in matches: + print(self.format(match, colored)) + + def format(self, match, colored=False): + formatstr = u"{0} {sev} {1}\n{2}:{3}\n{4}\n" if colored: color = saltcolor.get_colors() From 45f260d24ad9e7706c3e3ad9a506dd742f322f6b Mon Sep 17 00:00:00 2001 From: Roald Nefs Date: Thu, 21 Nov 2019 22:16:22 +0100 Subject: [PATCH 20/20] Bump version to v0.2.0 Signed-off-by: Roald Nefs --- docker/Dockerfile | 2 +- saltlint/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index abc50f9..362e7d4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer="info@warpnet.nl" RUN apk add --no-cache gcc g++ build-base libzmq musl-dev zeromq-dev # Install the salt-lint package -RUN pip install --no-cache salt-lint==v0.1.0 +RUN pip install --no-cache salt-lint==v0.2.0 # Remove development utilities RUN apk del --no-cache gcc g++ build-base libzmq musl-dev zeromq-dev \ diff --git a/saltlint/__init__.py b/saltlint/__init__.py index 086232a..1787459 100644 --- a/saltlint/__init__.py +++ b/saltlint/__init__.py @@ -5,7 +5,7 @@ """ NAME = 'salt-lint' -VERSION = '0.1.0' +VERSION = '0.2.0' DESCRIPTION = __doc__ __author__ = 'Warpnet B.V.'