Run banned namespace checker standalone.
()
| 73 | |
| 74 | |
| 75 | def main() -> None: |
| 76 | """Run banned namespace checker standalone.""" |
| 77 | import sys |
| 78 | |
| 79 | from ci.util.check_files import MultiCheckerFileProcessor, collect_files_to_check |
| 80 | |
| 81 | checker = BannedNamespaceChecker() |
| 82 | |
| 83 | # Collect files to check |
| 84 | files_to_check = collect_files_to_check( |
| 85 | [str(PROJECT_ROOT / "src"), str(PROJECT_ROOT / "tests")], |
| 86 | extensions=[".cpp", ".h", ".hpp", ".cc"], |
| 87 | ) |
| 88 | |
| 89 | # Run checker |
| 90 | processor = MultiCheckerFileProcessor() |
| 91 | processor.process_files_with_checkers(files_to_check, [checker]) |
| 92 | |
| 93 | # Check for violations |
| 94 | violations = checker.violations |
| 95 | |
| 96 | if violations: |
| 97 | # Print violations with custom error message |
| 98 | print("❌ Improper include inside namespace detected!") |
| 99 | print(" If you are using 'fl::fl', this means you included a file inside") |
| 100 | print(" the namespace declaration. Please review what you did and fix it.") |
| 101 | print() |
| 102 | print(" Common causes:") |
| 103 | print(" - #include directive placed after 'namespace fl {' declaration") |
| 104 | print(" - File included inside namespace scope instead of at global scope") |
| 105 | print() |
| 106 | print(f"Found {sum(len(v) for v in violations.values())} violation(s):") |
| 107 | print() |
| 108 | |
| 109 | for file_path, file_violations in sorted(violations.items()): |
| 110 | rel_path = file_path.replace(str(PROJECT_ROOT), "").lstrip("\\/") |
| 111 | print(f"{rel_path}:") |
| 112 | for line_num, line_content in file_violations: |
| 113 | print(f" Line {line_num}: {line_content}") |
| 114 | print() |
| 115 | |
| 116 | sys.exit(1) |
| 117 | else: |
| 118 | print("✅ No banned namespace patterns found.") |
| 119 | sys.exit(0) |
| 120 | |
| 121 | |
| 122 | if __name__ == "__main__": |
no test coverage detected