Conversation
Remove unreachable functions identified by the deadcode static analyzer: - ListItem.Title() and ListItem.Description() (pkg/console): unused public methods; internal code accesses struct fields directly - WithCustomOutput() (pkg/workflow): no production callers; update 3 test callsites to assign compiler.customOutput directly - invalidGlobPattern.Error() (pkg/workflow): method was never called Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Removes dead/unreferenced Go functions identified by static analysis and updates impacted tests accordingly.
Changes:
- Removed unused accessor methods on
console.ListItemand adjustedpkg/consoletests to assert fields directly. - Removed the unused
WithCustomOutputcompiler option and updated integration tests to setcompiler.customOutputdirectly. - Removed the unused
Error()method oninvalidGlobPattern.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/glob_validation.go | Deletes unused invalidGlobPattern.Error() method. |
| pkg/workflow/compiler_types.go | Deletes unused WithCustomOutput compiler option. |
| pkg/workflow/forbidden_fields_import_test.go | Refactors integration tests to set compiler.customOutput directly. |
| pkg/console/console_types.go | Deletes unused ListItem.Title() / ListItem.Description() methods. |
| pkg/console/list_test.go | Removes tests for deleted accessors; updates remaining test to check fields directly. |
Comments suppressed due to low confidence (2)
pkg/workflow/compiler_types.go:30
- Removing the exported
WithCustomOutputoption is a breaking API change for any downstream code constructing aworkflow.Compiler(external packages can’t setcustomOutputdirectly since the field is unexported). If this module is consumed as a library, consider keepingWithCustomOutput(possibly deprecated) or providing an alternative exported setter/option to preserve configurability.
// WithVerbose sets the verbose logging flag
func WithVerbose(verbose bool) CompilerOption {
return func(c *Compiler) { c.verbose = verbose }
}
// WithEngineOverride sets the AI engine override
func WithEngineOverride(engine string) CompilerOption {
return func(c *Compiler) { c.engineOverride = engine }
}
// WithSkipValidation configures whether to skip schema validation
func WithSkipValidation(skip bool) CompilerOption {
return func(c *Compiler) { c.skipValidation = skip }
}
// WithNoEmit configures whether to validate without generating lock files
pkg/console/console_types.go:66
ListItemis an exported type, and deleting the exportedTitle()/Description()accessors is a breaking change for any external consumers (the underlying fields are unexported, so callers outsidepackage consolecan no longer read them). Ifpkg/consoleis intended to be a public API, consider keeping these methods (maybe deprecated) or exporting the fields / providing alternative accessors.
// ListItem represents an item in an interactive list
type ListItem struct {
title string
description string
value string
}
// NewListItem creates a new list item with title, description, and value
func NewListItem(title, description, value string) ListItem {
return ListItem{
title: title,
description: description,
value: value,
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
30
to
36
| // invalidGlobPattern describes a single validation error within a glob pattern. | ||
| type invalidGlobPattern struct { | ||
| // Message is a human-readable description of the problem. | ||
| Message string | ||
| // Column is the 1-based column of the error within the pattern (0 when unknown). | ||
| Column int | ||
| } |
There was a problem hiding this comment.
The Column field doc says it is 1-based, but the validator stores p.Column - 1 (and uses 0 for unknown). This mismatch can confuse future consumers; update the comment to reflect the actual indexing (0-based) or adjust the stored value to be 1-based consistently.
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.
Dead Code Removal
This PR removes unreachable Go functions identified by the
deadcodestatic analyzer.Functions Removed
ListItem.Titlepkg/console/console_types.goListItem.Descriptionpkg/console/console_types.goWithCustomOutputpkg/workflow/compiler_types.goinvalidGlobPattern.Errorpkg/workflow/glob_validation.goTests Removed
TestListItem_Title— exclusively tested the deletedListItem.Title()methodTestListItem_Description— exclusively tested the deletedListItem.Description()methodTestNewListItemto access struct fields directly instead of the deleted methodsforbidden_fields_import_test.goto assigncompiler.customOutputdirectly (sinceWithCustomOutputwas the only way to set this field and had no production callers)Notes
ListItem.Title()/ListItem.Description(): internal code accesses the unexportedtitle/descriptionfields directly; the public methods were never calledWithCustomOutput: only used in integration tests, not in any production binary path; test callsites refactored to setcompiler.customOutputdirectlyinvalidGlobPattern.Error(): the struct is still used as a slice element type; only theError()method was never calledCompileToYAML,ParseWorkflowString,WithNoEmit,WithSkipValidation,WithWorkflowIdentifier— all referenced incmd/gh-aw-wasm/main.goNewCompilerWithVersion,NormalizeExpressionForComparison— used in 100+ test callsites as constructor/utility helpers; removal would require large test refactoringgenerateFilteredToolsJSONcluster — deleting would cascade into removing dozens of test functions across multiple filesVerification
go build ./...— passesgo vet ./...— passesgo vet -tags=integration ./...— passesmake fmt— formatting appliedgo test ./pkg/console/... ./pkg/workflow/...— passesDead Function Count
Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/23899257567