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

Function _ensure_include

ci/lint_cpp/noexcept_special_members_checker.py:387–403  ·  view source on GitHub ↗

Ensure ``#include "fl/stl/noexcept.h"`` is present when FL_NOEXCEPT is used.

(content: str)

Source from the content-addressed store, hash-verified

385
386
387def _ensure_include(content: str) -> str:
388 """Ensure ``#include "fl/stl/noexcept.h"`` is present when FL_NOEXCEPT is used."""
389 if "fl/stl/noexcept.h" in content:
390 return content
391 if "FL_NOEXCEPT" not in content:
392 return content
393
394 lines = content.split("\n")
395 insert_idx = 0
396 for i, ln in enumerate(lines):
397 stripped = ln.strip()
398 if stripped.startswith("#include"):
399 insert_idx = i + 1
400 elif stripped == "#pragma once" and insert_idx == 0:
401 insert_idx = i + 1
402 lines.insert(insert_idx, _NOEXCEPT_INCLUDE)
403 return "\n".join(lines)
404
405
406def fix_file(path: Path, dry_run: bool = False) -> tuple[int, list[str]]:

Callers 1

fix_fileFunction · 0.70

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected