From e0543235e164a1a25a6e0c3bee2bd033f438d231 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 8 Dec 2025 17:08:30 -0700 Subject: [PATCH] codman: Sort files alphabetically and drop inactive column Files appear in arbitrary order, making it hard to find specific files. Sort them alphabetically by filename for easier navigation. Also remove the inactive lines column from file output to reduce clutter, keeping only: filename, total lines, active lines, and percentage active. Co-developed-by: Claude Signed-off-by: Simon Glass --- tools/codman/output.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/codman/output.py b/tools/codman/output.py index 3311da593a8..c611a942583 100644 --- a/tools/codman/output.py +++ b/tools/codman/output.py @@ -379,13 +379,8 @@ def print_dir_stats(dir_stats, file_results, by_subdirs, show_files, # Show individual files if requested if show_files and stats.files: - # Sort files by inactive lines (descending) for line-level, or - # alphabetically otherwise - if file_results: - sorted_files = sorted(stats.files, key=lambda x: x['inactive'], - reverse=True) - else: - sorted_files = sorted(stats.files, key=lambda x: x['path']) + # Sort files alphabetically by filename + sorted_files = sorted(stats.files, key=lambda x: os.path.basename(x['path'])) for info in sorted_files: # Skip files with 0 active lines unless show_empty is set @@ -400,8 +395,7 @@ def print_dir_stats(dir_stats, file_results, by_subdirs, show_files, # Show line-level details pct_active = percent(info['active'], info['total']) print(f" {filename:<38} {info['total']:>7} " - f"{info['active']:>7} {pct_active:>6.1f} " - f"{info['inactive']:>7}") + f"{info['active']:>7} {pct_active:>6.1f}") else: # Show file-level only print(f" {filename:<38} {info['total']:>7} lines")