Skip to content

[code-simplifier] refactor: remove orphaned comments and simplify patterns in include/compiler code#28409

Merged
pelikhan merged 1 commit intomainfrom
code-simplifier/remove-orphaned-comments-and-simplify-patterns-307a652decd9e056
Apr 25, 2026
Merged

[code-simplifier] refactor: remove orphaned comments and simplify patterns in include/compiler code#28409
pelikhan merged 1 commit intomainfrom
code-simplifier/remove-orphaned-comments-and-simplify-patterns-307a652decd9e056

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This PR simplifies recently modified code (PRs #28366 and #28387) to improve clarity and reduce noise.

Files Simplified

  • pkg/parser/include_processor.go — removed orphaned doc comment for the deleted ProcessIncludes function
  • pkg/parser/include_expander.go — removed orphaned doc comments for the renamed ProcessIncludesForEngines/ProcessIncludesForSafeOutputs functions
  • pkg/workflow/compiler_orchestrator_tools.go — two simplifications:
    • Combined tools string with strings.Join + a parts slice instead of nested if/else branches
    • Simplified the hasExplicitGitHubTool detection using direct map lookups (reading from a nil map is safe in Go and returns the zero value)

Improvements Made

Removed Orphaned Comments

Stale doc comments left over from function renaming in PR #28366 were removed. These comments described functions that no longer exist under the documented names, creating confusion.

Simplified String Join

// Before: 3-branch if/else
var allIncludedTools string
if importsResult.MergedTools != "" && includedTools != "" {
    allIncludedTools = importsResult.MergedTools + "\n" + includedTools
} else if importsResult.MergedTools != "" {
    allIncludedTools = importsResult.MergedTools
} else {
    allIncludedTools = includedTools
}

// After: build a parts slice and join
var toolsParts []string
if importsResult.MergedTools != "" {
    toolsParts = append(toolsParts, importsResult.MergedTools)
}
if includedTools != "" {
    toolsParts = append(toolsParts, includedTools)
}
allIncludedTools := strings.Join(toolsParts, "\n")

Simplified Nil-Safe Map Lookup

// Before: 4 levels of nesting with redundant nil guards
hasExplicitGitHubTool := false
if tools != nil {
    if _, exists := tools["github"]; exists {
        if topTools != nil {
            if _, existsInTop := topTools["github"]; existsInTop {
                hasExplicitGitHubTool = true
            }
        }
    }
}

// After: flat, nil-safe (Go map reads are safe on nil maps)
_, inMergedTools := tools["github"]
_, inTopTools := topTools["github"]
hasExplicitGitHubTool := inMergedTools && inTopTools

Changes Based On

Testing

  • ✅ All relevant tests pass (go test ./pkg/parser/... ./pkg/workflow/...)
  • ✅ Build succeeds (make build)
  • ✅ No functional changes — behavior is identical

Note

🔒 Integrity filter blocked 1 item

The following item was blocked because it doesn't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Code Simplifier · ● 1.5M ·

  • expires on Apr 26, 2026, 6:14 AM UTC

… joins

- Remove orphaned doc comments in include_expander.go (ProcessIncludesForEngines/SafeOutputs)
  and include_processor.go (ProcessIncludes) left over from function renaming
- Simplify allIncludedTools concatenation using strings.Join with a parts slice
- Simplify hasExplicitGitHubTool using direct map lookups (nil-safe in Go)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes stale/orphaned doc comments left behind by earlier refactors and simplifies two small code patterns in the workflow compiler to reduce branching and nesting.

Changes:

  • Removed orphaned doc comments in the include processor/expander code.
  • Simplified tool-string concatenation by collecting non-empty parts and using strings.Join.
  • Simplified hasExplicitGitHubTool detection using nil-safe Go map reads and a flat boolean expression.
Show a summary per file
File Description
pkg/workflow/compiler_orchestrator_tools.go Simplifies tool string assembly and explicit GitHub tool detection logic.
pkg/parser/include_processor.go Removes stale doc comment referencing a deleted/renamed function.
pkg/parser/include_expander.go Removes stale doc comments referencing old exported function names.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@pelikhan pelikhan merged commit e7fb958 into main Apr 25, 2026
99 checks passed
@pelikhan pelikhan deleted the code-simplifier/remove-orphaned-comments-and-simplify-patterns-307a652decd9e056 branch April 25, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants