Skip to content

Commit

Permalink
Make fix more resilient to syntax-check errors
Browse files Browse the repository at this point in the history
Fixes: #4114
  • Loading branch information
ssbarnea committed Apr 29, 2024
1 parent 9a8db9f commit d05a1a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ansiblelint/rules/fqcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import sys
from typing import TYPE_CHECKING, Any

from ruamel.yaml.comments import CommentedSeq

from ansiblelint.constants import LINE_NUMBER_KEY
from ansiblelint.rules import AnsibleLintRule, TransformMixin
from ansiblelint.utils import load_plugin

if TYPE_CHECKING:
from ruamel.yaml.comments import CommentedMap, CommentedSeq
from ruamel.yaml.comments import CommentedMap

from ansiblelint.errors import MatchError
from ansiblelint.file_utils import Lintable
Expand Down Expand Up @@ -242,6 +244,8 @@ def transform(
current_action = match.message.split("`")[3]
new_action = match.message.split("`")[1]
for _ in range(len(target_task)):
if isinstance(target_task, CommentedSeq):
continue

Check warning on line 248 in src/ansiblelint/rules/fqcn.py

View check run for this annotation

Codecov / codecov/patch

src/ansiblelint/rules/fqcn.py#L248

Added line #L248 was not covered by tests
k, v = target_task.popitem(False)
target_task[new_action if k == current_action else k] = v
match.fixed = True
Expand Down
5 changes: 4 additions & 1 deletion src/ansiblelint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ def _get_ansible_syntax_check_matches(
filename = lintable
column = int(groups.get("column", 1))

if pattern.tag == "unknown-module" and app.options.nodeps:
if (
pattern.tag in ("unknown-module", "specific")
and app.options.nodeps
):
ignore_rc = True
else:
results.append(
Expand Down

0 comments on commit d05a1a8

Please sign in to comment.