Checker for ensuring only platform trampolines are used (not deep platform headers).
| 48 | |
| 49 | |
| 50 | class PlatformTrampolineChecker(FileContentChecker): |
| 51 | """Checker for ensuring only platform trampolines are used (not deep platform headers).""" |
| 52 | |
| 53 | def __init__(self): |
| 54 | self.violations: dict[str, list[tuple[int, str]]] = {} |
| 55 | |
| 56 | def should_process_file(self, file_path: str) -> bool: |
| 57 | """Check if file should be processed. |
| 58 | |
| 59 | Process: |
| 60 | - src/fl/** files |
| 61 | - Root src/*.cpp and src/*.h files |
| 62 | |
| 63 | Skip: |
| 64 | - src/platforms/** files (can include anything) |
| 65 | """ |
| 66 | # Normalize path |
| 67 | normalized_path = file_path.replace("\\", "/") |
| 68 | |
| 69 | # Skip if not in src/ |
| 70 | if "/src/" not in normalized_path: |
| 71 | return False |
| 72 | |
| 73 | # Extract parts after src/ |
| 74 | parts_after_src = normalized_path.split("/src/", 1)[1].split("/") |
| 75 | |
| 76 | # Allow src/platforms/** to include anything |
| 77 | if parts_after_src[0] == "platforms": |
| 78 | return False |
| 79 | |
| 80 | # Check src/fl/** |
| 81 | if parts_after_src[0] == "fl": |
| 82 | return True |
| 83 | |
| 84 | # Check root src/*.{cpp,h} (direct children of src/) |
| 85 | if len(parts_after_src) == 1 and file_path.endswith((".cpp", ".h", ".hpp")): |
| 86 | return True |
| 87 | |
| 88 | return False |
| 89 | |
| 90 | def check_file_content(self, file_content: FileContent) -> list[str]: |
| 91 | """Check file for deep platform includes.""" |
| 92 | violations: list[tuple[int, str]] = [] |
| 93 | in_multiline_comment = False |
| 94 | |
| 95 | for line_number, line in enumerate(file_content.lines, 1): |
| 96 | stripped = line.strip() |
| 97 | |
| 98 | # Track multi-line comment state |
| 99 | if "/*" in line: |
| 100 | in_multiline_comment = True |
| 101 | if "*/" in line: |
| 102 | in_multiline_comment = False |
| 103 | continue |
| 104 | |
| 105 | # Skip if in multi-line comment |
| 106 | if in_multiline_comment: |
| 107 | continue |
no outgoing calls
no test coverage detected