Conversation
Remove unreachable function identified by the deadcode static analyzer. parseLabelsFromConfig was only called from test files and has been replaced by direct usage of ParseStringArrayFromConfig where needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Removes a dead/unreachable helper for parsing labels from workflow config maps, along with its dedicated unit test.
Changes:
- Deleted
parseLabelsFromConfigfrompkg/workflow/config_helpers.go. - Removed
TestParseLabelsFromConfigfrompkg/workflow/config_parsing_helpers_test.go.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/config_helpers.go | Removes the now-dead parseLabelsFromConfig wrapper function. |
| pkg/workflow/config_parsing_helpers_test.go | Removes the unit test that exclusively targeted the deleted helper. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
pkg/workflow/config_parsing_helpers_test.go:97
- Deleting
TestParseLabelsFromConfigremoves the only direct test coverage forParseStringArrayFromConfigbehavior around missing keys vs empty slices and mixed-type filtering (the deleted helper was just a thin wrapper). Consider keeping a table-driven test that exercisesParseStringArrayFromConfigdirectly (e.g., with key "labels") to preserve these regressions checks.
func TestParseTitlePrefixFromConfig(t *testing.T) {
tests := []struct {
name string
input map[string]any
expected string
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
123
to
127
| return nil | ||
| } | ||
|
|
||
| // parseLabelsFromConfig extracts and validates labels from a config map | ||
| // Returns a slice of label strings, or nil if labels is not present or invalid | ||
| func parseLabelsFromConfig(configMap map[string]any) []string { | ||
| return ParseStringArrayFromConfig(configMap, "labels", configHelpersLog) | ||
| } | ||
|
|
||
| // extractStringFromMap is a generic helper that extracts and validates a string value from a map | ||
| // Returns the string value, or empty string if not present or invalid |
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
parseLabelsFromConfigpkg/workflow/config_helpers.goTests Removed
TestParseLabelsFromConfiginpkg/workflow/config_parsing_helpers_test.go(exclusively tested the deleted function)Verification
go build ./...— passesgo vet ./...— passesgo vet -tags=integration ./...— passesmake fmt— no changes neededDead Function Count
CompileToYAML,ParseWorkflowString; 4 more WASM-referenced:WithSkipValidation,WithNoEmit,WithWorkflowIdentifier,WithVersion)Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/25164525401