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

Class IncludePathsChecker

ci/lint_cpp/include_paths_checker.py:320–461  ·  view source on GitHub ↗

Checker for include path style enforcement.

Source from the content-addressed store, hash-verified

318
319
320class IncludePathsChecker(FileContentChecker):
321 """Checker for include path style enforcement."""
322
323 def __init__(self, max_errors: int | None = None):
324 self.violations: dict[str, list[tuple[int, str]]] = {}
325 self.total_error_count = 0 # Track total errors to enforce limit
326 self.max_errors = max_errors # None means unlimited, otherwise enforce limit
327
328 def should_process_file(self, file_path: str) -> bool:
329 """Only process files in src/fl/** and src/platforms/**."""
330 # Normalize path separators for cross-platform compatibility
331 normalized_path = file_path.replace("\\", "/")
332
333 # Check file extension
334 if not file_path.endswith((".cpp", ".h", ".hpp", ".c")):
335 return False
336
337 # Check if file is in excluded list
338 if any(file_path.endswith(excluded) for excluded in EXCLUDED_FILES):
339 return False
340
341 # Only check files in src/fl/ and src/platforms/
342 if "/src/fl/" in normalized_path or "/src/platforms/" in normalized_path:
343 return True
344
345 return False
346
347 def check_file_content(self, file_content: FileContent) -> list[str]:
348 """Check file content for invalid include paths."""
349 violations: list[tuple[int, str]] = []
350 in_multiline_comment = False
351
352 for line_number, line in enumerate(file_content.lines, 1):
353 # Stop collecting errors if we've hit the limit
354 if (
355 self.max_errors is not None
356 and self.total_error_count >= self.max_errors
357 ):
358 break
359
360 stripped = line.strip()
361
362 # Track multi-line comment state
363 if "/*" in line:
364 in_multiline_comment = True
365 if "*/" in line:
366 in_multiline_comment = False
367 continue
368
369 # Skip if in multi-line comment
370 if in_multiline_comment:
371 continue
372
373 # Skip single-line comments
374 if stripped.startswith("//"):
375 continue
376
377 # Split line to separate code from inline comments

Callers 2

create_checkersFunction · 0.90
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected