Skip to content

[complexity] Code complexity findings (2026-03-19) #748

Closed as not planned
Closed as not planned

Description

@github-actions

Summary

  • Files analyzed: 5
  • Functions cataloged: 19
  • Complexity hotspots found: 2

Findings

1. Multi-responsibility main() in workflow log fetcher

File: scripts/fetch-workflow-logs.py (lines 105-173)
Function: main()

Evidence:

  • CLI validation and exit handling: lines 124-129
  • Workflow run query orchestration: lines 133-142
  • Empty-result control path: lines 144-146
  • Download loop + per-run formatting + aggregation: lines 151-165
  • Manifest serialization and output: lines 167-173

What is wrong: A single 69-line function combines parsing/validation, query orchestration, download execution, and result emission.

Why it matters (medium): This script is used for CI diagnostics. Concentrated branching and mixed concerns increase change risk when adding flags/output behavior, because unrelated concerns must be edited together.

Suggested fix: Keep main() as thin orchestration and extract behavior-preserving helpers, e.g. validate_args(args), fetch_runs(args), download_runs(runs, args), write_manifest(results, output_dir).

2. Nested pagination/filter control in list_workflow_runs()

File: scripts/fetch-workflow-logs.py (lines 52-78)
Function: list_workflow_runs(...)

Evidence:

  • Nested while + for with multiple branch filters: lines 59-77
  • Early return on since boundary: lines 69-71
  • Separate skip path for until: lines 72-73

What is wrong: Pagination iteration, date-window semantics, and conclusion filtering are intertwined in one nested control-flow block.

Why it matters (medium): Boundary behavior (since stop vs until skip) is easy to regress when touched; complexity here directly affects correctness of selected runs.

Suggested fix: Split into smaller units with explicit semantics, e.g. iter_workflow_run_pages(...) + run_matches_filters(run, since, until, conclusion) (or named predicates for boundary rules), keeping current behavior intact.

Suggested Actions

  • Refactor scripts/fetch-workflow-logs.py::main into single-purpose helpers while preserving CLI behavior/output.
  • Refactor scripts/fetch-workflow-logs.py::list_workflow_runs to separate pagination from filter predicates and make date-boundary semantics explicit.
  • Add/adjust script tests covering since/until boundaries and conclusion=any behavior to lock in current semantics during refactor.

Analysis Metadata

  • Serena tools used: activate_project, get_symbols_overview
  • Analysis date: 2026-03-19T13:34:23.835Z

What is this? | From workflow: Trigger Code Complexity Detector

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

  • expires on Mar 26, 2026, 1:38 PM UTC

Activity

  1. github-actions commented on Mar 26, 2026

    @github-actions
    ContributorAuthor

    This issue was automatically closed because it expired on 2026-03-26T13:38:46.017Z.

    Closed by Workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions