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

Function format_and_print_results

ci/lint_cpp/run_all_checkers.py:473–540  ·  view source on GitHub ↗

Format and print all violations. Returns exit code (0 = success, 1 = failures). Args: results: Checker results to format. max_violations_per_checker: Maximum violations to print per checker before truncating output. Set to 0 for unlimited.

(
    results: dict[str, CheckerResults], max_violations_per_checker: int = 10
)

Source from the content-addressed store, hash-verified

471
472
473def format_and_print_results(
474 results: dict[str, CheckerResults], max_violations_per_checker: int = 10
475) -> int:
476 """Format and print all violations. Returns exit code (0 = success, 1 = failures).
477
478 Args:
479 results: Checker results to format.
480 max_violations_per_checker: Maximum violations to print per checker before
481 truncating output. Set to 0 for unlimited.
482 """
483 total_violations = 0
484
485 for checker_name, checker_results in sorted(results.items()):
486 if not checker_results.has_violations():
487 continue
488
489 file_count = checker_results.file_count()
490 violation_count = checker_results.total_violations()
491 total_violations += violation_count
492
493 print(f"\n{'=' * 80}")
494 print(
495 f"[{checker_name}] Found {violation_count} violation(s) in {file_count} file(s):"
496 )
497 print("=" * 80)
498
499 printed_violations = 0
500 truncated = False
501 for file_path in sorted(checker_results.violations.keys()):
502 if (
503 max_violations_per_checker > 0
504 and printed_violations >= max_violations_per_checker
505 ):
506 truncated = True
507 break
508 rel_path = os.path.relpath(file_path, PROJECT_ROOT)
509 # Normalize to forward slashes for consistent cross-platform output
510 rel_path = rel_path.replace("\\", "/")
511 file_violations = checker_results.violations[file_path]
512
513 print(f"\n{rel_path}:")
514 for violation in file_violations.violations:
515 if (
516 max_violations_per_checker > 0
517 and printed_violations >= max_violations_per_checker
518 ):
519 truncated = True
520 break
521 print(f" Line {violation.line_number}: {violation.content}")
522 printed_violations += 1
523
524 if truncated:
525 remaining = violation_count - printed_violations
526 print(
527 f"\n ... stopped after {max_violations_per_checker} violations"
528 f" ({remaining} more not shown)"
529 )
530

Callers 1

mainFunction · 0.85

Calls 6

itemsMethod · 0.80
file_countMethod · 0.80
total_violationsMethod · 0.80
printFunction · 0.50
has_violationsMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected