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

Function check_id_placement

scripts/code-verify.py:779–801  ·  view source on GitHub ↗

Inside each object body, `id:` must be the first non-comment/blank content line and must be followed by one blank line. Returns (violations, raw_line_indices) — the second list contains indices in physical-line space after which a blank line needs inserting to satisfy the id-blank-li

(
    lines: list[LogicalLine], path: Path
)

Source from the content-addressed store, hash-verified

777
778
779def check_id_placement(
780 lines: list[LogicalLine], path: Path
781) -> tuple[list[Violation], list[int]]:
782 """Inside each object body, `id:` must be the first non-comment/blank
783 content line and must be followed by one blank line. Returns
784 (violations, raw_line_indices) — the second list contains indices in
785 physical-line space after which a blank line needs inserting to satisfy
786 the id-blank-line rule."""
787 violations: list[Violation] = []
788 blanks_after: list[int] = []
789 body_stack: list[int] = []
790
791 for i, line in enumerate(lines):
792 if line.kind == "open":
793 body_stack.append(i + 1)
794 continue
795
796 delta = _brace_delta(line)
797 if delta < 0 and body_stack:
798 start = body_stack.pop()
799 _check_shallow_id(lines, start, i, path, violations, blanks_after)
800
801 return violations, blanks_after
802
803
804def _check_shallow_id(

Callers 1

process_fileFunction · 0.85

Calls 3

_brace_deltaFunction · 0.85
_check_shallow_idFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected