From 1b96139023cfaff0d942f9eee37880877ee7b8a8 Mon Sep 17 00:00:00 2001 From: Alan Parra <12500300+codingllama@users.noreply.github.com> Date: Thu, 19 Feb 2026 10:04:57 -0300 Subject: [PATCH] chore: Bump golangci-lint to v2.10.1 (#63939) * Fix "builder.WriteString(fmt.Sprintf(...))" calls * chore: Bump golangci-lint to v2.10.1 * Bump e/ * Fix a few more WriteString/Sprintf occurrences --- build.assets/versions.mk | 2 +- e | 2 +- examples/dynamoathenamigration/migration_test.go | 3 ++- gen/go/eventschema/getters.go | 6 +++--- integrations/access/email/client.go | 2 +- integrations/access/jira/types.go | 4 ++-- integrations/terraform/provider/credentials.go | 2 +- lib/accesslists/walk.go | 2 +- lib/autoupdate/rollout/metrics.go | 2 +- lib/client/ca_export.go | 2 +- lib/client/db/postgres/repl/commands.go | 2 +- lib/integrations/awsra/createsession/createsession.go | 2 +- lib/srv/sess.go | 2 +- lib/srv/usermgmt.go | 2 +- tool/tctl/common/autoupdate_command.go | 4 ++-- 15 files changed, 20 insertions(+), 19 deletions(-) diff --git a/build.assets/versions.mk b/build.assets/versions.mk index c8ab7fde1db..cf5aa8df62d 100644 --- a/build.assets/versions.mk +++ b/build.assets/versions.mk @@ -3,7 +3,7 @@ # Sync with devbox.json. GOLANG_VERSION ?= go1.25.7 -GOLANGCI_LINT_VERSION ?= v2.7.2 +GOLANGCI_LINT_VERSION ?= v2.10.1 # NOTE: Remember to update engines.node in package.json to match the major version. NODE_VERSION ?= 24.13.0 diff --git a/e b/e index 45c60e6cc5c..5ec90ceb017 160000 --- a/e +++ b/e @@ -1 +1 @@ -Subproject commit 45c60e6cc5c239ebf6b777f82e81ea17d92fdbba +Subproject commit 5ec90ceb017d319ed852d542345faa7ad045f77e diff --git a/examples/dynamoathenamigration/migration_test.go b/examples/dynamoathenamigration/migration_test.go index 8c7cbf4fcc6..ceb7b3a3002 100644 --- a/examples/dynamoathenamigration/migration_test.go +++ b/examples/dynamoathenamigration/migration_test.go @@ -514,7 +514,8 @@ func generateDynamoExportData(n int) string { lineFmt := `{ "Item": { "EventIndex": { "N": "2147483647" }, "SessionID": { "S": "4298bd54-a747-4d53-b850-83ba17caae5a" }, "CreatedAtDate": { "S": "2023-05-22" }, "FieldsMap": { "M": { "cluster_name": { "S": "test.example.local" }, "uid": { "S": "%s" }, "code": { "S": "T2005I" }, "ei": { "N": "2147483647" }, "time": { "S": "2023-05-22T12:12:21.966Z" }, "event": { "S": "session.upload" }, "sid": { "S": "4298bd54-a747-4d53-b850-83ba17caae5a" } } }, "EventType": { "S": "session.upload" }, "EventNamespace": { "S": "default" }, "CreatedAt": { "N": "1684757541" } } }` sb := strings.Builder{} for range n { - sb.WriteString(fmt.Sprintf(lineFmt+"\n", uuid.NewString())) + fmt.Fprintf(&sb, lineFmt, uuid.NewString()) + fmt.Fprintln(&sb) } return sb.String() } diff --git a/gen/go/eventschema/getters.go b/gen/go/eventschema/getters.go index 08176fb43ae..5eba19bd197 100644 --- a/gen/go/eventschema/getters.go +++ b/gen/go/eventschema/getters.go @@ -71,7 +71,7 @@ func QueryableEventList() (string, error) { if err != nil { return "", trace.Wrap(err) } - sb.WriteString(fmt.Sprintf("%s, %s\n", name, eventSchema.Description)) + fmt.Fprintf(&sb, "%s, %s\n", name, eventSchema.Description) } return sb.String(), nil } @@ -137,7 +137,7 @@ func (c *ColumnSchemaDetails) NameJSON() string { sb := strings.Builder{} sb.WriteString("$") for _, item := range c.Path { - sb.WriteString(fmt.Sprintf(`["%s"]`, item)) + fmt.Fprintf(&sb, `["%s"]`, item) } return sb.String() } @@ -251,7 +251,7 @@ func jsonFieldName(path []string) string { sb := strings.Builder{} sb.WriteString("$") for _, item := range path { - sb.WriteString(fmt.Sprintf(`["%s"]`, item)) + fmt.Fprintf(&sb, `["%s"]`, item) } return sb.String() } diff --git a/integrations/access/email/client.go b/integrations/access/email/client.go index f687f5deb00..7fedbf83c26 100644 --- a/integrations/access/email/client.go +++ b/integrations/access/email/client.go @@ -173,7 +173,7 @@ func (c *Client) buildBody(reqID string, reqData RequestData, subject string) st var builder strings.Builder builder.Grow(128) - builder.WriteString(fmt.Sprintf("%v:\n\n", subject)) + fmt.Fprintf(&builder, "%v:\n\n", subject) resolution := reqData.Resolution diff --git a/integrations/access/jira/types.go b/integrations/access/jira/types.go index e9112c0a4b0..604f9fcec0b 100644 --- a/integrations/access/jira/types.go +++ b/integrations/access/jira/types.go @@ -43,10 +43,10 @@ type ErrorResult struct { func (e ErrorResult) Error() string { sb := strings.Builder{} if len(e.ErrorMessages) > 0 { - sb.WriteString(fmt.Sprintf("error messages: %s ", strings.Join(e.ErrorMessages, ";"))) + fmt.Fprintf(&sb, "error messages: %s ", strings.Join(e.ErrorMessages, ";")) } if details := e.Details.String(); details != "" { - sb.WriteString(fmt.Sprintf("error details: %s", details)) + fmt.Fprintf(&sb, "error details: %s", details) } result := sb.String() if result == "" { diff --git a/integrations/terraform/provider/credentials.go b/integrations/terraform/provider/credentials.go index 59400d1544a..875b659e6d9 100644 --- a/integrations/terraform/provider/credentials.go +++ b/integrations/terraform/provider/credentials.go @@ -65,7 +65,7 @@ func (s CredentialSources) ActiveSources(ctx context.Context, config providerDat } if !active { tflog.Info(ctx, "credentials source is not active, skipping", logFields) - inactiveReason.WriteString(fmt.Sprintf(" - cannot read credentials %s because %s\n", source.Name(), reason)) + fmt.Fprintf(&inactiveReason, " - cannot read credentials %s because %s\n", source.Name(), reason) continue } tflog.Info(ctx, "credentials source is active", logFields) diff --git a/lib/accesslists/walk.go b/lib/accesslists/walk.go index dda5495716c..d62da0e4f20 100644 --- a/lib/accesslists/walk.go +++ b/lib/accesslists/walk.go @@ -311,7 +311,7 @@ func explainSkipped(skipped []skippedAccessPath) string { var sb strings.Builder sb.WriteString("\nWhen resolving access, the following access paths were ignored:") for _, path := range skipped { - sb.WriteString(fmt.Sprintf("\n * %q because %s", path, path.reason)) + fmt.Fprintf(&sb, "\n * %q because %s", path, path.reason) } return sb.String() } diff --git a/lib/autoupdate/rollout/metrics.go b/lib/autoupdate/rollout/metrics.go index 59a68cf093e..68fab89b5a8 100644 --- a/lib/autoupdate/rollout/metrics.go +++ b/lib/autoupdate/rollout/metrics.go @@ -269,7 +269,7 @@ func valuesHelpString[K constraints.Integer](possibleValues map[K]string) string // maps are nor ordered, so we must sort keys to consistently generate the help message. keys := maps.Keys(possibleValues) for _, k := range slices.Sorted(keys) { - sb.WriteString(fmt.Sprintf(" %d:%s", k, possibleValues[k])) + fmt.Fprintf(&sb, " %d:%s", k, possibleValues[k]) } sb.WriteRune('.') diff --git a/lib/client/ca_export.go b/lib/client/ca_export.go index 9dca59a0756..10a9d4e5f42 100644 --- a/lib/client/ca_export.go +++ b/lib/client/ca_export.go @@ -500,7 +500,7 @@ func exportGitHubCAs(keySet *types.CAKeySet, req ExportIntegrationAuthoritiesReq // GitHub only needs the keys like "ssh-rsa xxx" so print them without // cert-authority for easier copy-and-paste. - ret.WriteString(fmt.Sprintf("%s integration=%s\n", strings.TrimSpace(string(key.PublicKey)), req.Integration)) + fmt.Fprintf(&ret, "%s integration=%s\n", strings.TrimSpace(string(key.PublicKey)), req.Integration) } if req.MatchFingerprint != "" && ret.Len() == 0 { return "", trace.NotFound("no authorities found matching the provided fingerprint") diff --git a/lib/client/db/postgres/repl/commands.go b/lib/client/db/postgres/repl/commands.go index 6613b37e351..425dae1ddb3 100644 --- a/lib/client/db/postgres/repl/commands.go +++ b/lib/client/db/postgres/repl/commands.go @@ -79,7 +79,7 @@ func initCommands() map[string]*command { // - another item var limitations strings.Builder for _, l := range descriptiveLimitations { - limitations.WriteString(fmt.Sprintf("- %s\n", strings.ReplaceAll(l, lineBreak, lineBreak+" "))) + fmt.Fprintf(&limitations, "- %s\n", strings.ReplaceAll(l, lineBreak, lineBreak+" ")) } return fmt.Sprintf( diff --git a/lib/integrations/awsra/createsession/createsession.go b/lib/integrations/awsra/createsession/createsession.go index b1d2f445622..ae7d9142d4f 100644 --- a/lib/integrations/awsra/createsession/createsession.go +++ b/lib/integrations/awsra/createsession/createsession.go @@ -265,7 +265,7 @@ func CreateSession(ctx context.Context, req CreateSessionRequest) (*CreateSessio // List of signed headers canonicalReqStrBuilder.WriteString(signedHeaders + "\n") // Body hash encoded as hex - canonicalReqStrBuilder.WriteString(fmt.Sprintf("%x", canonicalRequestBodyHash)) + fmt.Fprintf(&canonicalReqStrBuilder, "%x", canonicalRequestBodyHash) // Task 1-8 canonicalRequestStr := canonicalReqStrBuilder.String() diff --git a/lib/srv/sess.go b/lib/srv/sess.go index f526831827b..136c46e26fd 100644 --- a/lib/srv/sess.go +++ b/lib/srv/sess.go @@ -83,7 +83,7 @@ var serverSessions = prometheus.NewGauge( func MsgParticipantCtrls(w io.Writer, m types.SessionParticipantMode) error { var modeCtrl bytes.Buffer - modeCtrl.WriteString(fmt.Sprintf("\r\nTeleport > Joining session with participant mode: %s\r\n", string(m))) + fmt.Fprintf(&modeCtrl, "\r\nTeleport > Joining session with participant mode: %s\r\n", string(m)) modeCtrl.WriteString("Teleport > Controls\r\n") modeCtrl.WriteString("Teleport > - CTRL-C: Leave the session\r\n") if m == types.SessionModeratorMode { diff --git a/lib/srv/usermgmt.go b/lib/srv/usermgmt.go index d47061858c7..55b6503542b 100644 --- a/lib/srv/usermgmt.go +++ b/lib/srv/usermgmt.go @@ -268,7 +268,7 @@ func sanitizeSudoersName(username string) string { func (u *HostSudoersManagement) WriteSudoers(name string, sudoers []string) error { var sudoersOut strings.Builder for _, entry := range sudoers { - sudoersOut.WriteString(fmt.Sprintf("%s %s\n", name, entry)) + fmt.Fprintf(&sudoersOut, "%s %s\n", name, entry) } err := u.backend.WriteSudoersFile(name, []byte(sudoersOut.String())) if errors.Is(err, host.ErrInvalidSudoers) { diff --git a/tool/tctl/common/autoupdate_command.go b/tool/tctl/common/autoupdate_command.go index a544ffafe47..d89d8bc2e81 100644 --- a/tool/tctl/common/autoupdate_command.go +++ b/tool/tctl/common/autoupdate_command.go @@ -346,11 +346,11 @@ func (c *AutoUpdateCommand) omittedSummary(reports []*autoupdatev1pb.AutoUpdateA var sb strings.Builder sb.WriteRune('\n') - sb.WriteString(fmt.Sprintf("%d agents were omitted from the reports:\n", totalOmitted)) + fmt.Fprintf(&sb, "%d agents were omitted from the reports:\n", totalOmitted) // We sort reasons alphabetically as this ensures the output is consistent // And makes snapshot testing easier. for _, reason := range slices.Sorted(maps.Keys(aggregated)) { - sb.WriteString(fmt.Sprintf("- %d omitted because: %s\n", aggregated[reason], reason)) + fmt.Fprintf(&sb, "- %d omitted because: %s\n", aggregated[reason], reason) } return sb.String() }