Validate that no new Arduino.h includes have been added to the codebase.
(
arguments: dict[str, Any], project_root: Path
)
| 2345 | |
| 2346 | |
| 2347 | async def validate_arduino_includes( |
| 2348 | arguments: dict[str, Any], project_root: Path |
| 2349 | ) -> CallToolResult: |
| 2350 | """Validate that no new Arduino.h includes have been added to the codebase.""" |
| 2351 | directory = arguments.get("directory", "src") |
| 2352 | include_examples = arguments.get("include_examples", False) |
| 2353 | check_dev = arguments.get("check_dev", False) |
| 2354 | show_approved = arguments.get("show_approved", True) |
| 2355 | |
| 2356 | result_text = "# Arduino.h Include Validation\n\n" |
| 2357 | |
| 2358 | # Define directories to scan |
| 2359 | scan_dirs = [directory] |
| 2360 | if include_examples: |
| 2361 | scan_dirs.append("examples") |
| 2362 | if check_dev: |
| 2363 | scan_dirs.append("dev") |
| 2364 | |
| 2365 | # Known approved includes (from our grep search) |
| 2366 | approved_includes = { |
| 2367 | "src/fl/sensors/digital_pin.hpp": "ok include", |
| 2368 | "src/third_party/arduinojson/json.hpp": "ok include", |
| 2369 | "src/lib8tion.cpp": "ok include", |
| 2370 | "src/led_sysdefs.h": "ok include", |
| 2371 | "src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h": True, |
| 2372 | # WASM platform includes are specifically for the WASM platform |
| 2373 | "src/platforms/wasm/led_sysdefs_wasm.h": True, |
| 2374 | "src/platforms/wasm/clockless.h": True, |
| 2375 | "src/platforms/wasm/compiler/Arduino.cpp": True, |
| 2376 | "src/FastLED.h": True, # References WASM Arduino.h |
| 2377 | } |
| 2378 | |
| 2379 | all_includes: list[dict[str, Any]] = [] |
| 2380 | violations: list[dict[str, Any]] = [] |
| 2381 | approved_count = 0 |
| 2382 | |
| 2383 | try: |
| 2384 | for scan_dir in scan_dirs: |
| 2385 | scan_path = project_root / scan_dir |
| 2386 | if not scan_path.exists(): |
| 2387 | result_text += f"⚠️ Directory not found: {scan_dir}\n" |
| 2388 | continue |
| 2389 | |
| 2390 | result_text += f"📁 Scanning directory: {scan_dir}\n" |
| 2391 | |
| 2392 | # Use ripgrep to find Arduino.h includes |
| 2393 | try: |
| 2394 | cmd = [ |
| 2395 | "rg", |
| 2396 | "--type", |
| 2397 | "cpp", |
| 2398 | "--type", |
| 2399 | "c", |
| 2400 | r"#include.*Arduino\.h", |
| 2401 | str(scan_path), |
| 2402 | ] |
| 2403 | output = await run_command(cmd, project_root) |
| 2404 |
no test coverage detected