From 4f3584b346bda45052a99f1e54e17eac750a7ac8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 03:52:48 +0000 Subject: [PATCH 1/2] Initial plan From 23ca321aac32e4343a23e644ea5e24c81a7e6ec7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 04:04:49 +0000 Subject: [PATCH 2/2] Replace len(string)==0 checks with empty string comparisons Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../codemod_checkout_persist_credentials_false.go | 14 +++++++------- pkg/cli/codemod_discussion_flag.go | 2 +- pkg/cli/codemod_engine_env_secrets.go | 4 ++-- pkg/cli/codemod_engine_steps.go | 8 ++++---- pkg/cli/codemod_github_app.go | 2 +- pkg/cli/codemod_github_app_client_id.go | 2 +- pkg/cli/codemod_github_repos.go | 2 +- pkg/cli/codemod_mcp_network.go | 6 +++--- pkg/cli/codemod_mount_as_clis.go | 2 +- pkg/cli/codemod_playwright_domains.go | 2 +- pkg/cli/codemod_steps_run_secrets_env.go | 8 ++++---- pkg/cli/codemod_user_rate_limit.go | 2 +- pkg/cli/mcp_tools_readonly.go | 2 +- pkg/cli/project_command.go | 2 +- pkg/cli/remove_command.go | 4 ++-- pkg/cli/run_push.go | 2 +- pkg/cli/run_workflow_execution.go | 2 +- pkg/cli/trial_helpers.go | 2 +- pkg/cli/trial_repository.go | 2 +- pkg/cli/validators.go | 2 +- pkg/cli/yaml_frontmatter_utils.go | 8 ++++---- pkg/console/input.go | 2 +- pkg/gitutil/gitutil.go | 2 +- pkg/parser/github_urls.go | 2 +- pkg/parser/import_directive.go | 2 +- pkg/parser/remote_fetch.go | 2 +- pkg/stringutil/fuzzy_match.go | 4 ++-- pkg/workflow/cache.go | 2 +- pkg/workflow/codex_logs.go | 2 +- pkg/workflow/compiler_safe_outputs_job.go | 2 +- pkg/workflow/engine_helpers.go | 2 +- pkg/workflow/redact_secrets.go | 2 +- pkg/workflow/runtime_validation.go | 2 +- pkg/workflow/template_injection_validation.go | 2 +- pkg/workflow/xml_comments.go | 2 +- 35 files changed, 55 insertions(+), 55 deletions(-) diff --git a/pkg/cli/codemod_checkout_persist_credentials_false.go b/pkg/cli/codemod_checkout_persist_credentials_false.go index ac31091fd86..44e7cfe14ca 100644 --- a/pkg/cli/codemod_checkout_persist_credentials_false.go +++ b/pkg/cli/codemod_checkout_persist_credentials_false.go @@ -95,7 +95,7 @@ func transformSectionCheckoutPersistCredentials(lines []string, sectionName stri sectionEnd := len(lines) - 1 for i := sectionStart + 1; i < len(lines); i++ { trimmed := strings.TrimSpace(lines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } if len(getIndentation(lines[i])) <= len(sectionIndent) { @@ -135,7 +135,7 @@ func transformAgentJobCheckoutPersistCredentials(lines []string, sectionNames [] jobsEnd := len(lines) - 1 for i := jobsStart + 1; i < len(lines); i++ { trimmed := strings.TrimSpace(lines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } if len(getIndentation(lines[i])) <= len(jobsIndent) { @@ -168,7 +168,7 @@ func transformAgentJobCheckoutPersistCredentials(lines []string, sectionNames [] agentEnd := len(jobsLines) - 1 for i := agentStart + 1; i < len(jobsLines); i++ { trimmed := strings.TrimSpace(jobsLines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } if len(getIndentation(jobsLines[i])) <= len(agentIndent) { @@ -224,7 +224,7 @@ func transformNestedSectionCheckoutPersistCredentials(lines []string, sectionNam sectionEnd := len(lines) - 1 for i := sectionStart + 1; i < len(lines); i++ { trimmed := strings.TrimSpace(lines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } if len(getIndentation(lines[i])) <= len(sectionIndent) { @@ -252,7 +252,7 @@ func transformNestedSectionCheckoutPersistCredentials(lines []string, sectionNam func findDirectChildIndentLen(lines []string, parentStart int, parentIndentLen int) (int, bool) { for i := parentStart + 1; i < len(lines); i++ { trimmed := strings.TrimSpace(lines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } indentLen := len(getIndentation(lines[i])) @@ -280,7 +280,7 @@ func transformCheckoutWithinSection(sectionLines []string, sectionIndent string) stepEnd := len(sectionLines) - 1 for j := i + 1; j < len(sectionLines); j++ { t := strings.TrimSpace(sectionLines[j]) - if len(t) == 0 { + if t == "" { continue } jIndent := getIndentation(sectionLines[j]) @@ -343,7 +343,7 @@ func ensureStepCheckoutPersistCredentials(stepLines []string, stepIndent string) withKeyIndentLen := currentWithKeyIndentLen for j := i + 1; j < len(stepLines); j++ { t := strings.TrimSpace(stepLines[j]) - if len(t) == 0 { + if t == "" { withEnd = j continue } diff --git a/pkg/cli/codemod_discussion_flag.go b/pkg/cli/codemod_discussion_flag.go index 8543b12192d..fa31b1b49d0 100644 --- a/pkg/cli/codemod_discussion_flag.go +++ b/pkg/cli/codemod_discussion_flag.go @@ -98,7 +98,7 @@ func getDiscussionFlagRemovalCodemod() Codemod { // Skip any nested content under the discussion field (shouldn't be any, but for completeness) if inDiscussionField { // Empty lines within the field block should be removed - if len(trimmedLine) == 0 { + if trimmedLine == "" { continue } diff --git a/pkg/cli/codemod_engine_env_secrets.go b/pkg/cli/codemod_engine_env_secrets.go index f67a01cac75..effdc7fa833 100644 --- a/pkg/cli/codemod_engine_env_secrets.go +++ b/pkg/cli/codemod_engine_env_secrets.go @@ -183,7 +183,7 @@ func removeUnsafeEngineEnvKeys(lines []string, unsafeKeys map[string]bool) ([]st } if inEnv && removingKey { - if len(trimmed) == 0 { + if trimmed == "" { continue } if strings.HasPrefix(trimmed, "#") && len(indent) > len(removingKeyIndent) { @@ -222,7 +222,7 @@ func removeEmptyEngineEnvBlock(lines []string) []string { j := i + 1 for ; j < len(lines); j++ { t := strings.TrimSpace(lines[j]) - if len(t) == 0 { + if t == "" { continue } if len(getIndentation(lines[j])) <= len(envIndent) { diff --git a/pkg/cli/codemod_engine_steps.go b/pkg/cli/codemod_engine_steps.go index f0ccffc92e9..72b145c815a 100644 --- a/pkg/cli/codemod_engine_steps.go +++ b/pkg/cli/codemod_engine_steps.go @@ -85,7 +85,7 @@ func getEngineStepsToTopLevelCodemod() Codemod { line := frontmatterLines[j] trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { continue } @@ -128,7 +128,7 @@ func getEngineStepsToTopLevelCodemod() Codemod { for j := i + 1; j < len(frontmatterLines); j++ { l := frontmatterLines[j] t := strings.TrimSpace(l) - if len(t) == 0 { + if t == "" { continue } if len(getIndentation(l)) > len(topStepsIndent) { @@ -171,7 +171,7 @@ func getEngineStepsToTopLevelCodemod() Codemod { continue } if inEngine { - if len(trimmed) == 0 { + if trimmed == "" { continue } lineIndentLen := len(getIndentation(line)) @@ -205,7 +205,7 @@ func getEngineStepsToTopLevelCodemod() Codemod { continue } if inEngine { - if len(trimmed) == 0 { + if trimmed == "" { continue } if len(getIndentation(line)) <= engineIndentLen { diff --git a/pkg/cli/codemod_github_app.go b/pkg/cli/codemod_github_app.go index 2214a33d548..08b689a3ee4 100644 --- a/pkg/cli/codemod_github_app.go +++ b/pkg/cli/codemod_github_app.go @@ -91,7 +91,7 @@ func renameAppToGitHubApp(lines []string) ([]string, bool) { trimmed := strings.TrimSpace(line) // Skip empty lines without resetting state - if len(trimmed) == 0 { + if trimmed == "" { result = append(result, line) continue } diff --git a/pkg/cli/codemod_github_app_client_id.go b/pkg/cli/codemod_github_app_client_id.go index 52c5c0d7f07..5f27b2edbfc 100644 --- a/pkg/cli/codemod_github_app_client_id.go +++ b/pkg/cli/codemod_github_app_client_id.go @@ -65,7 +65,7 @@ func renameGitHubAppIDToClientID(lines []string) ([]string, bool) { for i, line := range lines { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { result = append(result, line) continue } diff --git a/pkg/cli/codemod_github_repos.go b/pkg/cli/codemod_github_repos.go index f4f378fa3cc..6018ad20bae 100644 --- a/pkg/cli/codemod_github_repos.go +++ b/pkg/cli/codemod_github_repos.go @@ -69,7 +69,7 @@ func renameGitHubReposToAllowedRepos(lines []string) ([]string, bool) { trimmed := strings.TrimSpace(line) // Skip empty lines without resetting state - if len(trimmed) == 0 { + if trimmed == "" { result = append(result, line) continue } diff --git a/pkg/cli/codemod_mcp_network.go b/pkg/cli/codemod_mcp_network.go index 390822af485..4feff024b50 100644 --- a/pkg/cli/codemod_mcp_network.go +++ b/pkg/cli/codemod_mcp_network.go @@ -204,7 +204,7 @@ func removeFieldFromMCPServer(lines []string, serverName string, fieldName strin // Skip nested properties under the field if inFieldBlock { // Empty lines within the field block should be removed - if len(trimmedLine) == 0 { + if trimmedLine == "" { continue } @@ -252,7 +252,7 @@ func addTopLevelNetwork(lines []string, domains []string) []string { for j := i + 1; j < len(lines); j++ { nextLine := lines[j] nextTrimmed := strings.TrimSpace(nextLine) - if len(nextTrimmed) == 0 { + if nextTrimmed == "" { continue } if hasExitedBlock(nextLine, onIndent) { @@ -328,7 +328,7 @@ func updateNetworkAllowed(lines []string, domains []string) []string { currentIndent := getIndentation(line) // Empty lines - skip - if len(trimmedLine) == 0 { + if trimmedLine == "" { continue } diff --git a/pkg/cli/codemod_mount_as_clis.go b/pkg/cli/codemod_mount_as_clis.go index 2aeab41cc37..afb54954084 100644 --- a/pkg/cli/codemod_mount_as_clis.go +++ b/pkg/cli/codemod_mount_as_clis.go @@ -90,7 +90,7 @@ func renameMountAsCLIsToCLIProxy(lines []string) ([]string, bool) { for i, line := range lines { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { result = append(result, line) continue } diff --git a/pkg/cli/codemod_playwright_domains.go b/pkg/cli/codemod_playwright_domains.go index f50b5bd3c7d..aeca0e99218 100644 --- a/pkg/cli/codemod_playwright_domains.go +++ b/pkg/cli/codemod_playwright_domains.go @@ -160,7 +160,7 @@ func removeFieldFromPlaywright(lines []string, fieldName string) ([]string, bool // Skip nested properties under the removed field if inFieldBlock { - if len(trimmed) == 0 { + if trimmed == "" { continue } currentIndent := getIndentation(line) diff --git a/pkg/cli/codemod_steps_run_secrets_env.go b/pkg/cli/codemod_steps_run_secrets_env.go index 762693bac1a..1d9a5adc036 100644 --- a/pkg/cli/codemod_steps_run_secrets_env.go +++ b/pkg/cli/codemod_steps_run_secrets_env.go @@ -86,7 +86,7 @@ func transformSectionStepsRunSecrets(lines []string, sectionName string) ([]stri sectionEnd := len(lines) - 1 for i := sectionStart + 1; i < len(lines); i++ { trimmed := strings.TrimSpace(lines[i]) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { continue } if len(getIndentation(lines[i])) <= len(sectionIndent) { @@ -125,7 +125,7 @@ func transformStepsWithinSection(sectionLines []string, sectionIndent string) ([ stepEnd := len(sectionLines) - 1 for j := i + 1; j < len(sectionLines); j++ { t := strings.TrimSpace(sectionLines[j]) - if len(t) == 0 { + if t == "" { continue } jIndent := getIndentation(sectionLines[j]) @@ -199,7 +199,7 @@ func rewriteStepRunSecretsToEnv(stepLines []string, stepIndent string) ([]string envEnd = i for j := i + 1; j < len(stepLines); j++ { t := strings.TrimSpace(stepLines[j]) - if len(t) == 0 { + if t == "" { envEnd = j continue } @@ -225,7 +225,7 @@ func rewriteStepRunSecretsToEnv(stepLines []string, stepIndent string) ([]string if runValue == "|" || runValue == "|-" || runValue == ">" || runValue == ">-" { for j := i + 1; j < len(stepLines); j++ { t := strings.TrimSpace(stepLines[j]) - if len(t) == 0 { + if t == "" { continue } if effectiveStepLineIndentLen(t, getIndentation(stepLines[j]), stepIndent) <= runKeyIndentLen { diff --git a/pkg/cli/codemod_user_rate_limit.go b/pkg/cli/codemod_user_rate_limit.go index 9f0f8152570..59321254de5 100644 --- a/pkg/cli/codemod_user_rate_limit.go +++ b/pkg/cli/codemod_user_rate_limit.go @@ -46,7 +46,7 @@ func renameRateLimitToUserRateLimit(lines []string) ([]string, bool) { for i, line := range lines { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { result = append(result, line) continue } diff --git a/pkg/cli/mcp_tools_readonly.go b/pkg/cli/mcp_tools_readonly.go index 8bf3872dc52..62ac96b25c6 100644 --- a/pkg/cli/mcp_tools_readonly.go +++ b/pkg/cli/mcp_tools_readonly.go @@ -234,7 +234,7 @@ Returns JSON array with validation results for each workflow: if err != nil { mcpLog.Printf("Compile command exited with error: %v (output length: %d)", err, len(outputStr)) // If we have no output, this is a real execution failure - if len(outputStr) == 0 { + if outputStr == "" { // Try to get stderr for error details var stderr string var exitErr *exec.ExitError diff --git a/pkg/cli/project_command.go b/pkg/cli/project_command.go index 975bd8bf6ad..6cd6224e672 100644 --- a/pkg/cli/project_command.go +++ b/pkg/cli/project_command.go @@ -255,7 +255,7 @@ func validateOwner(ctx context.Context, ownerType, owner string, verbose bool) e // capitalizeFirst capitalizes the first letter of a string func capitalizeFirst(s string) string { - if len(s) == 0 { + if s == "" { return s } return strings.ToUpper(s[:1]) + s[1:] diff --git a/pkg/cli/remove_command.go b/pkg/cli/remove_command.go index d1f7803dd1c..7868bb4e966 100644 --- a/pkg/cli/remove_command.go +++ b/pkg/cli/remove_command.go @@ -419,7 +419,7 @@ func findIncludesInContent(content string) ([]string, error) { // Section references (e.g. file.md#Section) are stripped from the returned path. func parseIncludePath(line string) string { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { return "" } @@ -471,7 +471,7 @@ func parseIncludePath(line string) string { rest = rest[1:] } // Require at least one whitespace character after the directive keyword - if len(rest) == 0 || (rest[0] != ' ' && rest[0] != '\t') { + if rest == "" || (rest[0] != ' ' && rest[0] != '\t') { return "" } path := strings.TrimSpace(rest) diff --git a/pkg/cli/run_push.go b/pkg/cli/run_push.go index 9a986316635..99a1af5cd66 100644 --- a/pkg/cli/run_push.go +++ b/pkg/cli/run_push.go @@ -406,7 +406,7 @@ func pushWorkflowFiles(workflowName string, files []string, refOverride string, runPushLog.Printf("Git status output: %s", string(statusOutput)) // Check if there are no staged changes (nothing to commit) - if len(strings.TrimSpace(string(statusOutput))) == 0 { + if strings.TrimSpace(string(statusOutput)) == "" { runPushLog.Printf("No staged changes detected") if verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No changes to commit")) diff --git a/pkg/cli/run_workflow_execution.go b/pkg/cli/run_workflow_execution.go index 861149d46ee..90806ebaf04 100644 --- a/pkg/cli/run_workflow_execution.go +++ b/pkg/cli/run_workflow_execution.go @@ -78,7 +78,7 @@ func RunWorkflowOnGitHub(ctx context.Context, workflowIdOrName string, opts RunO } // Check that key (before '=') is not empty parts := strings.SplitN(input, "=", 2) - if len(parts[0]) == 0 { + if parts[0] == "" { return fmt.Errorf("invalid input format '%s': key cannot be empty", input) } } diff --git a/pkg/cli/trial_helpers.go b/pkg/cli/trial_helpers.go index 9b0b80015f3..cf8baa62f73 100644 --- a/pkg/cli/trial_helpers.go +++ b/pkg/cli/trial_helpers.go @@ -349,7 +349,7 @@ func copyTrialResultsToHostRepo(tempDir, dateTimeID string, workflowNames []stri } // If no changes, skip commit and push - if len(strings.TrimSpace(string(statusOutput))) == 0 { + if strings.TrimSpace(string(statusOutput)) == "" { trialLog.Print("No new trial results to commit, skipping push") if verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No new trial results to commit")) diff --git a/pkg/cli/trial_repository.go b/pkg/cli/trial_repository.go index a111361c57e..f7d22aae70a 100644 --- a/pkg/cli/trial_repository.go +++ b/pkg/cli/trial_repository.go @@ -494,7 +494,7 @@ func commitAndPushWorkflow(tempDir, workflowName string, verbose bool) error { } // If no changes, skip commit and push - if len(strings.TrimSpace(string(statusOutput))) == 0 { + if strings.TrimSpace(string(statusOutput)) == "" { if verbose { fmt.Fprintln(os.Stderr, console.FormatInfoMessage("No changes detected, skipping commit")) } diff --git a/pkg/cli/validators.go b/pkg/cli/validators.go index 52f11c4fb2d..ef12ae5ebb2 100644 --- a/pkg/cli/validators.go +++ b/pkg/cli/validators.go @@ -35,7 +35,7 @@ func ValidateWorkflowName(s string) error { func ValidateWorkflowIntent(s string) error { validatorsLog.Printf("Validating workflow intent: length=%d", len(s)) trimmed := strings.TrimSpace(s) - if len(trimmed) == 0 { + if trimmed == "" { validatorsLog.Print("Workflow intent validation failed: empty content") return errors.New("workflow instructions cannot be empty") } diff --git a/pkg/cli/yaml_frontmatter_utils.go b/pkg/cli/yaml_frontmatter_utils.go index 06cffd70002..30ea989ed0f 100644 --- a/pkg/cli/yaml_frontmatter_utils.go +++ b/pkg/cli/yaml_frontmatter_utils.go @@ -52,11 +52,11 @@ func getIndentation(line string) string { // isTopLevelKey checks if a line is a top-level YAML key (no indentation, contains colon, not a comment) func isTopLevelKey(line string) bool { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") { + if trimmed == "" || strings.HasPrefix(trimmed, "#") { return false } indent := getIndentation(line) - return len(indent) == 0 && strings.Contains(line, ":") + return indent == "" && strings.Contains(line, ":") } // isNestedUnder checks if currentLine is nested under (has more indentation than) parentIndent @@ -68,7 +68,7 @@ func isNestedUnder(currentLine, parentIndent string) bool { // hasExitedBlock checks if we've left a YAML block (found a line with same or less indentation that's a key) func hasExitedBlock(line, blockIndent string) bool { trimmed := strings.TrimSpace(line) - if len(trimmed) == 0 { + if trimmed == "" { return false } @@ -206,7 +206,7 @@ func removeFieldFromBlock(lines []string, fieldName string, parentBlock string) // Skip nested properties under the field (lines with greater indentation) if inFieldBlock { // Empty lines within the field block should be removed - if len(trimmedLine) == 0 { + if trimmedLine == "" { continue } diff --git a/pkg/console/input.go b/pkg/console/input.go index b2116582fcf..bf5727b94f5 100644 --- a/pkg/console/input.go +++ b/pkg/console/input.go @@ -28,7 +28,7 @@ func PromptSecretInput(title, description string) (string, error) { Description(description). EchoMode(huh.EchoModePassword). // Masks input for security Validate(func(s string) error { - if len(s) == 0 { + if s == "" { return errors.New("value cannot be empty") } return nil diff --git a/pkg/gitutil/gitutil.go b/pkg/gitutil/gitutil.go index 00b80b20014..ccc8bf70385 100644 --- a/pkg/gitutil/gitutil.go +++ b/pkg/gitutil/gitutil.go @@ -49,7 +49,7 @@ func IsAuthError(errMsg string) bool { // IsHexString checks if a string contains only hexadecimal characters. // This is used to validate Git commit SHAs and other hexadecimal identifiers. func IsHexString(s string) bool { - if len(s) == 0 { + if s == "" { return false } for _, c := range s { diff --git a/pkg/parser/github_urls.go b/pkg/parser/github_urls.go index 2fee9b1a397..bdf8d077619 100644 --- a/pkg/parser/github_urls.go +++ b/pkg/parser/github_urls.go @@ -360,7 +360,7 @@ const ( func isValidGitHubNameWithMaxLength(s string, maxLength int) bool { // GitHub identifiers can contain alphanumeric characters, hyphens, and underscores. // They cannot start or end with a hyphen. - if len(s) == 0 || len(s) > maxLength { + if s == "" || len(s) > maxLength { return false } if s[0] == '-' || s[len(s)-1] == '-' { diff --git a/pkg/parser/import_directive.go b/pkg/parser/import_directive.go index 349ff51ae1e..408eb251d95 100644 --- a/pkg/parser/import_directive.go +++ b/pkg/parser/import_directive.go @@ -29,7 +29,7 @@ func ParseImportDirective(line string) *ImportDirectiveMatch { trimmedLine := strings.TrimSpace(line) // Fast-path: import directives must start with '@' or '{'; skip the regex for all other lines. - if len(trimmedLine) == 0 || (trimmedLine[0] != '@' && trimmedLine[0] != '{') { + if trimmedLine == "" || (trimmedLine[0] != '@' && trimmedLine[0] != '{') { return nil } diff --git a/pkg/parser/remote_fetch.go b/pkg/parser/remote_fetch.go index 616b48be444..c1cff456d3e 100644 --- a/pkg/parser/remote_fetch.go +++ b/pkg/parser/remote_fetch.go @@ -476,7 +476,7 @@ func resolveRefToSHAViaGit(owner, repo, ref, host string) (string, error) { // Parse the output: " " lines := strings.Split(strings.TrimSpace(string(output)), "\n") - if len(lines) == 0 || len(lines[0]) == 0 { + if len(lines) == 0 || lines[0] == "" { return "", fmt.Errorf("no matching ref found for %s", ref) } diff --git a/pkg/stringutil/fuzzy_match.go b/pkg/stringutil/fuzzy_match.go index 79969f72b08..a531a7b426d 100644 --- a/pkg/stringutil/fuzzy_match.go +++ b/pkg/stringutil/fuzzy_match.go @@ -70,10 +70,10 @@ func LevenshteinDistance(a, b string) int { bLen := len(b) // Early exit for empty strings - if aLen == 0 { + if a == "" { return bLen } - if bLen == 0 { + if b == "" { return aLen } diff --git a/pkg/workflow/cache.go b/pkg/workflow/cache.go index 67f5d167482..2144ac6c6cd 100644 --- a/pkg/workflow/cache.go +++ b/pkg/workflow/cache.go @@ -60,7 +60,7 @@ var validCacheMemoryScopes = []string{"workflow", "repo"} // This prevents path-traversal attacks (e.g. "../../etc") when the ID is // appended to cacheMemoryDirPrefix to form a filesystem path. func isValidCacheID(id string) bool { - if len(id) == 0 || len(id) > 64 { + if id == "" || len(id) > 64 { return false } for _, c := range id { diff --git a/pkg/workflow/codex_logs.go b/pkg/workflow/codex_logs.go index a6f2b263f90..055cac0559d 100644 --- a/pkg/workflow/codex_logs.go +++ b/pkg/workflow/codex_logs.go @@ -325,7 +325,7 @@ func (e *CodexEngine) extractOutputSizeFromJSONFallback(jsonStr string) int { for i := 1; i < len(parts); i++ { // Find the quoted string value part := strings.TrimSpace(parts[i]) - if len(part) == 0 || part[0] != '"' { + if part == "" || part[0] != '"' { continue } diff --git a/pkg/workflow/compiler_safe_outputs_job.go b/pkg/workflow/compiler_safe_outputs_job.go index 423c4013244..1a21f015583 100644 --- a/pkg/workflow/compiler_safe_outputs_job.go +++ b/pkg/workflow/compiler_safe_outputs_job.go @@ -828,7 +828,7 @@ func scriptNameToHandlerName(scriptName string) string { } if sb.Len() == len("handle") { // Fallback: use the script name as-is when parts are empty - if len(scriptName) == 0 { + if scriptName == "" { sb.WriteString("Unknown") } else { sb.WriteString(strings.ToUpper(scriptName[:1]) + scriptName[1:]) diff --git a/pkg/workflow/engine_helpers.go b/pkg/workflow/engine_helpers.go index ce18c6b1c29..caf272cfc16 100644 --- a/pkg/workflow/engine_helpers.go +++ b/pkg/workflow/engine_helpers.go @@ -273,7 +273,7 @@ func appendEnvVarLine(lines []string, key, value string) []string { // that would cause it to be misinterpreted by YAML parsers, it wraps the value // in single quotes. Any embedded single quotes are escaped by doubling them (' becomes ”). func yamlStringValue(value string) string { - if len(value) == 0 { + if value == "" { return value } if quoted := quoteYAMLValueContainingColonSpace(value); quoted != value { diff --git a/pkg/workflow/redact_secrets.go b/pkg/workflow/redact_secrets.go index c4bf247315f..f5c1d19683d 100644 --- a/pkg/workflow/redact_secrets.go +++ b/pkg/workflow/redact_secrets.go @@ -44,7 +44,7 @@ func CollectSecretReferences(yamlContent string) []string { rest = rest[idx+len(secretsPrefix):] // First character of the name must be an uppercase letter - if len(rest) == 0 || rest[0] < 'A' || rest[0] > 'Z' { + if rest == "" || rest[0] < 'A' || rest[0] > 'Z' { continue } diff --git a/pkg/workflow/runtime_validation.go b/pkg/workflow/runtime_validation.go index 7a942407d03..4407cc4d387 100644 --- a/pkg/workflow/runtime_validation.go +++ b/pkg/workflow/runtime_validation.go @@ -135,7 +135,7 @@ func validateBlockScalarExpressionSizes(lines []string, maxSize int) error { if inBlock { // An empty line is part of the block (blank lines are allowed inside block scalars). - if len(strings.TrimSpace(line)) == 0 { + if strings.TrimSpace(line) == "" { blockSize += len(line) + 1 // +1 for the newline continue } diff --git a/pkg/workflow/template_injection_validation.go b/pkg/workflow/template_injection_validation.go index 78a18d94c6b..1d6100f6ecb 100644 --- a/pkg/workflow/template_injection_validation.go +++ b/pkg/workflow/template_injection_validation.go @@ -85,7 +85,7 @@ func hasExpressionInRunContent(yamlContent string, expressionRegex *regexp.Regex for line := range strings.SplitSeq(yamlContent, "\n") { // Compute indentation first; skip blank and all-whitespace lines in one step. trimmed := strings.TrimLeft(line, " \t") - if len(trimmed) == 0 { + if trimmed == "" { // Blank / all-whitespace lines are allowed inside block scalars. continue } diff --git a/pkg/workflow/xml_comments.go b/pkg/workflow/xml_comments.go index 13f0f79486a..120be8bed78 100644 --- a/pkg/workflow/xml_comments.go +++ b/pkg/workflow/xml_comments.go @@ -172,7 +172,7 @@ func isValidCodeBlockMarker(trimmedLine string) bool { // isMatchingCodeBlockMarker checks if the trimmed line matches the opening marker func isMatchingCodeBlockMarker(trimmedLine string, openMarker string) bool { marker, _ := extractCodeBlockMarker(trimmedLine) - if len(marker) == 0 || len(openMarker) == 0 { + if marker == "" || openMarker == "" { return false }