From ad22de1e2e6acf7c82ab5ff3c91de89e9d0dc6fb Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 4 Feb 2021 15:52:42 +0000 Subject: [PATCH] Drop E suffix when printing rule id From now on we no longer print E before rule id on parseable and normal printing because it both reduced readability of the text and also because it was misleading, some errors may be only warnings but we always displayed only E. This will also make it easier for us to migrate to text rule ids, which are more human friendly. --- src/ansiblelint/formatters/__init__.py | 4 ++-- test/TestUtils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansiblelint/formatters/__init__.py b/src/ansiblelint/formatters/__init__.py index f70adf2b66..e310e740a6 100644 --- a/src/ansiblelint/formatters/__init__.py +++ b/src/ansiblelint/formatters/__init__.py @@ -83,7 +83,7 @@ class ParseableFormatter(BaseFormatter): def format(self, match: "MatchError") -> str: result = ( f"[filename]{self._format_path(match.filename or '')}[/]:{match.position}: " - f"[error_code]E{match.rule.id}[/] [dim]{self.escape(match.message)}[/]") + f"[error_code]{match.rule.id}[/] [dim]{self.escape(match.message)}[/]") if match.tag: result += f" [dim][error_code]({match.tag})[/][/]" return result @@ -137,7 +137,7 @@ def format(self, match: "MatchError") -> str: filename = self._format_path(match.filename or "") position = match.position - rule_id = u"E{0}".format(match.rule.id) + rule_id = u"{0}".format(match.rule.id) severity = match.rule.severity message = self.escape(str(match.message)) diff --git a/test/TestUtils.py b/test/TestUtils.py index 667f7fa881..8e635229b1 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -263,7 +263,7 @@ def test_cli_auto_detect(capfd): assert "Discovering files to lint: git ls-files *.yaml *.yml" in err # An expected rule match from our examples assert "examples/playbooks/empty_playbook.yml:0: " \ - "E911 Empty playbook, nothing to do" in out + "911 Empty playbook, nothing to do" in out # assures that our .ansible-lint exclude was effective in excluding github files assert "Identified: .github/" not in out # assures that we can parse playbooks as playbooks