Skip to content

Commit

Permalink
Fix exclude_paths regression
Browse files Browse the repository at this point in the history
Fixes: #1311
  • Loading branch information
ssbarnea committed Feb 7, 2021
1 parent bc8988e commit 2d73dfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ansiblelint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def worker(lintable: Lintable) -> List[MatchError]:
# update list of checked files
self.checked_files.update([str(x.path) for x in self.lintables])

# remove any matches made inside excluded files
matches = list(
filter(lambda match: not self.is_excluded(match.filename), matches)
)

return sorted(set(matches))

def _emit_matches(self, files: List[Lintable]) -> Generator[MatchError, None, None]:
Expand Down
12 changes: 12 additions & 0 deletions test/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ def test_runner(default_rules_collection, playbook, exclude, length) -> None:
assert len(matches) == length


def test_runner_exclude_paths(default_rules_collection) -> None:
"""Test that exclude paths do work."""
runner = Runner(
'examples/playbooks/example.yml',
rules=default_rules_collection,
exclude_paths=['examples/'],
)

matches = runner.run()
assert len(matches) == 0


@pytest.mark.parametrize(
('formatter_cls'),
(
Expand Down

0 comments on commit 2d73dfd

Please sign in to comment.