diff --git a/src/ansiblelint/errors.py b/src/ansiblelint/errors.py index e57c0dc0a93..1b78605c50d 100644 --- a/src/ansiblelint/errors.py +++ b/src/ansiblelint/errors.py @@ -110,8 +110,8 @@ def __post_init__(self) -> None: msg = "MatchError called incorrectly as column numbers start with 1" raise RuntimeError(msg) - offset = getattr(self.lintable, "_line_offset", 1) - self.lineno += offset - 1 + offset = getattr(self.lintable, "_line_offset", 0) + self.lineno += offset @functools.cached_property def level(self) -> str: diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index e593fc6724d..a39a7de8057 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -403,7 +403,7 @@ def parse_examples_from_plugin(self) -> str: if isinstance(child, ast.Assign): label = child.targets[0] if isinstance(label, ast.Name) and label.id == "EXAMPLES": - self._line_offset = child.lineno + self._line_offset = child.lineno - 1 break docs = read_docstring(str(self.path))