Skip to content

[dead-code] chore: remove dead functions — 4 functions removed#24094

Merged
pelikhan merged 1 commit intomainfrom
dead-code/remove-4-dead-functions-2026-04-02-3219e6d124205367
Apr 2, 2026
Merged

[dead-code] chore: remove dead functions — 4 functions removed#24094
pelikhan merged 1 commit intomainfrom
dead-code/remove-4-dead-functions-2026-04-02-3219e6d124205367

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 2, 2026

Dead Code Removal

This PR removes unreachable Go functions identified by the deadcode static analyzer.

Functions Removed

Function File
ListItem.Title pkg/console/console_types.go
ListItem.Description pkg/console/console_types.go
WithCustomOutput pkg/workflow/compiler_types.go
invalidGlobPattern.Error pkg/workflow/glob_validation.go

Tests Removed

  • TestListItem_Title — exclusively tested the deleted ListItem.Title() method
  • TestListItem_Description — exclusively tested the deleted ListItem.Description() method
  • Updated TestNewListItem to access struct fields directly instead of the deleted methods
  • Updated 3 callsites in forbidden_fields_import_test.go to assign compiler.customOutput directly (since WithCustomOutput was the only way to set this field and had no production callers)

Notes

  • ListItem.Title() / ListItem.Description(): internal code accesses the unexported title/description fields directly; the public methods were never called
  • WithCustomOutput: only used in integration tests, not in any production binary path; test callsites refactored to set compiler.customOutput directly
  • invalidGlobPattern.Error(): the struct is still used as a slice element type; only the Error() method was never called
  • Skipped: CompileToYAML, ParseWorkflowString, WithNoEmit, WithSkipValidation, WithWorkflowIdentifier — all referenced in cmd/gh-aw-wasm/main.go
  • Skipped: NewCompilerWithVersion, NormalizeExpressionForComparison — used in 100+ test callsites as constructor/utility helpers; removal would require large test refactoring
  • Skipped: generateFilteredToolsJSON cluster — deleting would cascade into removing dozens of test functions across multiple files

Verification

  • go build ./... — passes
  • go vet ./... — passes
  • go vet -tags=integration ./... — passes
  • make fmt — formatting applied
  • go test ./pkg/console/... ./pkg/workflow/... — passes

Dead Function Count

  • Before this batch: 15 functions reported
  • Removed in this PR: 4 functions
  • Remaining: ~11 functions (several skipped due to WASM use or wide test dependency)

Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/23899257567

Generated by Dead Code Removal Agent ·

  • expires on Apr 5, 2026, 12:11 PM UTC

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>
@pelikhan pelikhan marked this pull request as ready for review April 2, 2026 12:13
Copilot AI review requested due to automatic review settings April 2, 2026 12:13
@pelikhan pelikhan merged commit 192518e into main Apr 2, 2026
49 of 51 checks passed
@pelikhan pelikhan deleted the dead-code/remove-4-dead-functions-2026-04-02-3219e6d124205367 branch April 2, 2026 12:13
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

Removes dead/unreferenced Go functions identified by static analysis and updates impacted tests accordingly.

Changes:

  • Removed unused accessor methods on console.ListItem and adjusted pkg/console tests to assert fields directly.
  • Removed the unused WithCustomOutput compiler option and updated integration tests to set compiler.customOutput directly.
  • Removed the unused Error() method on invalidGlobPattern.

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 WithCustomOutput option is a breaking API change for any downstream code constructing a workflow.Compiler (external packages can’t set customOutput directly since the field is unexported). If this module is consumed as a library, consider keeping WithCustomOutput (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

  • ListItem is an exported type, and deleting the exported Title() / Description() accessors is a breaking change for any external consumers (the underlying fields are unexported, so callers outside package console can no longer read them). If pkg/console is 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
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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