Skip to content

Commit

Permalink
Add footer with totals to table
Browse files Browse the repository at this point in the history
  • Loading branch information
robvanderleek committed Aug 10, 2024
1 parent ba7beff commit fc4c774
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions codelimit/common/ScanResultTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 0 additions & 8 deletions codelimit/common/Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit fc4c774

Please sign in to comment.