| 185 | return True |
| 186 | |
| 187 | def check_file_content(self, file_content: FileContent) -> list[str]: |
| 188 | violations: list[tuple[int, str]] = [] |
| 189 | in_block_comment = False |
| 190 | |
| 191 | for line_number, line in enumerate(file_content.lines, 1): |
| 192 | stripped = line.strip() |
| 193 | |
| 194 | # Track /* ... */ blocks. Single-line `/* ... */` is handled |
| 195 | # by the trailing-comment strip below. |
| 196 | if in_block_comment: |
| 197 | if "*/" in line: |
| 198 | in_block_comment = False |
| 199 | continue |
| 200 | if "/*" in line and "*/" not in line: |
| 201 | in_block_comment = True |
| 202 | continue |
| 203 | |
| 204 | if stripped.startswith("//"): |
| 205 | continue |
| 206 | if _SUPPRESS in line: |
| 207 | continue |
| 208 | |
| 209 | # Strip trailing // comment so the regex doesn't match inside it. |
| 210 | code = line.split("//")[0] |
| 211 | if _BANNED_PATTERN.search(code): |
| 212 | violations.append((line_number, line.rstrip())) |
| 213 | |
| 214 | if violations: |
| 215 | self.violations[file_content.path] = violations |
| 216 | |
| 217 | return [] |
| 218 | |
| 219 | |
| 220 | def main() -> None: |