Conversation
…hWorkflowNames - Remove redundant `if len(jobConfig.Inputs) > 0` guard (ranging over nil map is safe) - Merge duplicate `case "string", ""` and `default:` switch branches into single `default:` - Move `additionalProperties: false` into the inputSchema map literal - Build tool return map at the point of return instead of mutating across the function - Remove obvious inline comments that repeat what the code already says - Inline the filter loop in extractDispatchWorkflowNames into the collection loop - Combine two-step map existence check + type assertion into a single comma-ok assertion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
@copilot recompile |
Contributor
Ran Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies two functions added or moved in recent PRs (#20080, #19965), applying Go best practices and project conventions for clarity.
Files Simplified
pkg/workflow/safe_outputs_config_generation.go— SimplifiedgenerateCustomJobToolDefinition(moved fromsafe_outputs_generation.goin IMP-003: MovegenerateCustomJobToolDefinitiontosafe_outputs_config_generation.go#20080)pkg/cli/remote_workflow.go— SimplifiedextractDispatchWorkflowNames(added in feat(add): fetch dispatch-workflow dependencies and resources when adding remote workflows #19965)Improvements Made
generateCustomJobToolDefinitionRemoved unnecessary guard —
if len(jobConfig.Inputs) > 0 { ... }is not needed; ranging over a nil/empty map is a safe no-op in Go. Removing it reduces nesting by one level.Merged duplicate switch cases —
case "string", "":anddefault:both setproperty["type"] = "string". Merged into a singledefault:with a clearer comment.Inlined
additionalProperties: falseinto the map literal where the schema is initialised, keeping all schema defaults together.Return the tool map at the point of return instead of building it at the top and mutating it through the function — clearer data flow.
Removed obvious inline comments that restate what the code already expresses (e.g.
// Build the tool definition,// Track required fields,// Add description if present), per project style: "Only comment code that needs a bit of clarification."extractDispatchWorkflowNamesCombined two-step existence + type assertion for
safe-outputsinto a single comma-ok type assertion (nil map key returnsnil, falsein comma-ok form).Inlined the filter into the collection loops — the separate post-collection filter loop is eliminated by adding
!strings.Contains(name, "$\{\{")to the guard inside eachcasebranch.Simplified nested existence + type assertion for
v["workflows"]into a direct comma-ok type assertion, removing a level of nesting.Testing
TestGenerateCustomJobToolDefinition*,TestExtractDispatchWorkflowNames_*)make test-unit)make build)Changes Based On
generateCustomJobToolDefinitiontosafe_outputs_config_generation.go#20080 — movedgenerateCustomJobToolDefinitiontosafe_outputs_config_generation.goextractDispatchWorkflowNamestoremote_workflow.goAutomated by Code Simplifier Agent — analysing code from the last 24 hours