Run all applicable checkers on a single file. Args: file_path: Absolute path to the file to check checkers_by_scope: Dictionary of checkers organized by scope Returns: Dictionary mapping checker class name to CheckerResults
(
file_path: str, checkers_by_scope: dict[str, list[FileContentChecker]]
)
| 800 | |
| 801 | |
| 802 | def run_checkers_on_single_file( |
| 803 | file_path: str, checkers_by_scope: dict[str, list[FileContentChecker]] |
| 804 | ) -> dict[str, CheckerResults]: |
| 805 | """Run all applicable checkers on a single file. |
| 806 | |
| 807 | Args: |
| 808 | file_path: Absolute path to the file to check |
| 809 | checkers_by_scope: Dictionary of checkers organized by scope |
| 810 | |
| 811 | Returns: |
| 812 | Dictionary mapping checker class name to CheckerResults |
| 813 | """ |
| 814 | processor = MultiCheckerFileProcessor() |
| 815 | normalized_path = str(Path(file_path).resolve()) |
| 816 | |
| 817 | # Determine which scopes apply to this file |
| 818 | applicable_scopes = _determine_file_scopes(normalized_path) |
| 819 | |
| 820 | # Collect all checkers for the applicable scopes |
| 821 | applicable_checkers: list[FileContentChecker] = [] |
| 822 | for scope in applicable_scopes: |
| 823 | applicable_checkers.extend(checkers_by_scope.get(scope, [])) |
| 824 | |
| 825 | # Remove duplicate checkers (same instance may be added from multiple scopes) |
| 826 | seen_checkers: set[int] = set() |
| 827 | unique_checkers: list[FileContentChecker] = [] |
| 828 | for checker in applicable_checkers: |
| 829 | checker_id = id(checker) |
| 830 | if checker_id not in seen_checkers: |
| 831 | seen_checkers.add(checker_id) |
| 832 | unique_checkers.append(checker) |
| 833 | |
| 834 | # Run all applicable checkers on this single file |
| 835 | if unique_checkers: |
| 836 | processor.process_files_with_checkers([normalized_path], unique_checkers) |
| 837 | return _collect_violations_from_checkers(unique_checkers) |
| 838 | |
| 839 | return {} |
| 840 | |
| 841 | |
| 842 | def main() -> int: |
no test coverage detected