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

Function is_run_safe

scripts/code-verify.py:469–483  ·  view source on GitHub ↗

Sorting is only safe when every logical line is a single physical 'prop' line with no inline braces or brackets. The tokenizer already absorbs multi-line props into one LogicalLine; any line with more than one physical source line is therefore a multi-line value and skipped.

(run: list[LogicalLine])

Source from the content-addressed store, hash-verified

467
468
469def is_run_safe(run: list[LogicalLine]) -> bool:
470 """Sorting is only safe when every logical line is a single physical
471 'prop' line with no inline braces or brackets. The tokenizer already
472 absorbs multi-line props into one LogicalLine; any line with more than
473 one physical source line is therefore a multi-line value and skipped."""
474 for line in run:
475 if line.kind != "prop":
476 return False
477 if len(line.raws) != 1:
478 return False
479 sanitized = _strip_strings_and_comments(line.raws[0])
480 # Reject inline nested blocks or collection literals on the value.
481 if any(ch in sanitized for ch in "{}[]"):
482 return False
483 return True
484
485
486# ---------------------------------------------------------------------------

Callers 1

process_fileFunction · 0.85

Calls 1

Tested by

no test coverage detected