Skip to content

[complexity] Code complexity findings (2026-03-26) #812

Description

@github-actions

Summary

  • Files analyzed: 5
  • Functions cataloged: 39
  • Complexity hotspots found: 1

Findings

1. Redundant output path handling causes branch-specific behavior and avoidable complexity

File: scripts/extract-log-errors.py (lines 163-180 and 199-203)
Function(s): emit_output(...), emit_empty_output(...), main()

Complexity: Redundant conditional flow with two output implementations for the same responsibility.

Evidence:

  • emit_output writes JSON and, when --output is provided, prints the written path (L163-L171).
  • emit_empty_output handles only the empty-result branch and writes a different payload path without printing the path (L174-L180).
  • main special-cases not log_files to call emit_empty_output and exit (L199-L203), while non-empty flows always route through emit_output (L219).

What is wrong:
The script maintains two separate branches for output serialization and side-effects. This duplicates logic and introduces divergent behavior based solely on whether files were found.

Why it matters (medium):
The divergence makes behavior harder to reason about and maintain, and creates inconsistent CLI contracts for downstream automation when using --output (path is printed in one branch but not the other).

Suggested simplification:
Collapse to a single output path:

  • Always build summary (including empty case) in main.
  • Remove emit_empty_output.
  • Route both empty and non-empty flows through emit_output(summary, args.output) so output behavior is consistent.

Suggested Actions

  • Replace the not log_files special-case output path with unified summary construction.
  • Delete emit_empty_output and use emit_output for all result shapes.
  • Add/adjust tests for --output in both empty and non-empty scenarios to lock in consistent behavior.

Analysis Metadata

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

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

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

  • expires on Apr 2, 2026, 1:38 PM UTC

Activity

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