@@ -369,4 +369,55 @@ def remove(ctx: click.Context, dry_run: bool, category: str | None) -> None:
369369 else :
370370 for line_num in safe_lines :
371371 lines [line_num - 1 ] = "" # Blank the line (safer than deleting)
372-
372+ if safe_lines :
373+ filepath .write_text ("" .join (lines ), encoding = "utf-8" )
374+ removed_count += len (safe_lines )
375+ console .print (
376+ f"[green]✓[/green] Cleaned { rel_file } ({ len (safe_lines )} lines)"
377+ )
378+
379+ for line_num in sorted (skipped_lines ):
380+ content = lines [line_num - 1 ].strip () if 0 < line_num <= len (lines ) else ""
381+ console .print (
382+ f"[yellow]⚠ SKIPPED (multi-line — remove manually)[/yellow] "
383+ f"{ rel_file } :{ line_num } — { content [:80 ]} "
384+ )
385+
386+ action = "Would remove" if dry_run else "Removed"
387+ console .print (f"\n [bold]{ action } : { removed_count } dead code entries[/bold]" )
388+
389+
390+ # ── stats ─────────────────────────────────────────────────────────────
391+
392+
393+ @cli .command ()
394+ @click .pass_context
395+ def stats (ctx : click .Context ) -> None :
396+ """Show quick stats about the project's dead code."""
397+ project = ctx .obj ["project" ]
398+ ignore = _merge_config_ignore (ctx )
399+ include_patterns = ctx .obj .get ("include" )
400+ scanner = DeadCodeScanner (
401+ project , ignore_patterns = ignore , include_patterns = include_patterns
402+ )
403+ result = scanner .scan ()
404+
405+ console .print (f"Files scanned: [bold]{ result .files_scanned } [/bold]" )
406+ console .print (
407+ f"Unused exports: [bold yellow]{ len (result .unused_exports )} [/bold yellow]"
408+ )
409+ console .print (f"Dead routes: [bold red]{ len (result .dead_routes )} [/bold red]" )
410+ console .print (
411+ f"Orphaned CSS: [bold magenta]{ len (result .orphaned_css )} [/bold magenta]"
412+ )
413+ console .print (
414+ f"Unreferenced components: [bold cyan]{ len (result .unreferenced_components )} [/bold cyan]"
415+ )
416+ console .print (f"Total findings: [bold]{ len (result .findings )} [/bold]" )
417+
418+ if result .errors :
419+ console .print (f"[yellow]Errors: { len (result .errors )} [/yellow]" )
420+
421+
422+ if __name__ == "__main__" :
423+ cli ()
0 commit comments