From 911b33c8261586b7355f8c3bf3ac2bac18d1494f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 12:17:36 +0000 Subject: [PATCH] chore: remove dead function parseLabelsFromConfig 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> --- pkg/workflow/config_helpers.go | 6 -- pkg/workflow/config_parsing_helpers_test.go | 86 --------------------- 2 files changed, 92 deletions(-) diff --git a/pkg/workflow/config_helpers.go b/pkg/workflow/config_helpers.go index 6afb3d7adde..acf237ea094 100644 --- a/pkg/workflow/config_helpers.go +++ b/pkg/workflow/config_helpers.go @@ -123,12 +123,6 @@ func ParseStringArrayOrExprFromConfig(m map[string]any, key string, log *logger. 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 // If log is provided, it will log the extracted value for debugging diff --git a/pkg/workflow/config_parsing_helpers_test.go b/pkg/workflow/config_parsing_helpers_test.go index 0a9c4da1dc5..c44dab743ae 100644 --- a/pkg/workflow/config_parsing_helpers_test.go +++ b/pkg/workflow/config_parsing_helpers_test.go @@ -90,92 +90,6 @@ func TestExtractStringFromMap(t *testing.T) { } } -func TestParseLabelsFromConfig(t *testing.T) { - tests := []struct { - name string - input map[string]any - expected []string - }{ - { - name: "valid labels array", - input: map[string]any{ - "labels": []any{"bug", "enhancement", "documentation"}, - }, - expected: []string{"bug", "enhancement", "documentation"}, - }, - { - name: "empty labels array", - input: map[string]any{ - "labels": []any{}, - }, - expected: []string{}, - }, - { - name: "missing labels field", - input: map[string]any{}, - expected: nil, - }, - { - name: "labels with mixed types (filters non-strings)", - input: map[string]any{ - "labels": []any{"bug", 123, "enhancement", true, "documentation"}, - }, - expected: []string{"bug", "enhancement", "documentation"}, - }, - { - name: "labels as []string", - input: map[string]any{ - "labels": []string{"bug", "enhancement"}, - }, - expected: []string{"bug", "enhancement"}, - }, - { - name: "labels as non-array type", - input: map[string]any{ - "labels": "not-an-array", - }, - expected: nil, - }, - { - name: "labels with only non-string types", - input: map[string]any{ - "labels": []any{123, true, 456}, - }, - expected: []string{}, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result := parseLabelsFromConfig(tt.input) - - // Handle nil vs empty slice comparison - if tt.expected == nil { - if result != nil { - t.Errorf("expected nil, got %v", result) - } - return - } - - if result == nil { - t.Errorf("expected %v, got nil", tt.expected) - return - } - - if len(result) != len(tt.expected) { - t.Errorf("expected length %d, got %d", len(tt.expected), len(result)) - return - } - - for i, expected := range tt.expected { - if result[i] != expected { - t.Errorf("at index %d: expected %q, got %q", i, expected, result[i]) - } - } - }) - } -} - func TestParseTitlePrefixFromConfig(t *testing.T) { tests := []struct { name string