Run clang-tidy on all C++ source files in parallel.
(fix: bool, jobs: int)
| 174 | |
| 175 | @click.command() |
| 176 | @click.option("--fix", is_flag=True, help="Apply fixes automatically") |
| 177 | @click.option("--jobs", "-j", type=int, default=os.cpu_count() or 4, help="Number of parallel jobs") |
| 178 | def main(fix: bool, jobs: int): |
| 179 | """Run clang-tidy on all C++ source files in parallel.""" |
| 180 | # Check if clang-tidy is installed |
| 181 | if not shutil.which("clang-tidy"): |
| 182 | console.print("[red]Error: clang-tidy is not installed.[/red]") |
| 183 | console.print("Install it with: brew install llvm (macOS) or apt-get install clang-tidy (Ubuntu)") |
| 184 | sys.exit(1) |
| 185 | |
| 186 | # Find compile_commands.json |
| 187 | compile_commands = find_compile_commands() |
| 188 | if not compile_commands: |
| 189 | console.print("[red]Error: compile_commands.json not found.[/red]") |
| 190 | console.print("Please build the project first with:") |
| 191 | console.print(" cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON") |
| 192 | console.print(" cmake --build build") |
| 193 | sys.exit(1) |
| 194 | |
| 195 | console.print(f"[blue]Using compile commands: {compile_commands}[/blue]") |
| 196 | console.print(f"[blue]Running with {jobs} parallel jobs[/blue]") |
| 197 | |
| 198 | # Find all C++ files |
| 199 | files = find_cpp_files() |
| 200 | console.print(f"[blue]Found {len(files)} files to lint[/blue]\n") |
| 201 | |
| 202 | if not files: |
| 203 | console.print("[yellow]No C++ files found to lint[/yellow]") |
| 204 | return |
| 205 | |
| 206 | # Run linting |
| 207 | success = asyncio.run(lint_all_files(files, compile_commands, fix, jobs)) |
| 208 | |
| 209 | # Print summary |
| 210 | console.print() |
| 211 | if success: |
| 212 | if fix: |
| 213 | console.print("[green]✅ Linting completed with fixes applied[/green]") |
| 214 | else: |
| 215 | console.print("[green]✅ No linting issues found[/green]") |
| 216 | sys.exit(0) |
| 217 | else: |
| 218 | if fix: |
| 219 | console.print("[yellow]⚠️ Some files could not be automatically fixed[/yellow]") |
| 220 | else: |
| 221 | console.print("[red]❌ Linting issues found. Run 'uv run scripts/lint.py --fix' to auto-fix some issues.[/red]") |
| 222 | sys.exit(1) |
| 223 |
no test coverage detected