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

Function _stdio_findings

scripts/code_verify_rules.py:2980–2997  ·  view source on GitHub ↗

Flag raw-stdio output (`std::cout`, ` `, `printf`, `std::endl`) in Qt source code. Strings and `//` line comments are masked first so `// printf("...")` in prose doesn't fire.

(src_text: str, path: Path, fence_mask: list[bool])

Source from the content-addressed store, hash-verified

2978
2979
2980def _stdio_findings(src_text: str, path: Path, fence_mask: list[bool]) -> list[Finding]:
2981 """Flag raw-stdio output (`std::cout`, `<iostream>`, `printf`, `std::endl`)
2982 in Qt source code. Strings and `//` line comments are masked first so
2983 `// printf("...")` in prose doesn&#x27;t fire."""
2984 if path.suffix not in (".cpp", ".cc", ".cxx", ".mm", ".h", ".hpp", ".hxx"):
2985 return []
2986 if _is_vendored_path(path):
2987 return []
2988 out: list[Finding] = []
2989 for i, raw in enumerate(src_text.split("\n"), start=1):
2990 if i - 1 < len(fence_mask) and fence_mask[i - 1]:
2991 continue
2992 scrubbed = _strip_strings_and_line_comments(raw)
2993 for pat, kind, msg in _STDIO_PATTERNS:
2994 if pat.search(scrubbed):
2995 out.append(Finding(i, kind, msg))
2996 break
2997 return out
2998
2999
3000_TRAILING_DOXY_RE = re.compile(r"/\*\*<")

Callers 1

analyzeFunction · 0.85

Calls 5

_is_vendored_pathFunction · 0.85
FindingClass · 0.70
searchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected