From fc4c77499b8777bcfff305d8a2d66c9bbda4f0db Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Sat, 10 Aug 2024 11:03:59 +0200 Subject: [PATCH] Add footer with totals to table --- .github/workflows/main.yml | 4 ++-- codelimit/common/ScanResultTable.py | 7 ++++--- codelimit/common/Scanner.py | 8 -------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d6814b..fdc37a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,11 +24,11 @@ jobs: run: poetry run pytest --cov --cov-report=xml - name: 'Run codelimit' run: | - poetry run codelimit scan codelimit/ + poetry run codelimit scan . - name: 'Build and run codelimit binary' run: | poetry run pyinstaller -n codelimit -F codelimit/__main__.py - ./dist/codelimit scan codelimit/ + ./dist/codelimit scan . - name: 'Run Code Limit action' uses: getcodelimit/codelimit-action@main with: diff --git a/codelimit/common/ScanResultTable.py b/codelimit/common/ScanResultTable.py index ff3ed69..68a155f 100644 --- a/codelimit/common/ScanResultTable.py +++ b/codelimit/common/ScanResultTable.py @@ -10,12 +10,13 @@ def __init__(self, scan_totals: ScanTotals): super().__init__( expand=True, box=box.SIMPLE, + show_footer=len(scan_totals.languages()) > 1 ) self.scan_totals = scan_totals self.add_column("Language") - self.add_column("Files", justify="right") - self.add_column("Lines of Code", justify="right") - self.add_column("Functions", justify="right") + self.add_column("Files", f'{scan_totals.total_files():n}', justify="right") + self.add_column("Lines of Code", f'{scan_totals.total_loc():n}', justify="right") + self.add_column("Functions", f'{scan_totals.total_functions():n}', justify="right") self.add_column("\u26A0", justify="right") self.add_column("\u2716", justify="right") self._populate() diff --git a/codelimit/common/Scanner.py b/codelimit/common/Scanner.py index 0638503..43f72fd 100644 --- a/codelimit/common/Scanner.py +++ b/codelimit/common/Scanner.py @@ -48,8 +48,6 @@ def add_file_entry(entry: SourceFileEntry): _scan_folder(codebase, path, cached_report, add_file_entry) live.stop() - if len(scan_totals.languages()) > 1: - print_totals(scan_totals) print_refactor_candidates(scan_totals) return codebase @@ -64,12 +62,6 @@ def print_header(cached_report, path): print(" [bold]Found cached report, only analyzing changed files[/bold]") -def print_totals(scan_totals: ScanTotals): - print(f" [bold]Total lines of code[/bold]: {scan_totals.total_loc():n}") - print(f" [bold]Total files[/bold]: {scan_totals.total_files():n}") - print(f" [bold]Total functions[/bold]: {scan_totals.total_functions():n}") - - def print_refactor_candidates(scan_totals: ScanTotals): total_hard_to_maintain = scan_totals.total_hard_to_maintain() if total_hard_to_maintain > 0: