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

Function main

ci/lint_cpp/include_paths_checker.py:624–753  ·  view source on GitHub ↗

Run include paths checker standalone.

()

Source from the content-addressed store, hash-verified

622
623
624def main() -> None:
625 """Run include paths checker standalone."""
626 import sys
627
628 from ci.util.check_files import (
629 FileContent,
630 MultiCheckerFileProcessor,
631 collect_files_to_check,
632 )
633 from ci.util.paths import PROJECT_ROOT
634
635 # Check for --json and --fix flags
636 json_output = None
637 apply_fix = False
638
639 if "--fix" in sys.argv:
640 apply_fix = True
641 sys.argv.remove("--fix")
642
643 if "--json" in sys.argv:
644 json_idx = sys.argv.index("--json")
645 if json_idx + 1 < len(sys.argv):
646 json_output = sys.argv[json_idx + 1]
647 else:
648 json_output = "include_path_violations.json"
649 # Remove flags from argv before running checker
650 sys.argv.pop(json_idx)
651 if json_output != "include_path_violations.json":
652 sys.argv.pop(json_idx)
653
654 # Run checker - with unlimited errors if JSON export or fix is requested
655 checker = IncludePathsChecker(
656 max_errors=None if (json_output or apply_fix) else MAX_VALIDATION_ERRORS
657 )
658 directories = [
659 str(PROJECT_ROOT / "src" / "fl"),
660 str(PROJECT_ROOT / "src" / "platforms"),
661 ]
662
663 files_to_check = collect_files_to_check(
664 directories, extensions=[".cpp", ".h", ".hpp", ".c"]
665 )
666
667 # Load file contents for fixing
668 file_contents: dict[str, FileContent] = {}
669 for file_path in files_to_check:
670 with open(file_path, "r", encoding="utf-8", errors="replace") as f:
671 content = f.read()
672 file_contents[file_path] = FileContent(
673 path=file_path, content=content, lines=content.splitlines(keepends=True)
674 )
675
676 processor = MultiCheckerFileProcessor()
677 processor.process_files_with_checkers(files_to_check, [checker])
678
679 # Apply fixes if requested
680 if apply_fix and checker.violations:
681 # Map normalized paths back to actual file paths for fixing

Callers 1

Calls 15

collect_files_to_checkFunction · 0.90
FileContentClass · 0.90
apply_fixesFunction · 0.85
export_violations_jsonFunction · 0.85
itemsMethod · 0.80
valuesMethod · 0.80
IncludePathsCheckerClass · 0.70
printFunction · 0.50
removeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected