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

Function check_relative_includes

cpp_lint.py:32–54  ·  view source on GitHub ↗

Check a file for #include directives containing ".." Returns: List of (line_number, line_content) tuples for offending includes

(file_path: Path)

Source from the content-addressed store, hash-verified

30
31
32def check_relative_includes(file_path: Path) -> List[Tuple[int, str]]:
33 """
34 Check a file for #include directives containing ".."
35
36 Returns:
37 List of (line_number, line_content) tuples for offending includes
38 """
39 violations: List[Tuple[int, str]] = []
40
41 # Regex to match #include directives with ".." in the path
42 # Matches both #include "path/with/../file.h" and #include <path/with/../file.h>
43 include_pattern = re.compile(r'^\s*#\s*include\s+[<"]([^>"]*\.\..*)[>"]')
44
45 try:
46 with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
47 for line_num, line in enumerate(f, start=1):
48 match = include_pattern.match(line)
49 if match:
50 violations.append((line_num, line.rstrip()))
51 except Exception as e:
52 print(f"Warning: Could not read {file_path}: {e}", file=sys.stderr)
53
54 return violations
55
56
57def check_fastled_header_usage(file_path: Path) -> List[Tuple[int, str]]:

Callers 1

mainFunction · 0.85

Calls 3

compileMethod · 0.80
printFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected