all: enable and resolve uncheckedInlineErr, preferStringWriter, preferFprint, and deprecatedComment linter checks - #23097
Conversation
|
[SharovBot] 🤖 Closed by automated review. This PR appears to be an AI-generated stylistic/convention change (linter compliance: These types of changes are not being accepted at this time. The changes will be included in a consolidated weekly cleanup PR. If you believe this was closed in error, please reach out to a maintainer. |
There was a problem hiding this comment.
Pull request overview
This pull request enables four additional gocritic checks in the repo’s GolangCI-Lint configuration and updates code across the repository to comply with those rules (error-check structuring, more allocation-friendly writing APIs, and standard Go deprecation comment formatting).
Changes:
- Enables
uncheckedInlineErr,preferStringWriter,preferFprint, anddeprecatedCommentby removing them fromgocritic.disabled-checksin.golangci.yml. - Replaces
Write([]byte(s))/WriteString(fmt.Sprintf(...))patterns withWriteString(...)andfmt.Fprintf(...)where appropriate. - Updates doc comments so
Deprecated:notices are in their own paragraph (tooling-recognizable format).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.golangci.yml |
Stops disabling the four targeted gocritic checks so they run in CI/local lint. |
cmd/erigon/node/node.go |
Refactors to avoid inline error initialization per uncheckedInlineErr. |
cmd/rpctest/rpctest/utils.go |
Uses WriteString for request JSON writing per preferStringWriter. |
db/state/commitment_convert.go |
Uses WriteString when writing the restore manifest to avoid string→[]byte allocation. |
cmd/capcli/cli.go |
Uses fmt.Fprintf to write formatted CSV lines per preferFprint. |
execution/commitment/hex_patricia_hashed.go |
Replaces WriteString(fmt.Sprintf(...)) with fmt.Fprintf in FullString() per preferFprint. |
cl/cltypes/solid/hashutil.go |
Adds a blank comment line before Deprecated: to satisfy deprecatedComment. |
node/cli/flags.go |
Adds a blank comment line before Deprecated: to satisfy deprecatedComment. |
p2p/enode/node.go |
Adds a blank comment line before Deprecated: to satisfy deprecatedComment. |
rpc/jsonrpc/eth_deprecated.go |
Adds a blank comment line before Deprecated: to satisfy deprecatedComment. |
rpc/subscription.go |
Adds a blank comment line before Deprecated: to satisfy deprecatedComment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Enables four
gocriticlinter rules (uncheckedInlineErr,preferStringWriter,preferFprint, anddeprecatedComment) in.golangci.ymland resolves all code violations across the repository.uncheckedInlineErrerr := utils.SetNodeConfig(...)prior toif err != nilcheck incmd/erigon/node/node.go.preferStringWriterw.WriteString(s)overw.Write([]byte(s))to avoid unnecessary string-to-byte allocations on writers implementingio.StringWriter.Write([]byte(...))calls toWriteString(...)incmd/rpctest/rpctest/utils.goanddb/state/commitment_convert.go.preferFprintfmt.Fprintf(w, ...)overw.WriteString(fmt.Sprintf(...))for cleaner syntax and reduced allocations.fmt.Fprintfacrosscmd/capcli/cli.goandexecution/commitment/hex_patricia_hashed.go.deprecatedCommentDeprecated:notices by placing them in a dedicated paragraph so IDEs and Go tooling correctly parse deprecation hints.Deprecated:notices across:cl/cltypes/solid/hashutil.gonode/cli/flags.gop2p/enode/node.gorpc/jsonrpc/eth_deprecated.gorpc/subscription.go