Skip to content

Commit

Permalink
Remove useless code
Browse files Browse the repository at this point in the history
Ref. #799
  • Loading branch information
treiher committed Oct 22, 2021
1 parent d9f45c8 commit 82ba91c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions rflx/specification/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ def check(spec_file: Path) -> RecordFluxError:
lines = specification.split("\n")

for i, l in enumerate(lines, start=1):
strings = [range(m.start(), m.end()) for m in re.finditer(r'"[^"]*"', l.split("--")[0])]

blank_lines = _check_blank_lines(error, l, i, spec_file, blank_lines, len(lines))
_check_characters(error, l, i, spec_file, strings)
_check_characters(error, l, i, spec_file)
_check_indentation(error, l, i, spec_file)
_check_line_length(error, l, i, spec_file)
_check_token_spacing(error, l, i, spec_file, strings)
_check_token_spacing(error, l, i, spec_file)
_check_trailing_spaces(error, l, i, spec_file)

return error
Expand Down Expand Up @@ -81,9 +79,7 @@ def _check_blank_lines(
return blank_lines


def _check_characters(
error: RecordFluxError, line: str, row: int, spec_file: Path, strings: list[range]
) -> None:
def _check_characters(error: RecordFluxError, line: str, row: int, spec_file: Path) -> None:
for j, c in enumerate(line, start=1):
if c == INCORRECT_LINE_TERMINATORS:
s = repr(c).replace("'", '"')
Expand All @@ -92,10 +88,6 @@ def _check_characters(
s = repr(c).replace("'", '"')
_append(error, f"illegal whitespace character {s}", row, j, spec_file)

for j, c in enumerate(line.split("--")[0], start=1):
if any(j in r for r in strings):
continue


def _check_indentation(error: RecordFluxError, line: str, row: int, spec_file: Path) -> None:
match = re.match(r" *", line)
Expand All @@ -118,9 +110,9 @@ def _check_indentation(error: RecordFluxError, line: str, row: int, spec_file: P
)


def _check_token_spacing(
error: RecordFluxError, line: str, row: int, spec_file: Path, strings: list[range]
) -> None:
def _check_token_spacing(error: RecordFluxError, line: str, row: int, spec_file: Path) -> None:
strings = [range(m.start(), m.end()) for m in re.finditer(r'"[^"]*"', line.split("--")[0])]

for match in re.finditer(
r"--+|/?=(?!>)|<=?|>=?|=>|:=|\+|[(]+\-\d+[)]+|\-|/|\*\*?|::?|'|;|,",
line,
Expand Down

0 comments on commit 82ba91c

Please sign in to comment.