Search a directory and process files using the provided callback. Args: start_dir: Directory to start searching from callback: Callback class to handle file processing Returns: List of all issues found across all files
(
self, start_dir: str, callback: FileProcessorCallback
)
| 246 | self.max_workers = max_workers or NUM_WORKERS |
| 247 | |
| 248 | def search_directory( |
| 249 | self, start_dir: str, callback: FileProcessorCallback |
| 250 | ) -> list[str]: |
| 251 | """Search a directory and process files using the provided callback. |
| 252 | |
| 253 | Args: |
| 254 | start_dir: Directory to start searching from |
| 255 | callback: Callback class to handle file processing |
| 256 | |
| 257 | Returns: |
| 258 | List of all issues found across all files |
| 259 | """ |
| 260 | files_to_check: list[str] = [] |
| 261 | |
| 262 | # Collect all files that should be processed |
| 263 | for root, _, files in os.walk(start_dir): |
| 264 | for file in files: |
| 265 | file_path = os.path.join(root, file) |
| 266 | if callback.should_process_file(file_path): |
| 267 | files_to_check.append(file_path) |
| 268 | |
| 269 | # Process files in parallel |
| 270 | all_issues: list[str] = [] |
| 271 | with ThreadPoolExecutor(max_workers=self.max_workers) as executor: |
| 272 | futures = [ |
| 273 | executor.submit(self._process_single_file, file_path, callback) |
| 274 | for file_path in files_to_check |
| 275 | ] |
| 276 | for future in futures: |
| 277 | all_issues.extend(future.result()) |
| 278 | |
| 279 | return all_issues |
| 280 | |
| 281 | def _process_single_file( |
| 282 | self, file_path: str, callback: FileProcessorCallback |
nothing calls this directly
no test coverage detected