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

Method check_file_content

ci/lint_cpp/cpp_include_checker.py:31–74  ·  view source on GitHub ↗

Check file content for .cpp file includes.

(self, file_content: FileContent)

Source from the content-addressed store, hash-verified

29 return True
30
31 def check_file_content(self, file_content: FileContent) -> list[str]:
32 """Check file content for .cpp file includes."""
33 # Unity build aggregator files are exempt — they exist solely to
34 # #include other .cpp files into a single translation unit.
35 for line in file_content.lines[:5]:
36 if "// ok cpp include" in line.lower():
37 return []
38
39 violations: list[tuple[int, str]] = []
40 in_multiline_comment = False
41
42 # Check each line for .cpp includes
43 for line_number, line in enumerate(file_content.lines, 1):
44 stripped = line.strip()
45
46 # Track multi-line comment state
47 if "/*" in line:
48 in_multiline_comment = True
49 if "*/" in line:
50 in_multiline_comment = False
51 continue # Skip the line with closing */
52
53 # Skip if we're inside a multi-line comment
54 if in_multiline_comment:
55 continue
56
57 # Skip single-line comment lines
58 if stripped.startswith("//"):
59 continue
60
61 # Remove single-line comment portion before checking
62 code_part = line.split("//")[0]
63
64 # Check for .cpp includes in code portion
65 match = self._CPP_INCLUDE_PATTERN.search(code_part)
66 if match:
67 cpp_file = match.group(1)
68 violations.append((line_number, f'#include "{cpp_file}"'))
69
70 # Store violations if any found
71 if violations:
72 self.violations[file_content.path] = violations
73
74 return [] # MUST return empty list
75
76
77def main() -> None:

Callers 1

_checkMethod · 0.95

Calls 1

appendMethod · 0.45

Tested by 1

_checkMethod · 0.76