MCPcopy Create free account
hub / github.com/FastLED/FastLED / LoggingInIramChecker

Class LoggingInIramChecker

ci/lint_cpp/logging_in_iram_checker.py:53–203  ·  view source on GitHub ↗

Checker for logging macros in FL_IRAM functions.

Source from the content-addressed store, hash-verified

51
52
53class LoggingInIramChecker(FileContentChecker):
54 """Checker for logging macros in FL_IRAM functions."""
55
56 def __init__(self):
57 self.violations: dict[str, list[tuple[int, str]]] = {}
58
59 def should_process_file(self, file_path: str) -> bool:
60 """Only process C++ files in critical directories."""
61 # Check if file is in excluded list
62 if any(file_path.endswith(excluded) for excluded in EXCLUDED_FILES):
63 return False
64
65 # Only check .cpp and .h files
66 if not file_path.endswith((".cpp", ".h", ".hpp")):
67 return False
68
69 # Only check critical directories
70 critical_dirs = ["/platforms/", "/fl/"]
71 if not any(
72 critical_dir in file_path.replace("\\", "/")
73 for critical_dir in critical_dirs
74 ):
75 return False
76
77 return True
78
79 def check_file_content(self, file_content: FileContent) -> list[str]:
80 """Check for logging macros in FL_IRAM functions."""
81 violations: list[tuple[int, str]] = []
82
83 # Join lines and strip comments for parsing
84 full_content = "\n".join(file_content.lines)
85
86 # Quick first pass: skip files without FL_IRAM
87 if "FL_IRAM" not in full_content:
88 return []
89
90 cleaned_content = strip_comments(full_content)
91
92 # Find all FL_IRAM function definitions
93 # Pattern matches various forms:
94 # - void FL_IRAM func()
95 # - FL_IRAM void func()
96 # - static void FL_IRAM func()
97 # - static FL_IRAM void func()
98 # - template<T> T FL_IRAM func()
99 # - FL_OPTIMIZE_FUNCTION FL_IRAM\nstatic void func() (multi-line)
100 # - FL_IRAM static bool __attribute__(...) func() (attributes)
101 # Pattern explanation:
102 # 1. Match FL_IRAM keyword
103 # 2. Handle optional modifiers/attributes/return type after FL_IRAM (may span lines)
104 # 3. Extract function name (including ClassName:: prefix for methods)
105 # 4. Find opening brace
106 iram_func_pattern = re.compile(
107 r"FL_IRAM" # FL_IRAM marker
108 r"[\s\n]+" # Whitespace/newlines after FL_IRAM
109 r"(?:static\s+)?" # Optional static
110 r"(?:inline\s+)?" # Optional inline

Callers 2

create_checkersFunction · 0.90
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected