MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / _is_brace_free_control

Function _is_brace_free_control

scripts/code-verify.py:601–614  ·  view source on GitHub ↗

True when `line` opens a control statement whose body must be on the next physical line (i.e. it does not end with `{` and is not a one-liner with a `;` body).

(line: str)

Source from the content-addressed store, hash-verified

599
600
601def _is_brace_free_control(line: str) -> bool:
602 """True when `line` opens a control statement whose body must be on the
603 next physical line (i.e. it does not end with `{` and is not a one-liner
604 with a `;` body)."""
605 sanitized = _strip_eol_comment(line)
606 if not sanitized:
607 return False
608 if sanitized.endswith("{") or sanitized.endswith(";"):
609 return False
610 if not _BRACE_FREE_CONTROL_RE.match(sanitized):
611 return False
612 # Reject pathological matches where the regex's greedy `.*` swallowed
613 # an unbalanced paren run (e.g. `if (cond` continued on next line).
614 return sanitized.count("(") == sanitized.count(")")
615
616
617def _line_indent(line: str) -> int:

Callers 1

Calls 2

_strip_eol_commentFunction · 0.85
countMethod · 0.45

Tested by

no test coverage detected