Checker for C++ standard attributes - should use FL_* macros instead.
| 45 | |
| 46 | |
| 47 | class AttributeChecker(FileContentChecker): |
| 48 | """Checker for C++ standard attributes - should use FL_* macros instead.""" |
| 49 | |
| 50 | def __init__(self): |
| 51 | self.violations: dict[str, list[tuple[int, str]]] = {} |
| 52 | |
| 53 | def should_process_file(self, file_path: str) -> bool: |
| 54 | """Check if file should be processed.""" |
| 55 | # Check C++ file extensions |
| 56 | if not file_path.endswith((".cpp", ".h", ".hpp", ".ino", ".cpp.hpp")): |
| 57 | return False |
| 58 | |
| 59 | # Skip the file that defines FL_* macros |
| 60 | if file_path.endswith("compiler_control.h"): |
| 61 | return False |
| 62 | |
| 63 | # Skip third-party libraries (they define their own attributes) |
| 64 | if "/third_party/" in file_path.replace("\\", "/"): |
| 65 | return False |
| 66 | |
| 67 | # Skip external test frameworks (doctest.h, etc.) |
| 68 | if file_path.endswith(("doctest.h", "catch.hpp", "gtest.h")): |
| 69 | return False |
| 70 | |
| 71 | return True |
| 72 | |
| 73 | def check_file_content(self, file_content: FileContent) -> list[str]: |
| 74 | """Check file content for C++ standard attribute usage.""" |
| 75 | violations: list[tuple[int, str]] = [] |
| 76 | in_multiline_comment = False |
| 77 | |
| 78 | for line_number, line in enumerate(file_content.lines, 1): |
| 79 | stripped = line.strip() |
| 80 | |
| 81 | # Track multi-line comment state |
| 82 | if "/*" in line: |
| 83 | in_multiline_comment = True |
| 84 | if "*/" in line: |
| 85 | in_multiline_comment = False |
| 86 | continue |
| 87 | |
| 88 | # Skip if inside multi-line comment |
| 89 | if in_multiline_comment: |
| 90 | continue |
| 91 | |
| 92 | # Skip single-line comment lines |
| 93 | if stripped.startswith("//"): |
| 94 | continue |
| 95 | |
| 96 | # Remove single-line comment portion before checking |
| 97 | code_part = line.split("//")[0] |
| 98 | |
| 99 | # Skip lines that define FL_* macros |
| 100 | if "#define" in code_part and "FL_" in code_part: |
| 101 | continue |
| 102 | |
| 103 | # Fast first pass: skip regex if line contains neither [[ nor alignas |
| 104 | if "[[" not in code_part and "alignas" not in code_part: |
no outgoing calls
no test coverage detected