From c9f4d08cbd1ee88256f8bece7b045ef5e14ea84e Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 12:57:49 +0000 Subject: [PATCH 1/6] Wrapp transform with try --- Containerfile | 12 ++++++++++++ src/ansiblelint/transformer.py | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Containerfile diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000000..d867c71365 --- /dev/null +++ b/Containerfile @@ -0,0 +1,12 @@ +FROM registry.fedoraproject.org/fedora:latest + +WORKDIR /root +RUN < None: """Do Rule-Transforms handling any last-minute MatchError inspections.""" for match in sorted(matches): + match_id = f"{match.tag}/{match.match_type} {match.filename}:{match.lineno}" if not isinstance(match.rule, TransformMixin): + logging.debug("Rule specific fix not available for: %s", match_id) continue if self.write_set != {"all"}: rule = cast(AnsibleLintRule, match.rule) rule_definition = set(rule.tags) rule_definition.add(rule.id) if rule_definition.isdisjoint(self.write_set): - # rule transform not requested. Skip it. + logging.debug("Rule specific fix not enabled for: %s", match_id) continue if file_is_yaml and not match.yaml_path: data = cast(CommentedMap | CommentedSeq, data) @@ -148,4 +151,15 @@ def _do_transforms( "playbook", ): match.yaml_path = get_path_to_task(file, match.lineno, data) - match.rule.transform(match, file, data) + + logging.debug("Applying rule specific fix for: %s", match_id) + try: + match.rule.transform(match, file, data) + except Exception as exc: # pylint: disable=broad-except + _logger.error("Rule specific fix failed for: %s", match_id) + _logger.exception(exc) + msg = "Please file an issue for this with the task or playbook that caused the error." + _logger.error(msg) + continue + state = "was" if match.fixed else "was not" + _logger.debug("Rule specific fix %s applied for: %s", state, match_id) From 6d58d1981acfdf589cc2a5e7e62405ec84447bf1 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 10:42:32 -0700 Subject: [PATCH 2/6] Improve fix feedback, avoid traceback --- Containerfile | 12 -- src/ansiblelint/transformer.py | 33 ++-- test/test_transformer.py | 277 ++++++++++++++++++++++++++++++++- 3 files changed, 299 insertions(+), 23 deletions(-) delete mode 100644 Containerfile diff --git a/Containerfile b/Containerfile deleted file mode 100644 index d867c71365..0000000000 --- a/Containerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM registry.fedoraproject.org/fedora:latest - -WORKDIR /root -RUN < None: self._do_transforms(file, ruamel_data or data, file_is_yaml, matches) if file_is_yaml: - _logger.debug("Dumping %s using YAML (%s)", file, yaml.version) + _logger.debug("%s %s, version=%s", self.DUMP_MSG, file, yaml.version) # noinspection PyUnboundLocalVariable file.content = yaml.dumps(ruamel_data) @@ -132,14 +144,14 @@ def _do_transforms( for match in sorted(matches): match_id = f"{match.tag}/{match.match_type} {match.filename}:{match.lineno}" if not isinstance(match.rule, TransformMixin): - logging.debug("Rule specific fix not available for: %s", match_id) + logging.debug("%s %s", self.FIX_NA_MSG, match_id) continue if self.write_set != {"all"}: rule = cast(AnsibleLintRule, match.rule) rule_definition = set(rule.tags) rule_definition.add(rule.id) if rule_definition.isdisjoint(self.write_set): - logging.debug("Rule specific fix not enabled for: %s", match_id) + logging.debug("%s %s", self.FIX_NE_MSG, match_id) continue if file_is_yaml and not match.yaml_path: data = cast(CommentedMap | CommentedSeq, data) @@ -152,14 +164,15 @@ def _do_transforms( ): match.yaml_path = get_path_to_task(file, match.lineno, data) - logging.debug("Applying rule specific fix for: %s", match_id) + logging.debug("%s %s", self.FIX_APPLY_MSG, match_id) try: match.rule.transform(match, file, data) - except Exception as exc: # pylint: disable=broad-except - _logger.error("Rule specific fix failed for: %s", match_id) + except Exception as exc: # pylint: disable=broad-except + _logger.error("%s %s", self.FIX_FAILED_MSG, match_id) _logger.exception(exc) - msg = "Please file an issue for this with the task or playbook that caused the error." - _logger.error(msg) + _logger.error(self.FIX_ISSUE_MSG) continue - state = "was" if match.fixed else "was not" - _logger.debug("Rule specific fix %s applied for: %s", state, match_id) + if match.fixed: + _logger.debug("%s %s", self.FIX_APPLIED_MSG, match_id) + else: + _logger.error("%s %s", self.FIX_NOT_APPLIED_MSG, match_id) diff --git a/test/test_transformer.py b/test/test_transformer.py index 235f0b303c..e73dbf425b 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -1,11 +1,13 @@ +# cspell:ignore classinfo """Tests for Transformer.""" from __future__ import annotations +import builtins import os import shutil from pathlib import Path -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Any from unittest import mock import pytest @@ -13,6 +15,7 @@ import ansiblelint.__main__ as main from ansiblelint.app import App from ansiblelint.file_utils import Lintable +from ansiblelint.rules import TransformMixin # noinspection PyProtectedMember from ansiblelint.runner import LintResult, get_matches @@ -20,6 +23,7 @@ if TYPE_CHECKING: from ansiblelint.config import Options + from ansiblelint.errors import MatchError from ansiblelint.rules import RulesCollection @@ -354,3 +358,274 @@ def report_outcome( main.main() assert fix_called assert report_called + + +class TransformTests: + """A carrier for some common test constants.""" + + FILE_NAME = "examples/playbooks/transform-no-free-form.yml" + FILE_TYPE = "playbook" + LINENO = 5 + ID = "no-free-form" + MATCH_TYPE = "task" + VERSION_PART = "version=(1, 1)" + + @classmethod + def match_id(cls) -> str: + """Generate a match id. + + :returns: Match id string + """ + return f"{cls.ID}/{cls.MATCH_TYPE} {cls.FILE_NAME}:{cls.LINENO}" + + @classmethod + def rewrite_part(cls) -> str: + """Generate a rewrite part. + + :returns: Rewrite part string + """ + return f"{cls.FILE_NAME} ({cls.FILE_TYPE}), {cls.VERSION_PART}" + + +@pytest.fixture(name="test_result") +def fixture_test_result( + config_options: Options, + default_rules_collection: RulesCollection, +) -> tuple[LintResult, Options]: + """Fixture that runs the Runner to populate a LintResult for a given file. + + The results are confirmed and a limited to a single match. + + :param config_options: Configuration options + :param default_rules_collection: Default rules collection + :returns: Tuple of LintResult and Options + """ + config_options.write_list = [TransformTests.ID] + config_options.lintables = [TransformTests.FILE_NAME] + + result = get_matches(rules=default_rules_collection, options=config_options) + match = result.matches[0] + + def write(*_args: Any, **_kwargs: Any) -> None: + """Don't rewrite the test fixture. + + :param _args: Arguments + :param _kwargs: Keyword arguments + """ + + setattr(match.lintable, "write", write) # noqa: B010 + + assert match.rule.id == TransformTests.ID + assert match.filename == TransformTests.FILE_NAME + assert match.lineno == TransformTests.LINENO + assert match.match_type == TransformTests.MATCH_TYPE + result.matches = [match] + + return result, config_options + + +def test_transform_na( + caplog: pytest.LogCaptureFixture, + monkeypatch: pytest.MonkeyPatch, + test_result: tuple[LintResult, Options], +) -> None: + """Test the transformer is not available. + + :param caplog: Log capture fixture + :param monkeypatch: Monkeypatch + :param test_result: Test result fixture + """ + result = test_result[0] + options = test_result[1] + + _isinstance = builtins.isinstance + called = False + + def mp_isinstance(t_object: Any, classinfo: type) -> bool: + if classinfo is TransformMixin: + nonlocal called + called = True + return False + return _isinstance(t_object, classinfo) + + monkeypatch.setattr(builtins, "isinstance", mp_isinstance) + + transformer = Transformer(result=result, options=options) + with caplog.at_level(10): + transformer.run() + + assert called + assert len(caplog.records) == 2 + + log_0 = f"{transformer.FIX_NA_MSG} {TransformTests.match_id()}" + assert caplog.records[0].message == log_0 + assert caplog.records[0].levelname == "DEBUG" + + log_1 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" + assert caplog.records[1].message == log_1 + assert caplog.records[1].levelname == "DEBUG" + + +def test_transform_no_tb( + caplog: pytest.LogCaptureFixture, + test_result: tuple[LintResult, Options], +) -> None: + """Test the transformer does not traceback. + + :param caplog: Log capture fixture + :param test_result: Test result fixture + :raises RuntimeError: If the rule is not a TransformMixin + """ + result = test_result[0] + options = test_result[1] + exception_msg = "FixFailure" + + def transform(*_args: Any, **_kwargs: Any) -> None: + """Raise an exception for the transform call. + + :raises RuntimeError: Always + """ + raise RuntimeError(exception_msg) + + if isinstance(result.matches[0].rule, TransformMixin): + setattr(result.matches[0].rule, "transform", transform) # noqa: B010 + else: + err = "Rule is not a TransformMixin" + raise RuntimeError(err) + + transformer = Transformer(result=result, options=options) + with caplog.at_level(10): + transformer.run() + + assert len(caplog.records) == 5 + + log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" + assert caplog.records[0].message == log_0 + assert caplog.records[0].levelname == "DEBUG" + + log_1 = f"{transformer.FIX_FAILED_MSG} {TransformTests.match_id()}" + assert caplog.records[1].message == log_1 + assert caplog.records[1].levelname == "ERROR" + + log_2 = exception_msg + assert caplog.records[2].message == log_2 + assert caplog.records[2].levelname == "ERROR" + + log_3 = f"{transformer.FIX_ISSUE_MSG}" + assert caplog.records[3].message == log_3 + assert caplog.records[3].levelname == "ERROR" + + log_4 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" + assert caplog.records[4].message == log_4 + assert caplog.records[4].levelname == "DEBUG" + + +def test_transform_applied( + caplog: pytest.LogCaptureFixture, + test_result: tuple[LintResult, Options], +) -> None: + """Test the transformer is applied. + + :param caplog: Log capture fixture + :param test_result: Test result fixture + """ + result = test_result[0] + options = test_result[1] + + transformer = Transformer(result=result, options=options) + with caplog.at_level(10): + transformer.run() + + assert len(caplog.records) == 3 + + log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" + assert caplog.records[0].message == log_0 + assert caplog.records[0].levelname == "DEBUG" + + log_1 = f"{transformer.FIX_APPLIED_MSG} {TransformTests.match_id()}" + assert caplog.records[1].message == log_1 + assert caplog.records[1].levelname == "DEBUG" + + log_2 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" + assert caplog.records[2].message == log_2 + assert caplog.records[2].levelname == "DEBUG" + + +def test_transform_not_enabled( + caplog: pytest.LogCaptureFixture, + test_result: tuple[LintResult, Options], +) -> None: + """Test the transformer is not enabled. + + :param caplog: Log capture fixture + :param test_result: Test result fixture + """ + result = test_result[0] + options = test_result[1] + options.write_list = [] + + transformer = Transformer(result=result, options=options) + with caplog.at_level(10): + transformer.run() + + assert len(caplog.records) == 2 + + log_0 = f"{transformer.FIX_NE_MSG} {TransformTests.match_id()}" + assert caplog.records[0].message == log_0 + assert caplog.records[0].levelname == "DEBUG" + + log_1 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" + assert caplog.records[1].message == log_1 + assert caplog.records[1].levelname == "DEBUG" + + +def test_transform_not_applied( + caplog: pytest.LogCaptureFixture, + test_result: tuple[LintResult, Options], +) -> None: + """Test the transformer is not applied. + + :param caplog: Log capture fixture + :param test_result: Test result fixture + :raises RuntimeError: If the rule is not a TransformMixin + """ + result = test_result[0] + options = test_result[1] + + called = False + + def transform(match: MatchError, *_args: Any, **_kwargs: Any) -> None: + """Do not apply the transform. + + :param match: Match object + :param _args: Arguments + :param _kwargs: Keyword arguments + """ + nonlocal called + called = True + match.fixed = False + + if isinstance(result.matches[0].rule, TransformMixin): + setattr(result.matches[0].rule, "transform", transform) # noqa: B010 + else: + err = "Rule is not a TransformMixin" + raise RuntimeError(err) + + transformer = Transformer(result=result, options=options) + with caplog.at_level(10): + transformer.run() + + assert called + assert len(caplog.records) == 3 + + log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" + assert caplog.records[0].message == log_0 + assert caplog.records[0].levelname == "DEBUG" + + log_1 = f"{transformer.FIX_NOT_APPLIED_MSG} {TransformTests.match_id()}" + assert caplog.records[1].message == log_1 + assert caplog.records[1].levelname == "ERROR" + + log_2 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" + assert caplog.records[2].message == log_2 + assert caplog.records[2].levelname == "DEBUG" From b33c81a8bb50f1e3dea011047553e74bcc4147da Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 10:49:19 -0700 Subject: [PATCH 3/6] rm uneeded self --- src/ansiblelint/transformer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ansiblelint/transformer.py b/src/ansiblelint/transformer.py index 9f41bb86c0..24308ff64c 100644 --- a/src/ansiblelint/transformer.py +++ b/src/ansiblelint/transformer.py @@ -47,7 +47,6 @@ class Transformer: def __init__(self, result: LintResult, options: Options): """Initialize a Transformer instance.""" - self._options = options self.write_set = self.effective_write_set(options.write_list) self.matches: list[MatchError] = result.matches From 7fc9e13d5f608d70df4df2893cb9a8250dc74c25 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 11:05:56 -0700 Subject: [PATCH 4/6] Update tests based on previously merged PRs --- .pre-commit-config.yaml | 2 +- src/ansiblelint/transformer.py | 6 +-- test/test_transformer.py | 79 ++++++++++++++++++---------------- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43a827febf..2bbed8a5fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -137,7 +137,7 @@ repos: types: [file, yaml] entry: yamllint --strict - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.3" + rev: "v0.4.4" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/src/ansiblelint/transformer.py b/src/ansiblelint/transformer.py index 24308ff64c..c610704651 100644 --- a/src/ansiblelint/transformer.py +++ b/src/ansiblelint/transformer.py @@ -167,9 +167,9 @@ def _do_transforms( try: match.rule.transform(match, file, data) except Exception as exc: # pylint: disable=broad-except - _logger.error("%s %s", self.FIX_FAILED_MSG, match_id) - _logger.exception(exc) - _logger.error(self.FIX_ISSUE_MSG) + _logger.error("%s %s", self.FIX_FAILED_MSG, match_id) # noqa: TRY400 + _logger.exception(exc) # noqa: TRY401 + _logger.error(self.FIX_ISSUE_MSG) # noqa: TRY400 continue if match.fixed: _logger.debug("%s %s", self.FIX_APPLIED_MSG, match_id) diff --git a/test/test_transformer.py b/test/test_transformer.py index e73dbf425b..fa9530e317 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -455,15 +455,16 @@ def mp_isinstance(t_object: Any, classinfo: type) -> bool: transformer.run() assert called - assert len(caplog.records) == 2 + logs = [record for record in caplog.records if record.module == "transformer"] + assert len(logs) == 2 log_0 = f"{transformer.FIX_NA_MSG} {TransformTests.match_id()}" - assert caplog.records[0].message == log_0 - assert caplog.records[0].levelname == "DEBUG" + assert logs[0].message == log_0 + assert logs[0].levelname == "DEBUG" log_1 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" - assert caplog.records[1].message == log_1 - assert caplog.records[1].levelname == "DEBUG" + assert logs[1].message == log_1 + assert logs[1].levelname == "DEBUG" def test_transform_no_tb( @@ -491,33 +492,34 @@ def transform(*_args: Any, **_kwargs: Any) -> None: setattr(result.matches[0].rule, "transform", transform) # noqa: B010 else: err = "Rule is not a TransformMixin" - raise RuntimeError(err) + raise TypeError(err) transformer = Transformer(result=result, options=options) with caplog.at_level(10): transformer.run() - assert len(caplog.records) == 5 + logs = [record for record in caplog.records if record.module == "transformer"] + assert len(logs) == 5 log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" - assert caplog.records[0].message == log_0 - assert caplog.records[0].levelname == "DEBUG" + assert logs[0].message == log_0 + assert logs[0].levelname == "DEBUG" log_1 = f"{transformer.FIX_FAILED_MSG} {TransformTests.match_id()}" - assert caplog.records[1].message == log_1 - assert caplog.records[1].levelname == "ERROR" + assert logs[1].message == log_1 + assert logs[1].levelname == "ERROR" log_2 = exception_msg - assert caplog.records[2].message == log_2 - assert caplog.records[2].levelname == "ERROR" + assert logs[2].message == log_2 + assert logs[2].levelname == "ERROR" log_3 = f"{transformer.FIX_ISSUE_MSG}" - assert caplog.records[3].message == log_3 - assert caplog.records[3].levelname == "ERROR" + assert logs[3].message == log_3 + assert logs[3].levelname == "ERROR" log_4 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" - assert caplog.records[4].message == log_4 - assert caplog.records[4].levelname == "DEBUG" + assert logs[4].message == log_4 + assert logs[4].levelname == "DEBUG" def test_transform_applied( @@ -536,19 +538,20 @@ def test_transform_applied( with caplog.at_level(10): transformer.run() - assert len(caplog.records) == 3 + logs = [record for record in caplog.records if record.module == "transformer"] + assert len(logs) == 3 log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" - assert caplog.records[0].message == log_0 - assert caplog.records[0].levelname == "DEBUG" + assert logs[0].message == log_0 + assert logs[0].levelname == "DEBUG" log_1 = f"{transformer.FIX_APPLIED_MSG} {TransformTests.match_id()}" - assert caplog.records[1].message == log_1 - assert caplog.records[1].levelname == "DEBUG" + assert logs[1].message == log_1 + assert logs[1].levelname == "DEBUG" log_2 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" - assert caplog.records[2].message == log_2 - assert caplog.records[2].levelname == "DEBUG" + assert logs[2].message == log_2 + assert logs[2].levelname == "DEBUG" def test_transform_not_enabled( @@ -568,15 +571,16 @@ def test_transform_not_enabled( with caplog.at_level(10): transformer.run() - assert len(caplog.records) == 2 + logs = [record for record in caplog.records if record.module == "transformer"] + assert len(logs) == 2 log_0 = f"{transformer.FIX_NE_MSG} {TransformTests.match_id()}" - assert caplog.records[0].message == log_0 - assert caplog.records[0].levelname == "DEBUG" + assert logs[0].message == log_0 + assert logs[0].levelname == "DEBUG" log_1 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" - assert caplog.records[1].message == log_1 - assert caplog.records[1].levelname == "DEBUG" + assert logs[1].message == log_1 + assert logs[1].levelname == "DEBUG" def test_transform_not_applied( @@ -609,23 +613,24 @@ def transform(match: MatchError, *_args: Any, **_kwargs: Any) -> None: setattr(result.matches[0].rule, "transform", transform) # noqa: B010 else: err = "Rule is not a TransformMixin" - raise RuntimeError(err) + raise TypeError(err) transformer = Transformer(result=result, options=options) with caplog.at_level(10): transformer.run() assert called - assert len(caplog.records) == 3 + logs = [record for record in caplog.records if record.module == "transformer"] + assert len(logs) == 3 log_0 = f"{transformer.FIX_APPLY_MSG} {TransformTests.match_id()}" - assert caplog.records[0].message == log_0 - assert caplog.records[0].levelname == "DEBUG" + assert logs[0].message == log_0 + assert logs[0].levelname == "DEBUG" log_1 = f"{transformer.FIX_NOT_APPLIED_MSG} {TransformTests.match_id()}" - assert caplog.records[1].message == log_1 - assert caplog.records[1].levelname == "ERROR" + assert logs[1].message == log_1 + assert logs[1].levelname == "ERROR" log_2 = f"{transformer.DUMP_MSG} {TransformTests.rewrite_part()}" - assert caplog.records[2].message == log_2 - assert caplog.records[2].levelname == "DEBUG" + assert logs[2].message == log_2 + assert logs[2].levelname == "DEBUG" From 9d3b32de6ea67dc4dac259e6174aa506b434dc65 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 11:10:55 -0700 Subject: [PATCH 5/6] Switch to logging exception, it's a 40 --- src/ansiblelint/transformer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansiblelint/transformer.py b/src/ansiblelint/transformer.py index c610704651..675b033429 100644 --- a/src/ansiblelint/transformer.py +++ b/src/ansiblelint/transformer.py @@ -167,9 +167,9 @@ def _do_transforms( try: match.rule.transform(match, file, data) except Exception as exc: # pylint: disable=broad-except - _logger.error("%s %s", self.FIX_FAILED_MSG, match_id) # noqa: TRY400 + _logger.exception("%s %s", self.FIX_FAILED_MSG, match_id) _logger.exception(exc) # noqa: TRY401 - _logger.error(self.FIX_ISSUE_MSG) # noqa: TRY400 + _logger.exception(self.FIX_ISSUE_MSG) continue if match.fixed: _logger.debug("%s %s", self.FIX_APPLIED_MSG, match_id) From fd303295f640277a4af88c9c1299c5ca2499d0f7 Mon Sep 17 00:00:00 2001 From: "Bradley A. Thornton" Date: Fri, 10 May 2024 11:31:28 -0700 Subject: [PATCH 6/6] Back to error --- .github/workflows/tox.yml | 2 +- src/ansiblelint/transformer.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 00d6b0e95f..aed46a9e29 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -73,7 +73,7 @@ jobs: env: # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 860 + PYTEST_REQPASS: 865 steps: - uses: actions/checkout@v4 with: diff --git a/src/ansiblelint/transformer.py b/src/ansiblelint/transformer.py index 675b033429..c610704651 100644 --- a/src/ansiblelint/transformer.py +++ b/src/ansiblelint/transformer.py @@ -167,9 +167,9 @@ def _do_transforms( try: match.rule.transform(match, file, data) except Exception as exc: # pylint: disable=broad-except - _logger.exception("%s %s", self.FIX_FAILED_MSG, match_id) + _logger.error("%s %s", self.FIX_FAILED_MSG, match_id) # noqa: TRY400 _logger.exception(exc) # noqa: TRY401 - _logger.exception(self.FIX_ISSUE_MSG) + _logger.error(self.FIX_ISSUE_MSG) # noqa: TRY400 continue if match.fixed: _logger.debug("%s %s", self.FIX_APPLIED_MSG, match_id)