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

Function _is_banner_run

scripts/code-verify.py:937–963  ·  view source on GitHub ↗

A run of consecutive `//` comment payloads is a banner when it follows the project's section-marker shapes: A) Decorators only — `//---`, `//===`, `//` (blank). Flagging these as multi-line narration is wrong; they're rules between sections. B) Sandwich — the run starts AN

(payloads: list[str])

Source from the content-addressed store, hash-verified

935
936
937def _is_banner_run(payloads: list[str]) -> bool:
938 """A run of consecutive `//` comment payloads is a banner when it follows
939 the project's section-marker shapes:
940
941 A) Decorators only — `//---`, `//===`, `//` (blank). Flagging these
942 as multi-line narration is wrong; they're rules between sections.
943 B) Sandwich — the run starts AND ends with a decorator and every
944 non-decorator line is adjacent to one. Catches both the C++ form
945 (`//---` / `// Section` / `//---`) and the QML form
946 (`//` / `// Section` / `//`)."""
947 if not payloads:
948 return False
949
950 if all(_is_banner_payload(p) for p in payloads):
951 return True
952
953 if not _is_banner_payload(payloads[0]) or not _is_banner_payload(payloads[-1]):
954 return False
955
956 for idx, p in enumerate(payloads):
957 if _is_banner_payload(p):
958 continue
959 prev_dec = idx > 0 and _is_banner_payload(payloads[idx - 1])
960 next_dec = idx + 1 < len(payloads) and _is_banner_payload(payloads[idx + 1])
961 if not (prev_dec or next_dec):
962 return False
963 return True
964
965
966def find_comment_style_violations(

Callers 1

Calls 1

_is_banner_payloadFunction · 0.85

Tested by

no test coverage detected