Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bin/compile_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import compile # noqa: E402 (bin/compile.py; import after sys.path setup)

NAME_RE = re.compile(r"'([a-z0-9_]+)'\s+as\s+name", re.IGNORECASE)
CATEGORIES_RE = re.compile(
r"array\[(.*?)\]\s+as\s+categories", re.IGNORECASE | re.DOTALL
)
CATEGORIES_RE = re.compile(r"array\[([^\]]*)\]\s+as\s+categories", re.IGNORECASE)

VALID_CATEGORIES = {"SECURITY", "PERFORMANCE"}


def extract_name(stem: str, query: str) -> str:
Expand All @@ -56,6 +56,9 @@ def extract_categories(stem: str, query: str) -> List[str]:
]
if not categories:
raise SystemExit(f"lint {stem!r}: empty categories array")
invalid = [c for c in categories if c not in VALID_CATEGORIES]
if invalid:
raise SystemExit(f"lint {stem!r}: invalid categories {invalid}")
return categories


Expand Down
Loading