Skip to content

Commit

Permalink
fix: support '*' for select (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Aug 25, 2023
1 parent 6ae4344 commit 2108bc7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/repo_review/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ def is_allowed(select: Set[str], ignore: Set[str], name: str) -> bool:
number is in the ignore list. If the select list is not empty, only runs the
check if the name or name without the number is in the select list.
:param select: A set of names or prefixes to include.
:param select: A set of names or prefixes to include. "*" selects all checks.
:param ignore: A set of names or prefixes to exclude.
:param name: The check to test.
:return: True if this check is allowed, False otherwise.
"""
if select and name not in select and name.rstrip("0123456789") not in select:
if (
select
and name not in select
and name.rstrip("0123456789") not in select
and "*" not in select
):
return False
if name in ignore or name.rstrip("0123456789") in ignore:
return False
Expand Down
11 changes: 11 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ def test_select_filter_exact(monkeypatch: pytest.MonkeyPatch) -> None:
assert len(results) == 1


def test_select_filter_all(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
repo_review.processor,
"collect_checks",
lambda _: {"D100": D100(), "D200": D200(), "C100": C100(fail=True)},
)
_, results = repo_review.processor.process(Path(), select={"*"})

assert len(results) == 3


def test_string_result(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
repo_review.processor,
Expand Down

0 comments on commit 2108bc7

Please sign in to comment.