Skip to content

Commit

Permalink
fix: 🩹 Fix Markdown report
Browse files Browse the repository at this point in the history
  • Loading branch information
robvanderleek committed Dec 3, 2024
1 parent 5e98a84 commit a3552b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
17 changes: 9 additions & 8 deletions codelimit/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ def _report_totals_markdown(st: ScanTotals) -> str:
f"{lt.hard_to_maintain} | "
f"{lt.unmaintainable} |\n"
)
result += (
f"| | "
f"**{st.total_files()}** | "
f"**{st.total_loc()}** | "
f"**{st.total_functions()}** | "
f"**{st.total_hard_to_maintain()}** | "
f"**{st.total_unmaintainable()}** |"
)
if len(st.languages_totals()) > 1:
result += (
f"| **Totals** | "
f"**{st.total_files()}** | "
f"**{st.total_loc()}** | "
f"**{st.total_functions()}** | "
f"**{st.total_hard_to_maintain()}** | "
f"**{st.total_unmaintainable()}** |"
)
return result


Expand Down
29 changes: 27 additions & 2 deletions tests/commands/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from codelimit.common.report.ReportUnit import ReportUnit


def test_report_totals_markdown():
def test_report_totals_markdown_one_language():
python_totals = LanguageTotals("Python")
python_totals.files = 1
python_totals.loc = 2
Expand All @@ -15,11 +15,36 @@ def test_report_totals_markdown():
python_totals.unmaintainable = 5
st = ScanTotals({"Python": python_totals})
result = _report_totals_markdown(st)

assert result == (
"| **Language** | **Files** | **Lines of Code** | **Functions** | ⚠ | ✖ |\n"
"| --- | ---: | ---: | ---: | ---: | ---: |\n"
"| Python | 1 | 2 | 3 | 4 | 5 |\n"
)


def test_report_totals_markdown_two_languages():
python_totals = LanguageTotals("Python")
python_totals.files = 1
python_totals.loc = 2
python_totals.functions = 3
python_totals.hard_to_maintain = 4
python_totals.unmaintainable = 5
ts_totals = LanguageTotals("TypeScript")
ts_totals.files = 1
ts_totals.loc = 2
ts_totals.functions = 3
ts_totals.hard_to_maintain = 4
ts_totals.unmaintainable = 5
st = ScanTotals({"Python": python_totals, "TypeScript": ts_totals})
result = _report_totals_markdown(st)

assert result == (
"| **Language** | **Files** | **Lines of Code** | **Functions** | ⚠ | ✖ |\n"
"| --- | ---: | ---: | ---: | ---: | ---: |\n"
"| Python | 1 | 2 | 3 | 4 | 5 |\n"
"| | **1** | **2** | **3** | **4** | **5** |"
"| TypeScript | 1 | 2 | 3 | 4 | 5 |\n"
"| **Totals** | **2** | **4** | **6** | **8** | **10** |"
)


Expand Down

0 comments on commit a3552b1

Please sign in to comment.