Skip to content

[dead-code] chore: remove dead functions — 8 functions removed#19750

Merged
pelikhan merged 2 commits intomainfrom
dead-code/remove-batch-20260305-183836-ac68bd914344f905
Mar 6, 2026
Merged

[dead-code] chore: remove dead functions — 8 functions removed#19750
pelikhan merged 2 commits intomainfrom
dead-code/remove-batch-20260305-183836-ac68bd914344f905

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 5, 2026

Dead Code Removal

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

Functions Removed

Function File
FormatAggregatedError pkg/workflow/error_aggregation.go
SplitJoinedErrors pkg/workflow/error_aggregation.go
ValidateExpressionSafetyPublic pkg/workflow/expression_validation.go
extractMapFromFrontmatter pkg/workflow/frontmatter_extraction_metadata.go
unmarshalFromMap pkg/workflow/frontmatter_types.go
GetCurrentGitTag pkg/workflow/git_helpers.go
RunGit pkg/workflow/git_helpers.go
ExecGHWithOutput pkg/workflow/github_cli.go

Tests Removed

  • TestFormatAggregatedError_NoError, TestFormatAggregatedError_SingleError, TestFormatAggregatedError_MultipleErrors — exclusively tested FormatAggregatedError
  • TestSplitJoinedErrors_NoError, TestSplitJoinedErrors_SingleError, TestSplitJoinedErrors_MultipleErrors — exclusively tested SplitJoinedErrors
  • TestImportInputsExpressionValidation — exclusively tested ValidateExpressionSafetyPublic
  • TestExtractMapFromFrontmatter — exclusively tested extractMapFromFrontmatter
  • TestUnmarshalFromMap — exclusively tested unmarshalFromMap
  • TestGetCurrentGitTag (entire git_helpers_test.go) — exclusively tested GetCurrentGitTag

Also updated TestFrontmatterConfigBackwardCompatibility to use ExtractMapField directly (the underlying function extractMapFromFrontmatter was just a thin wrapper around it).

Also removed now-unused imports: os from git_helpers.go, bytes and github.com/cli/go-gh/v2 from github_cli.go, strings from error_aggregation_test.go.

Verification

  • go build ./... — passes
  • go vet ./... — passes
  • go vet -tags=integration ./... — passes
  • make fmt — no changes needed
  • go test ./pkg/workflow/... — passes (27.8s)

Dead Function Count

  • Before this batch: ~63 functions
  • Removed in this PR: 8 functions
  • Remaining: ~55 functions

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

Generated by Dead Code Removal Agent ·

  • expires on Mar 8, 2026, 6:40 PM UTC

Removes unreachable Go functions identified by the deadcode static analyzer.

Functions removed:
- FormatAggregatedError (pkg/workflow/error_aggregation.go)
- SplitJoinedErrors (pkg/workflow/error_aggregation.go)
- ValidateExpressionSafetyPublic (pkg/workflow/expression_validation.go)
- extractMapFromFrontmatter (pkg/workflow/frontmatter_extraction_metadata.go)
- unmarshalFromMap (pkg/workflow/frontmatter_types.go)
- GetCurrentGitTag (pkg/workflow/git_helpers.go)
- RunGit (pkg/workflow/git_helpers.go)
- ExecGHWithOutput (pkg/workflow/github_cli.go)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 6, 2026 02:52
Copilot AI review requested due to automatic review settings March 6, 2026 02:52
@pelikhan pelikhan merged commit 84a6d59 into main Mar 6, 2026
49 checks passed
@pelikhan pelikhan deleted the dead-code/remove-batch-20260305-183836-ac68bd914344f905 branch March 6, 2026 02:52
Copy link
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/unreachable workflow helper functions (and their dedicated tests) as identified by static analysis, reducing maintenance surface area.

Changes:

  • Deleted unused helper functions across error aggregation, expression validation, frontmatter parsing/extraction, git helpers, and GitHub CLI helpers.
  • Removed/updated tests that only exercised the deleted functions and cleaned up now-unused imports.
  • Adjusted frontmatter backward-compatibility test to call ExtractMapField directly.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/workflow/tools_types_test.go Removes test that only covered the deleted extractMapFromFrontmatter wrapper.
pkg/workflow/imports_inputs_test.go Removes test that only covered the deleted ValidateExpressionSafetyPublic wrapper.
pkg/workflow/github_cli.go Drops ExecGHWithOutput and removes now-unused go-gh/v2/bytes imports.
pkg/workflow/git_helpers_test.go Removes tests that only covered deleted GetCurrentGitTag.
pkg/workflow/git_helpers.go Removes GetCurrentGitTag and RunGit plus now-unused os import.
pkg/workflow/frontmatter_types_test.go Removes tests that only covered deleted unmarshalFromMap; updates backward-compat test to use ExtractMapField.
pkg/workflow/frontmatter_types.go Removes unused unmarshalFromMap helper.
pkg/workflow/frontmatter_extraction_metadata.go Removes unused extractMapFromFrontmatter wrapper.
pkg/workflow/expression_validation.go Removes unused ValidateExpressionSafetyPublic wrapper.
pkg/workflow/error_aggregation_test.go Removes tests/imports that only covered deleted FormatAggregatedError / SplitJoinedErrors.
pkg/workflow/error_aggregation.go Removes unused FormatAggregatedError / SplitJoinedErrors helpers.
Comments suppressed due to low confidence (1)

pkg/workflow/github_cli.go:13

  • The go-gh/v2 dependency was removed from this file, but there are still log messages and doc comments later in the file that claim commands are executed "via go-gh/v2". This is now misleading since the implementation uses os/exec directly; please update the wording (and/or remove the token-based branching language) to match the current behavior.
import (
	"context"
	"os"
	"os/exec"

	"github.com/github/gh-aw/pkg/console"
	"github.com/github/gh-aw/pkg/logger"
	"github.com/github/gh-aw/pkg/tty"
)

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

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 136 to 140
sb.WriteString(err.Error())
}

return fmt.Errorf("%s", sb.String())
}
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The FormattedError doc comment still references FormatAggregatedError ("preferred over Error() + FormatAggregatedError"), but FormatAggregatedError was removed in this change. Please update the comment to avoid referring to a non-existent helper (e.g., just compare against Error()).

Copilot uses AI. Check for mistakes.
Comment on lines 37 to 41
package workflow

import (
"os"
"os/exec"
"strings"
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The file header comment ("# Key Functions") still lists GetCurrentGitTag() and RunGit() even though both were removed in this PR. Please update that section to reflect the remaining public API (e.g., RunGitCombined) so the module-level documentation stays accurate.

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