Skip to content

Commit

Permalink
Allow arbitrary whitespaces in style pragma
Browse files Browse the repository at this point in the history
Ref. #1079, #1083
  • Loading branch information
treiher committed Jun 23, 2022
1 parent 7669e7f commit beeeb10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 7 additions & 8 deletions rflx/specification/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ def _determine_enabled_checks(error: RecordFluxError, line: str, spec_file: Path
checks = {c.value for c in Check.__members__.values()}
disabled_checks = set()

if "-- style:" in line:
m = re.match(r"^-- style: disable = ([^.]*)$", line)
if m:
disabled_checks = {c.strip() for c in m.group(1).split(",")}
for c in disabled_checks - checks:
_append(error, f'invalid check "{c}"', 1, 1, spec_file)
else:
_append(error, "invalid format of style pragma", 1, 1, spec_file)
m = re.match(r"^\s*--\s*style\s*:\s*disable\s*=\s*([^.]*)$", line)
if m:
disabled_checks = {c.strip() for c in m.group(1).split(",")}
for c in disabled_checks - checks:
_append(error, f'invalid check "{c}"', 1, 1, spec_file)
else:
return set(Check.__members__.values())

if Check.ALL.value in disabled_checks:
return set()
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/specification/style_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ def test_no_error(spec: str, tmp_path: Path) -> None:
"end Test;",
r'3:33: style: error: space after "::" \[token-spacing\]',
),
(
"-- style: disable",
r"1:1: style: error: invalid format of style pragma",
),
(
"-- style: disable = foo",
r'1:1: style: error: invalid check "foo"',
Expand Down

0 comments on commit beeeb10

Please sign in to comment.