Collect violations from a list of checkers. Args: checkers: List of checker instances to collect violations from Returns: Dictionary mapping checker class name to CheckerResults
(
checkers: list[FileContentChecker],
)
| 676 | |
| 677 | |
| 678 | def _collect_violations_from_checkers( |
| 679 | checkers: list[FileContentChecker], |
| 680 | ) -> dict[str, CheckerResults]: |
| 681 | """Collect violations from a list of checkers. |
| 682 | |
| 683 | Args: |
| 684 | checkers: List of checker instances to collect violations from |
| 685 | |
| 686 | Returns: |
| 687 | Dictionary mapping checker class name to CheckerResults |
| 688 | """ |
| 689 | all_results: dict[str, CheckerResults] = {} |
| 690 | |
| 691 | for checker in checkers: |
| 692 | checker_name = checker.__class__.__name__ |
| 693 | violations = getattr(checker, "violations", None) |
| 694 | if not violations: |
| 695 | continue |
| 696 | |
| 697 | results = _convert_violations_to_results(violations) |
| 698 | |
| 699 | # Merge violations from multiple checkers with same name |
| 700 | if checker_name not in all_results: |
| 701 | all_results[checker_name] = results |
| 702 | else: |
| 703 | # Merge into existing results |
| 704 | for file_path, file_violations in results.violations.items(): |
| 705 | for violation in file_violations.violations: |
| 706 | all_results[checker_name].add_violation( |
| 707 | file_path, violation.line_number, violation.content |
| 708 | ) |
| 709 | |
| 710 | return all_results |
| 711 | |
| 712 | |
| 713 | def _determine_file_scopes(file_path: str) -> set[str]: |
no test coverage detected