Lint all files in parallel.
(files: List[Path], compile_commands: Path, fix: bool, jobs: int)
| 124 | |
| 125 | |
| 126 | async def lint_all_files(files: List[Path], compile_commands: Path, fix: bool, jobs: int): |
| 127 | """Lint all files in parallel.""" |
| 128 | extra_args = get_system_include_args() |
| 129 | semaphore = asyncio.Semaphore(jobs) |
| 130 | |
| 131 | # Create tasks for all files |
| 132 | tasks = [ |
| 133 | lint_file(file, compile_commands, fix, extra_args, semaphore) |
| 134 | for file in files |
| 135 | ] |
| 136 | |
| 137 | # Run with progress bar |
| 138 | with Progress( |
| 139 | SpinnerColumn(), |
| 140 | TextColumn("[progress.description]{task.description}"), |
| 141 | BarColumn(), |
| 142 | MofNCompleteColumn(), |
| 143 | console=console, |
| 144 | ) as progress: |
| 145 | task_id = progress.add_task( |
| 146 | "[cyan]Linting files...", |
| 147 | total=len(files) |
| 148 | ) |
| 149 | |
| 150 | failed_files = [] |
| 151 | |
| 152 | # Process results as they complete |
| 153 | for coro in asyncio.as_completed(tasks): |
| 154 | file, success, output = await coro |
| 155 | progress.update(task_id, advance=1) |
| 156 | |
| 157 | if success: |
| 158 | console.print(f"[green]✓[/green] {file.name}") |
| 159 | else: |
| 160 | console.print(f"[red]✗[/red] {file.name}") |
| 161 | failed_files.append((file, output)) |
| 162 | |
| 163 | # Print details for failed files |
| 164 | if failed_files: |
| 165 | console.print("\n[red]Issues found in the following files:[/red]") |
| 166 | for file, output in failed_files: |
| 167 | console.print(f"\n[yellow]{file}:[/yellow]") |
| 168 | console.print(output) |
| 169 | |
| 170 | return len(failed_files) == 0 |
| 171 | |
| 172 | |
| 173 | @click.command() |
no test coverage detected