Skip to content

Commit 2108bc7

Browse files
authored
fix: support '*' for select (#138)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 6ae4344 commit 2108bc7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/repo_review/checks.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,18 @@ def is_allowed(select: Set[str], ignore: Set[str], name: str) -> bool:
7676
number is in the ignore list. If the select list is not empty, only runs the
7777
check if the name or name without the number is in the select list.
7878
79-
:param select: A set of names or prefixes to include.
79+
:param select: A set of names or prefixes to include. "*" selects all checks.
8080
:param ignore: A set of names or prefixes to exclude.
8181
:param name: The check to test.
8282
8383
:return: True if this check is allowed, False otherwise.
8484
"""
85-
if select and name not in select and name.rstrip("0123456789") not in select:
85+
if (
86+
select
87+
and name not in select
88+
and name.rstrip("0123456789") not in select
89+
and "*" not in select
90+
):
8691
return False
8792
if name in ignore or name.rstrip("0123456789") in ignore:
8893
return False

tests/test_checks.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ def test_select_filter_exact(monkeypatch: pytest.MonkeyPatch) -> None:
138138
assert len(results) == 1
139139

140140

141+
def test_select_filter_all(monkeypatch: pytest.MonkeyPatch) -> None:
142+
monkeypatch.setattr(
143+
repo_review.processor,
144+
"collect_checks",
145+
lambda _: {"D100": D100(), "D200": D200(), "C100": C100(fail=True)},
146+
)
147+
_, results = repo_review.processor.process(Path(), select={"*"})
148+
149+
assert len(results) == 3
150+
151+
141152
def test_string_result(monkeypatch: pytest.MonkeyPatch) -> None:
142153
monkeypatch.setattr(
143154
repo_review.processor,

0 commit comments

Comments
 (0)