Skip to content

all: enable and resolve uncheckedInlineErr, preferStringWriter, preferFprint, and deprecatedComment linter checks - #23097

Queued
Sahil-4555 wants to merge 14 commits into
erigontech:mainfrom
Sahil-4555:linter/enable-nilvalreturn
Queued

all: enable and resolve uncheckedInlineErr, preferStringWriter, preferFprint, and deprecatedComment linter checks#23097
Sahil-4555 wants to merge 14 commits into
erigontech:mainfrom
Sahil-4555:linter/enable-nilvalreturn

Conversation

@Sahil-4555

Copy link
Copy Markdown
Collaborator

Enables four gocritic linter rules (uncheckedInlineErr, preferStringWriter, preferFprint, and deprecatedComment) in .golangci.yml and resolves all code violations across the repository.

  1. uncheckedInlineErr

    • Rule: Flags inlined error initializations where the error variable is not cleanly evaluated in the condition.
    • Changes: Un-inlined error assignment err := utils.SetNodeConfig(...) prior to if err != nil check in cmd/erigon/node/node.go.
  2. preferStringWriter

    • Rule: Prefers w.WriteString(s) over w.Write([]byte(s)) to avoid unnecessary string-to-byte allocations on writers implementing io.StringWriter.
    • Changes: Refactored Write([]byte(...)) calls to WriteString(...) in cmd/rpctest/rpctest/utils.go and db/state/commitment_convert.go.
  3. preferFprint

    • Rule: Prefers fmt.Fprintf(w, ...) over w.WriteString(fmt.Sprintf(...)) for cleaner syntax and reduced allocations.
    • Changes: Refactored string formatting calls to fmt.Fprintf across cmd/capcli/cli.go and execution/commitment/hex_patricia_hashed.go.
  4. deprecatedComment

    • Rule: Enforces standard Go formatting for Deprecated: notices by placing them in a dedicated paragraph so IDEs and Go tooling correctly parse deprecation hints.
    • Changes: Added blank comment lines before Deprecated: notices across:
      • cl/cltypes/solid/hashutil.go
      • node/cli/flags.go
      • p2p/enode/node.go
      • rpc/jsonrpc/eth_deprecated.go
      • rpc/subscription.go

@erigon-copilot

erigon-copilot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

[SharovBot] 🤖 Closed by automated review.

This PR appears to be an AI-generated stylistic/convention change (linter compliance: preferFprint, preferStringWriter, deprecatedComment fixups) from a non-core contributor.

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.

@erigon-copilot erigon-copilot Bot closed this Aug 7, 2026
@Sahil-4555 Sahil-4555 reopened this Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and deprecatedComment by removing them from gocritic.disabled-checks in .golangci.yml.
  • Replaces Write([]byte(s)) / WriteString(fmt.Sprintf(...)) patterns with WriteString(...) and fmt.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.

Comment thread .golangci.yml
@awskii
awskii added this pull request to the merge queue Aug 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 10, 2026
@Sahil-4555
Sahil-4555 requested a review from awskii August 10, 2026 15:28
@awskii
awskii enabled auto-merge August 10, 2026 16:01
@awskii
awskii added this pull request to the merge queue Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants