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

Function _header_contract_names

scripts/code_verify_rules.py:2385–2410  ·  view source on GitHub ↗

Override/virtual/final method names relevant to `path`: always the ones declared in the file itself -- this catches classes defined inline in a `.cpp` (e.g. the NativeTemplate implementations, whose `id()`/`name()` overrides live in the `.cpp`, not a header) -- unioned, for a `.cpp`, wit

(path, src_text: str, is_header: bool)

Source from the content-addressed store, hash-verified

2383
2384
2385def _header_contract_names(path, src_text: str, is_header: bool) -> set:
2386 """Override/virtual/final method names relevant to `path`: always the ones
2387 declared in the file itself -- this catches classes defined inline in a
2388 `.cpp` (e.g. the NativeTemplate implementations, whose `id()`/`name()`
2389 overrides live in the `.cpp`, not a header) -- unioned, for a `.cpp`, with
2390 those in the paired `.h`/`.hpp`/`.hxx`. A trivial body on one of these is
2391 an interface contract, not dead code."""
2392 names = _contract_names_from_text(src_text)
2393 if is_header:
2394 return names
2395 for suffix in (".h", ".hpp", ".hxx"):
2396 cand = path.with_suffix(suffix)
2397 if not cand.exists():
2398 continue
2399 key = str(cand)
2400 cached = _header_contract_cache.get(key)
2401 if cached is None:
2402 try:
2403 text = cand.read_text(encoding="utf-8", errors="replace")
2404 except OSError:
2405 text = ""
2406 cached = _contract_names_from_text(text)
2407 _header_contract_cache[key] = cached
2408 names = names | cached
2409 break
2410 return names
2411
2412
2413def _is_constant_return_expr(node, src: bytes) -> bool:

Callers 1

_cpp_rulesFunction · 0.85

Calls 3

existsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected