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

Class NativePlatformDefinesChecker

ci/lint_cpp/native_platform_defines_checker.py:333–484  ·  view source on GitHub ↗

Checker for native platform defines across all src/ directories. Scans all C++ files under src/ for native platform, OS, and compiler defines in preprocessor conditionals and suggests FL_IS_* equivalents. Exclusions: - third_party/ (external code we don't control) - is_*.h

Source from the content-addressed store, hash-verified

331
332
333class NativePlatformDefinesChecker(FileContentChecker):
334 """Checker for native platform defines across all src/ directories.
335
336 Scans all C++ files under src/ for native platform, OS, and compiler
337 defines in preprocessor conditionals and suggests FL_IS_* equivalents.
338
339 Exclusions:
340 - third_party/ (external code we don't control)
341 - is_*.h detection headers (they define FL_IS_* from native defines)
342 - Root dispatch headers (platforms.h, led_sysdefs.h, etc.)
343 - Platform-level dispatch headers (fastpin_*.h, led_sysdefs_*.h, etc.)
344 - Compiler abstraction files (compiler_control.h, deprecated.h, etc.)
345 - Compile test files
346 - core_detection.h
347 - lib8tion/config.h (architecture-level dispatch for ASM vs C)
348 """
349
350 def __init__(self):
351 self.violations: dict[str, list[tuple[int, str]]] = {}
352
353 def should_process_file(self, file_path: str) -> bool:
354 """Check if file should be processed for native platform defines."""
355 # Must be under src/
356 if not file_path.startswith(str(SRC_ROOT)):
357 return False
358
359 # Check file extension - .h, .cpp, .hpp files
360 if not file_path.endswith((".cpp", ".h", ".hpp")):
361 return False
362
363 path_obj = Path(file_path)
364 file_name = path_obj.name
365
366 # ── Third-party exclusion ────────────────────────────────────
367 # External libraries use raw compiler/OS defines appropriately;
368 # we don't control their code.
369 try:
370 path_obj.relative_to(SRC_ROOT / "third_party")
371 return False
372 except ValueError:
373 pass
374
375 # Skip the is_*.h detection headers — they MUST use native defines
376 # These files convert native compiler defines into FL_IS_* defines
377 if file_name.startswith("is_"):
378 return False
379
380 # Skip core detection headers — they detect which Arduino core is in use
381 if "core_detection" in file_name.lower():
382 return False
383
384 # Skip compile test files
385 if "compile_test" in file_name.lower():
386 return False
387
388 # ── Compiler abstraction files ───────────────────────────────
389 # These files define macros wrapping compiler-specific features
390 # (pragmas, attributes, builtins, DLL export/import).

Callers 3

_get_violationsFunction · 0.90
create_checkersFunction · 0.90
mainFunction · 0.70

Calls

no outgoing calls

Tested by 1

_get_violationsFunction · 0.72