Checker that flags raw 'noexcept' keyword — use FL_NOEXCEPT instead.
| 38 | |
| 39 | |
| 40 | class RawNoexceptChecker(FileContentChecker): |
| 41 | """Checker that flags raw 'noexcept' keyword — use FL_NOEXCEPT instead.""" |
| 42 | |
| 43 | def __init__(self) -> None: |
| 44 | self.violations: dict[str, list[tuple[int, str]]] = {} |
| 45 | |
| 46 | def should_process_file(self, file_path: str) -> bool: |
| 47 | normalized = file_path.replace("\\", "/") |
| 48 | |
| 49 | # Only C++ source files inside src/ |
| 50 | # Accept both absolute paths (/path/to/project/src/...) and |
| 51 | # relative test paths (src/fl/...) |
| 52 | if "/src/" not in normalized and not normalized.startswith("src/"): |
| 53 | return False |
| 54 | if not normalized.endswith((".h", ".hpp", ".cpp", ".cpp.hpp")): |
| 55 | return False |
| 56 | |
| 57 | # Skip the definition file itself |
| 58 | if normalized.endswith("fl/stl/noexcept.h"): |
| 59 | return False |
| 60 | |
| 61 | # Skip third-party code — not under our control |
| 62 | if "/third_party/" in normalized: |
| 63 | return False |
| 64 | |
| 65 | return True |
| 66 | |
| 67 | def check_file_content(self, file_content: FileContent) -> list[str]: |
| 68 | """Check file content for raw noexcept keyword usage.""" |
| 69 | # Fast file-level skip when noexcept is completely absent |
| 70 | if "noexcept" not in file_content.content: |
| 71 | return [] |
| 72 | |
| 73 | violations: list[tuple[int, str]] = [] |
| 74 | in_multiline_comment = False |
| 75 | |
| 76 | for line_number, line in enumerate(file_content.lines, 1): |
| 77 | stripped = line.strip() |
| 78 | |
| 79 | # Track multi-line comment state |
| 80 | if "/*" in line: |
| 81 | in_multiline_comment = True |
| 82 | if "*/" in line: |
| 83 | in_multiline_comment = False |
| 84 | continue # skip the closing */ line |
| 85 | |
| 86 | if in_multiline_comment: |
| 87 | continue |
| 88 | |
| 89 | # Skip pure single-line comments |
| 90 | if stripped.startswith("//"): |
| 91 | continue |
| 92 | |
| 93 | # Strip inline comment portion |
| 94 | code = stripped.split("//")[0].strip() |
| 95 | if not code: |
| 96 | continue |
| 97 |
no outgoing calls