Skip to content

Commit

Permalink
Prevent duplicate warnings about deprecated tags (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Aug 13, 2022
1 parent 84b2407 commit 8c530d6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/ansiblelint/skip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import logging
from functools import lru_cache
from itertools import product
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Sequence
from typing import TYPE_CHECKING, Any, Dict, Generator, List, Optional, Sequence, Set

# Module 'ruamel.yaml' does not explicitly export attribute 'YAML'; implicit reexport disabled
from ruamel.yaml import YAML
Expand All @@ -35,7 +35,7 @@
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject

_logger = logging.getLogger(__name__)

_found_deprecated_tags: Set[str] = set()

# playbook: Sequence currently expects only instances of one of the two
# classes below but we should consider avoiding this chimera.
Expand All @@ -46,15 +46,18 @@
def get_rule_skips_from_line(line: str) -> List[str]:
"""Return list of rule ids skipped via comment on the line of yaml."""
_before_noqa, _noqa_marker, noqa_text = line.partition("# noqa")

result = []
for v in noqa_text.lstrip(" :").split():
if v in RENAMED_TAGS:
tag = RENAMED_TAGS[v]
_logger.warning(
"Replaced outdated tag '%s' with '%s', replace it to avoid future regressions.",
v,
tag,
)
if v not in _found_deprecated_tags:
_logger.warning(
"Replaced outdated tag '%s' with '%s', replace it to avoid future regressions",
v,
tag,
)
_found_deprecated_tags.add(v)
v = tag
result.append(v)
return result
Expand Down

0 comments on commit 8c530d6

Please sign in to comment.