From 1c0ada2bafb4242d6d740b85c3593ca60ba509e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BA=D0=BE=D1=81=20=D0=90=D1=80=D1=82=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Fri, 17 Jul 2026 13:41:57 +0700 Subject: [PATCH] refactor: remove dead code in cli and xlsx cli.py: drop redundant 'if issue_hours is None' branch before 'if not issue_hours'. The branch is not formally dead (client returns None when no time entries found, client.py), but it is a semantic duplicate: both branches print the same message and return 0, and None is falsy, so a single 'not issue_hours' check covers None, empty list and keeps behavior identical. test_cli_returns_zero_on_no_entries stays green unchanged. xlsx.py: drop unreachable 'if ws is None' fallback. Workbook() (write_only=False) always creates one worksheet in __init__, so wb.active is never None; set the title directly. Closes #63 --- redmine_reporter/cli.py | 4 ---- redmine_reporter/formatters/xlsx.py | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/redmine_reporter/cli.py b/redmine_reporter/cli.py index e3ee63b..6300fcc 100644 --- a/redmine_reporter/cli.py +++ b/redmine_reporter/cli.py @@ -422,10 +422,6 @@ def main(argv: Optional[List[str]] = None) -> int: logging.exception("Unexpected error") return 1 - if issue_hours is None: - print("ℹ️ No time entries found in the given period.", file=sys.stderr) - return 0 - if not issue_hours: print("ℹ️ No time entries found in the given period.", file=sys.stderr) return 0 diff --git a/redmine_reporter/formatters/xlsx.py b/redmine_reporter/formatters/xlsx.py index ed3a7ae..16c4dd6 100644 --- a/redmine_reporter/formatters/xlsx.py +++ b/redmine_reporter/formatters/xlsx.py @@ -39,10 +39,7 @@ class XLSXFormatter(Formatter): def format(self, rows: List[ReportRow]) -> Workbook: wb = Workbook() ws = wb.active - if ws is None: - ws = wb.create_sheet("Report") - else: - ws.title = "Report" + ws.title = "Report" headers = [ "Project",