tox: update lint regex to not require column

This is needed to be able to parse output from ansible-lint.

Removes a testcase with a faulty assumption that if the column is
not present the output must be a warning and should not be returned.

It is probably better to allow the user to configure their linting
output themselves.

Also we don't need a separate matcher for sphinx.

Change-Id: I6d06dce921348d3c6fb5a56cdc1e4df675d685c2
This commit is contained in:
Albin Vass 2020-05-02 18:29:00 +02:00
parent 0fdaf8d36b
commit 53f2444dbb
3 changed files with 12 additions and 20 deletions

View File

@ -0,0 +1,8 @@
workdir: .
output: |
roles/tox/tasks/main.yaml:41: [EZUULJOBS0001] Loop vars should have zj_ prefix
comments:
roles/tox/tasks/main.yaml:
- line: 41
message: "[EZUULJOBS0001] Loop vars should have zj_ prefix"

View File

@ -1,10 +0,0 @@
---
workdir: .
output: |
tests/test_discovery.py:25: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
config = yaml.load(open('hiera/common.yaml', 'r'))
tests/test_discovery.py:714: UserWarning: Policy "foo:create_bar":"role:fizz" was deprecated in N in favor of "foo:create_bar":"". Reason: because of reasons. Either ensure your deployment is ready for the new default or copy/paste the deprecated policy into your policy file and maintain it manually.
warnings.warn(deprecated_msg)
WARNING [oslo_policy.policy] Policies ['foo', 'bar'] are part of a cyclical reference.
WARNING [oslo_policy.policy] Policies ['foo', 'bar'] are part of a cyclical reference.
comments: {}

View File

@ -41,8 +41,7 @@ import re
from ansible.module_utils.basic import AnsibleModule
ANSI_RE = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
PEP8_RE = re.compile(r"^(.*):(\d+):(\d+): (.*)$")
SPHINX_RE = re.compile(r"^([^:]*):([\d]+):(\w.+)$")
LINT_RE = re.compile(r"^([^:]*):(\d+):((\d+):)?\s?(.*)$")
def simple_matcher(line, regex, file_path_group, start_line_group,
@ -58,17 +57,12 @@ def simple_matcher(line, regex, file_path_group, start_line_group,
return file_path, start_line, message
def pep8_matcher(line):
return simple_matcher(line, PEP8_RE, 1, 2, 4)
def sphinx_matcher(line):
return simple_matcher(line, SPHINX_RE, 1, 2, 3)
def lint_matcher(line):
return simple_matcher(line, LINT_RE, 1, 2, 5)
matchers = [
pep8_matcher,
sphinx_matcher,
lint_matcher,
]