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

Function _apply_fixes

ci/lint/clang_tidy/noexcept_platforms.py:260–310  ·  view source on GitHub ↗

Apply FL_NOEXCEPT insertions to source files. Returns (changes_applied, files_modified).

(hits: list[tuple[str, int, str]], dry_run: bool)

Source from the content-addressed store, hash-verified

258
259
260def _apply_fixes(hits: list[tuple[str, int, str]], dry_run: bool) -> tuple[int, int]:
261 """Apply FL_NOEXCEPT insertions to source files.
262
263 Returns (changes_applied, files_modified).
264 """
265 # Group hits by file
266 by_file: dict[str, list[int]] = {}
267 for filepath, line_num, _ in hits:
268 by_file.setdefault(filepath, []).append(line_num)
269
270 total_changes = 0
271 total_files = 0
272
273 for filepath in sorted(by_file):
274 full_path = PROJECT_ROOT / filepath
275 if not full_path.exists():
276 continue
277
278 content = full_path.read_text(encoding="utf-8", errors="replace")
279 lines = content.split("\n")
280 file_changes = 0
281
282 for line_num in sorted(by_file[filepath]):
283 if line_num < 1 or line_num > len(lines):
284 continue
285
286 old_line = lines[line_num - 1]
287 new_line = _insert_fl_noexcept(old_line)
288
289 if new_line is not None and new_line != old_line:
290 if dry_run:
291 print(f" {filepath}:{line_num}")
292 print(f" - {old_line.strip()}")
293 print(f" + {new_line.strip()}")
294 lines[line_num - 1] = new_line
295 file_changes += 1
296
297 if file_changes > 0:
298 include_added = _ensure_include(lines)
299
300 if not dry_run:
301 full_path.write_text("\n".join(lines), encoding="utf-8")
302 print(
303 f" {filepath}: {file_changes} changes"
304 f"{' (+include)' if include_added else ''}"
305 )
306
307 total_changes += file_changes
308 total_files += 1
309
310 return total_changes, total_files
311
312
313# ============================================================================

Callers 1

mainFunction · 0.70

Calls 4

_insert_fl_noexceptFunction · 0.85
_ensure_includeFunction · 0.70
printFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected