Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 14, 2026

pkg/cli/logs_parsing.go exceeded the 300-line complexity limit at 616 lines, mixing core parsing, engine-specific formats, firewall analysis, and JavaScript execution.

Changes

Split into 4 focused modules:

  • logs_parsing_core.go (240 lines) - aw_info.json parsing, artifact discovery (parseAwInfo, extractEngineFromAwInfo, findAgentLogFile, findAgentOutputFile)
  • logs_parsing_engines.go (57 lines) - Engine-specific log parsing and fallback (parseLogFileWithEngine)
  • logs_parsing_firewall.go (231 lines) - Firewall log analysis and markdown generation (parseFirewallLogs)
  • logs_parsing_javascript.go (152 lines) - JavaScript parser execution with mocked Actions environment (parseAgentLog)

Technical Notes

Renamed from logs_parsing_js.go to logs_parsing_javascript.go - Go's build system ignores files with _js suffix.

All functions remain package-private; no behavioral changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Refactor logs_parsing.go to meet 300-line complexity limit</issue_title>
<issue_description>## Description

The file pkg/cli/logs_parsing.go contains 616 lines of code, significantly exceeding the 300-line hard limit specified in the validation complexity guidelines (AGENTS.md). This file mixes multiple concerns including log parsing, engine-specific formats, firewall analysis, and JavaScript execution.

Suggested Changes

Split logs_parsing.go into focused modules following the validation refactoring patterns:

  1. logs_parsing_core.go - Core parsing logic (parseAwInfo, findAgentLogFile)
  2. logs_parsing_engines.go - Engine-specific parsing (parseClaudeLog, parseCopilotLog, etc.)
  3. logs_parsing_firewall.go - Firewall log analysis (parseFirewallLog, generateFirewallSummary)
  4. logs_parsing_js.go - JavaScript parser execution (runJavaScriptParser)

Files Affected

  • pkg/cli/logs_parsing.go (split into 4 files)
  • pkg/cli/logs_parsing_test.go (may need corresponding split)

Success Criteria

  • Each new file is under 300 lines
  • Functions are logically grouped by domain
  • All existing tests pass without modification
  • Documentation headers clearly define each file's responsibilities
  • No functional changes (pure refactoring)

Source

Code analysis revealed violation of validation complexity guidelines in AGENTS.md:

  • Current size: 616 lines
  • Hard limit: 300 lines
  • Target size: 100-200 lines per file

Priority

Medium - Improves maintainability and follows established architecture patterns but not blocking

AI generated by Discussion Task Miner - Code Quality Improvement Agent

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 14, 2026 16:01
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor logs_parsing.go to reduce complexity Refactor logs_parsing.go into focused modules under 300-line limit Jan 14, 2026
Copilot AI requested a review from mnkiefer January 14, 2026 16:19
@pelikhan pelikhan marked this pull request as ready for review January 15, 2026 00:20
@pelikhan pelikhan merged commit 48fb2b5 into main Jan 15, 2026
142 checks passed
@pelikhan pelikhan deleted the copilot/refactor-logs-parsing-module branch January 15, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Refactor logs_parsing.go to meet 300-line complexity limit

3 participants