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])
| 2978 | |
| 2979 | |
| 2980 | def _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'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"/\*\*<") |
no test coverage detected