Skip to content

lint: enable captLocal and commentFormatting gocritic rules - #22800

Merged
taratorio merged 28 commits into
erigontech:mainfrom
Sahil-4555:refactor/unnecessary-defer
Jul 30, 2026
Merged

lint: enable captLocal and commentFormatting gocritic rules#22800
taratorio merged 28 commits into
erigontech:mainfrom
Sahil-4555:refactor/unnecessary-defer

Conversation

@Sahil-4555

@Sahil-4555 Sahil-4555 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

We have resolved all linter warnings for captLocal rules reported by gocritic as below

  1. Linter Rule Configuration:

    • Enabled captLocal by removing them from disabled-checks in .golangci.yml.
  2. Codebase-wide formatting & variable naming:

    • Capitalized local variables, function parameters, and receiver names corrected to lowercase to follow Go naming conventions (resolving captLocal issues).

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

Enables additional gocritic rules (captLocal, commentFormatting) in the repo’s GolangCI-Lint configuration and updates the codebase to comply, primarily via mechanical comment spacing fixes and local identifier renames to satisfy captLocal.

Changes:

  • Enabled gocritic checks captLocal and commentFormatting in .golangci.yml.
  • Mechanical formatting fixes across many files to satisfy commentFormatting (e.g., ensuring // spacing).
  • Renamed local variables/parameters/receivers in select files to satisfy captLocal (uppercase → lowercase).

Reviewed changes

Copilot reviewed 19 out of 285 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
txnprovider/txpool/txpoolcfg/txpoolcfg.go Comment spacing tweaks for commentFormatting.
txnprovider/txpool/txpool_grpc_server.go Comment spacing tweaks for commentFormatting.
txnprovider/txpool/tests/pool_test.go Comment spacing tweaks for commentFormatting.
txnprovider/txpool/pool_txn_types_fuzz_test.go Comment spacing tweaks for commentFormatting.
txnprovider/shutter/encrypted_txns_pool.go Comment spacing tweaks for commentFormatting.
rpc/requests/request_generator.go Comment spacing tweaks for commentFormatting.
rpc/jsonstream/stack_stream_test.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/trace_filtering.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/trace_adhoc.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/storage_range.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/send_transaction_test.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/receipts/receipts_generator.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/overlay_api.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/otterscan_transaction_by_sender_and_nonce_test.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/eth_receipts.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/eth_callMany_test.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/eth_call_test.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/erigon_api.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/debug_execution_witness.go Comment spacing tweaks for commentFormatting.
rpc/jsonrpc/bor_api_impl.go Comment spacing tweaks for commentFormatting.
rpc/handler.go Comment spacing tweaks for commentFormatting.
rpc/gasprice/gasprice_test.go Comment spacing tweaks for commentFormatting.
rpc/gasprice/feehistory_test.go Comment spacing tweaks for commentFormatting.
polygon/tests/mining_test.go Comment spacing tweaks for commentFormatting.
polygon/bridge/snapshot_store.go Comment spacing tweaks for commentFormatting.
polygon/bor/bor_test.go Comment spacing tweaks for commentFormatting.
p2p/sentry/sentry_multi_client/sentry_multi_client.go Comment spacing tweaks for commentFormatting.
p2p/protocols/eth/handlers.go Comment spacing tweaks for commentFormatting.
p2p/enode/nodedb_test.go Comment spacing tweaks for commentFormatting.
p2p/discover/v5wire/encoding_test.go Comment spacing tweaks for commentFormatting.
node/shards/state_cache_test.go Comment spacing tweaks for commentFormatting.
node/shards/events.go captLocal param rename + related assignment update.
node/rpcstack_test.go Comment spacing tweaks for commentFormatting.
node/node.go Comment spacing tweaks for commentFormatting.
node/node_test.go Comment spacing tweaks for commentFormatting.
node/logging/logging.go Comment spacing tweaks for commentFormatting.
node/gointerfaces/grpcutil/utils.go Comment spacing tweaks for commentFormatting.
node/ethconfig/config.go Comment spacing tweaks for commentFormatting.
node/eth/backend.go Comment spacing tweaks for commentFormatting.
node/eth/backend_test.go Comment spacing tweaks for commentFormatting.
node/debug/api.go Comment spacing tweaks for commentFormatting.
node/app/workerpool/workerpool_test.go Comment spacing tweaks for commentFormatting.
node/app/version.go Comment spacing tweaks for commentFormatting.
node/app/util/compare.go Comment spacing tweaks for commentFormatting.
node/app/event/managedeventbus.go Comment spacing tweaks for commentFormatting.
node/app/event/eventbus.go Comment spacing tweaks for commentFormatting.
execution/vm/runtime/runtime.go Comment spacing tweaks for commentFormatting.
execution/vm/program/program_test.go Comment spacing tweaks for commentFormatting.
execution/vm/operations_acl.go Comment spacing tweaks for commentFormatting.
execution/vm/instructions.go Adds/adjusts comment (and formatting).
execution/vm/contracts_test.go Comment spacing tweaks for commentFormatting.
execution/vm/analysis_test.go Comment spacing tweaks for commentFormatting.
execution/types/transaction.go captLocal rename in helper signature and locals.
execution/types/receipt.go Comment spacing tweaks for commentFormatting.
execution/types/receipt_test.go Comment spacing tweaks for commentFormatting.
execution/types/log.go Comment spacing tweaks for commentFormatting.
execution/types/encdec_test.go Comment spacing tweaks for commentFormatting.
execution/types/bloom9_test.go Comment spacing tweaks for commentFormatting.
execution/types/block.go Comment spacing tweak (includes a go:generate-looking line).
execution/types/accounts/account.go Comment spacing tweaks for commentFormatting.
execution/types/accounts/account_benchmark_test.go Comment spacing tweaks for commentFormatting.
execution/tracing/tracers/logger/logger_test.go Comment spacing tweaks for commentFormatting.
execution/tracing/tracers/logger/logger_json.go Comment spacing tweaks for commentFormatting.
execution/tracing/tracers/js/tracer_test.go Comment spacing tweaks for commentFormatting.
execution/tests/testutil/matcher.go Comment spacing tweaks for commentFormatting.
execution/tests/state_test.go Comment spacing tweaks for commentFormatting.
execution/tests/chaos_monkey/chaos_monkey.go captLocal param rename (IsInitialCycleisInitialCycle).
execution/tests/blockchain_test.go Comment spacing tweaks for commentFormatting.
execution/state/triedb_state.go Comment spacing tweaks for commentFormatting.
execution/state/state_test.go Comment spacing tweaks for commentFormatting.
execution/state/state_object.go Comment spacing tweaks for commentFormatting.
execution/state/rw_v3.go Comment spacing tweaks for commentFormatting.
execution/state/history_reader_v3.go Comment spacing tweaks for commentFormatting.
execution/state/genesiswrite/genesis_write.go Comment spacing tweaks for commentFormatting.
execution/state/genesiswrite/genesis_test.go Comment spacing tweaks for commentFormatting.
execution/state/dump.go Comment spacing tweaks for commentFormatting.
execution/state/database.go Comment spacing tweaks for commentFormatting.
execution/state/database_test.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/sync.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/sync_test.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/stage_snapshots.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/stage_senders.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/stage_finish.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/stage_custom_trace.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/rawdbreset/reset_stages.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/exec3_serial.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/exec3_parallel.go Comment spacing tweaks for commentFormatting.
execution/stagedsync/default_stages.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/merge/merge.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/ethash/difficulty.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/aura/rolling_finality.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/aura/gaslimit_override.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/aura/empty_step.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/aura/config.go Comment spacing tweaks for commentFormatting.
execution/protocol/rules/aura/aura_test.go Comment spacing tweaks for commentFormatting.
execution/protocol/misc/eip4844_test.go Comment spacing tweaks for commentFormatting.
execution/protocol/mdgas/md_gas.go Comment spacing tweaks for commentFormatting.
execution/protocol/evm.go Comment spacing tweaks for commentFormatting.
execution/notifications/accumulator.go Comment spacing tweaks for commentFormatting.
execution/execmodule/notification_dispatcher.go Comment spacing tweaks for commentFormatting.
execution/execmodule/forkchoice.go Comment spacing tweaks for commentFormatting.
execution/execmodule/execmoduletester/exec_module_tester.go Comment spacing tweaks for commentFormatting.
execution/exec/txtask.go Comment spacing tweaks for commentFormatting.
execution/exec/state.go Comment spacing tweaks for commentFormatting.
execution/exec/recon_state.go Comment spacing tweaks for commentFormatting.
execution/exec/historical_trace_worker.go Comment spacing tweaks for commentFormatting.
execution/exec/blocks_read_ahead.go Comment spacing tweaks for commentFormatting.
execution/commitment/trie/trie.go Comment spacing tweaks for commentFormatting.
execution/commitment/trie/gen_struct_step.go Comment spacing tweaks for commentFormatting.
execution/commitment/trie/debug.go Comment spacing tweaks for commentFormatting.
execution/commitment/commitmentdb/commitment_context.go Comment spacing tweaks for commentFormatting.
execution/builder/finish.go Comment spacing tweaks for commentFormatting.
execution/builder/create_block.go Comment spacing tweaks for commentFormatting.
execution/abi/unpack_test.go Comment spacing tweaks for commentFormatting.
execution/abi/bind/bind_test.go Comment spacing tweaks for commentFormatting.
execution/abi/bind/backends/simulated.go Comment spacing tweaks for commentFormatting.
execution/abi/abifuzzer_test.go Comment spacing tweaks for commentFormatting.
diagnostics/sysutils/sysutils.go Comment spacing tweaks for commentFormatting.
diagnostics/diaglib/stages_test.go Comment spacing tweaks for commentFormatting.
diagnostics/diaglib/network_test.go Comment spacing tweaks for commentFormatting.
db/test/domain_shared_bench_test.go Comment spacing tweaks for commentFormatting.
db/state/statecfg/state_schema.go Comment spacing tweaks for commentFormatting.
db/state/snap_repo.go Comment spacing tweaks for commentFormatting.
db/state/snap_config.go Comment spacing tweaks for commentFormatting.
db/state/metrics.go Comment spacing tweaks for commentFormatting.
db/state/merge.go Comment spacing tweaks for commentFormatting.
db/state/inverted_index_test.go Comment spacing tweaks for commentFormatting.
db/state/inverted_index_stream.go Comment spacing tweaks for commentFormatting.
db/state/history_stream.go Comment spacing tweaks for commentFormatting.
db/state/execctx/domain_shared.go Comment spacing tweaks for commentFormatting.
db/state/execctx/domain_shared_test.go Comment spacing tweaks for commentFormatting.
db/state/entity_integrity_check.go captLocal rename of named return (IsPresentisPresent).
db/state/domain_committed.go Comment spacing tweaks for commentFormatting.
db/state/dirty_files.go Comment spacing tweaks for commentFormatting.
db/state/aggregator2.go Comment spacing tweaks for commentFormatting.
db/state/aggregator_fuzz_test.go Comment spacing tweaks for commentFormatting.
db/snaptype2/block_types.go Comment spacing tweaks for commentFormatting.
db/snaptype/type.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/snapshotsync.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/snapshots_test.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/merger.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/freezeblocks/dump_test.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/freezeblocks/bor_snapshots.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/freezeblocks/block_snapshots.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/freezeblocks/block_reader.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/freezeblocks/block_cache_test.go Comment spacing tweaks for commentFormatting.
db/snapshotsync/caplin_state_snapshots.go Comment spacing tweaks for commentFormatting.
db/snapcfg/util.go Comment spacing tweaks for commentFormatting.
db/seg/seg_paged_rw.go Comment spacing tweaks for commentFormatting.
db/seg/seg_auto_rw.go Comment spacing tweaks for commentFormatting.
db/seg/decompress.go Comment spacing tweaks for commentFormatting.
db/seg/decompress_bench_test.go Comment spacing tweaks for commentFormatting.
db/recsplit/simpleseq/simple_sequence.go Comment spacing tweaks for commentFormatting.
db/recsplit/recsplit.go Comment spacing tweaks for commentFormatting.
db/recsplit/recsplit_test.go Comment spacing tweaks for commentFormatting.
db/recsplit/index.go Comment block formatting adjusted (and needs cleanup).
db/recsplit/index_test.go Comment spacing tweaks for commentFormatting.
db/recsplit/golomb_rice.go Comment spacing tweaks for commentFormatting.
db/recsplit/eliasfano32/elias_fano_test.go Comment spacing tweaks for commentFormatting.
db/rawdb/rawtemporaldb/accessors_receipt_test.go Comment spacing tweaks for commentFormatting.
db/rawdb/accessors_chain.go Comment spacing tweaks for commentFormatting.
db/rawdb/accessors_chain_test.go Comment spacing tweaks for commentFormatting.
db/migrations/migrations_test.go Comment spacing tweaks for commentFormatting.
db/kv/temporal/kv_temporal.go Comment spacing tweaks for commentFormatting.
db/kv/tables.go Comment spacing tweaks for commentFormatting.
db/kv/stream/stream_test.go Comment spacing tweaks for commentFormatting.
db/kv/stream/stream_interface.go Comment spacing tweaks for commentFormatting.
db/kv/remotedbserver/remotedbserver.go Comment spacing tweaks for commentFormatting.
db/kv/rawdbv3/txnum.go Comment spacing tweaks for commentFormatting.
db/kv/prune/prune.go Comment spacing tweaks for commentFormatting.
db/kv/membatchwithdb/memory_mutation.go Comment spacing tweaks for commentFormatting.
db/kv/membatchwithdb/memory_mutation_test.go Comment spacing tweaks for commentFormatting.
db/kv/mdbx/kv_mdbx.go Comment spacing tweaks for commentFormatting.
db/kv/mdbx/kv_abstract_test.go Comment spacing tweaks for commentFormatting.
db/kv/kvcache/cache_test.go Comment spacing tweaks for commentFormatting.
db/kv/kv_interface.go Comment spacing tweaks for commentFormatting.
db/integrity/receipts_no_duplicates.go Comment spacing tweaks for commentFormatting.
db/integrity/integrity_action_type.go Comment spacing tweaks for commentFormatting.
db/etl/heap.go Comment spacing tweaks for commentFormatting.
db/etl/etl_test.go Comment spacing tweaks for commentFormatting.
db/etl/collector.go Comment spacing tweaks for commentFormatting.
db/etl/buffers.go Comment spacing tweaks for commentFormatting.
db/downloader/webseeds/verify.go Comment spacing tweaks for commentFormatting.
db/downloader/webseed.go Comment spacing tweaks for commentFormatting.
db/downloader/util.go Comment spacing tweaks for commentFormatting.
db/downloader/downloadercfg/downloadercfg.go Comment spacing tweaks for commentFormatting.
db/downloader/downloader_test.go Comment spacing tweaks for commentFormatting.
db/datastruct/fusefilter/fusefilter_reader.go Comment spacing tweaks for commentFormatting.
db/datastruct/btindex/btree_index_test.go Comment spacing tweaks for commentFormatting.
db/datastruct/btindex/bpstree_bench_test.go Comment spacing tweaks for commentFormatting.
db/datadir/dirs.go Comment spacing tweaks for commentFormatting.
common/types_test.go Comment spacing tweaks for commentFormatting.
common/log/v3/root.go Comment spacing tweaks for commentFormatting.
common/log/v3/log_test.go Comment spacing tweaks for commentFormatting.
common/hexutil/json.go Comment spacing tweaks for commentFormatting.
common/estimate/esitmated_ram.go Comment spacing tweaks for commentFormatting.
common/dbg/experiments.go Comment spacing tweaks for commentFormatting.
common/crypto/ecies/ecies.go captLocal renames in deriveKeys locals/returns.
common/crypto/blake2b/blake2b_f_test.go Comment spacing tweaks for commentFormatting.
common/chan.go Comment spacing tweaks for commentFormatting.
common/bytes.go Comment spacing tweaks for commentFormatting.
cmd/utils/flags/flags.go Comment spacing tweaks for commentFormatting.
cmd/utils/flags.go Comment spacing tweaks for commentFormatting.
cmd/utils/app/reset-datadir.go Comment spacing tweaks for commentFormatting.
cmd/utils/app/publishable_check.go Comment spacing tweaks for commentFormatting.
cmd/utils/app/make_app.go Comment spacing tweaks for commentFormatting.
cmd/rpctest/rpctest/bench7.go Comment spacing tweaks for commentFormatting.
cmd/rpctest/rpctest/bench3.go Comment spacing tweaks for commentFormatting.
cmd/rpcdaemon/main.go Comment spacing tweaks for commentFormatting.
cmd/rpcdaemon/cli/httpcfg/http_cfg.go Comment spacing tweaks for commentFormatting.
cmd/rpcdaemon/cli/config.go Comment spacing tweaks for commentFormatting.
cmd/integration/main.go Comment spacing tweaks for commentFormatting.
cmd/integration/commands/state_stages.go Comment spacing tweaks for commentFormatting.
cmd/integration/commands/state_history.go Comment spacing tweaks for commentFormatting.
cmd/integration/commands/reset_state.go Comment spacing tweaks for commentFormatting.
cmd/evm/runner.go Comment spacing tweaks for commentFormatting.
cmd/evm/internal/t8ntool/execution.go Comment spacing tweaks for commentFormatting.
cmd/erigon/node/node.go Comment spacing tweaks for commentFormatting.
cmd/erigon/main.go Comment spacing tweaks for commentFormatting.
cmd/downloader/main.go Comment spacing tweaks for commentFormatting.
cmd/caplin/caplin1/run.go Comment spacing tweaks for commentFormatting.
cl/utils/eth2shuffle/shuffle_bench_test.go Comment spacing tweaks for commentFormatting.
cl/transition/impl/eth2/validation.go captLocal receiver rename (Iimp).
cl/spectest/consensus_tests/rewards.go Comment spacing tweaks for commentFormatting.
cl/spectest/consensus_tests/fork_choice.go Comment spacing tweaks for commentFormatting.
cl/spectest/consensus_tests/bls.go Comment spacing tweaks for commentFormatting.
cl/sentinel/utils_test.go Comment spacing tweaks for commentFormatting.
cl/sentinel/service/start.go captLocal param rename (PeerDasStateReaderpeerDasStateReader).
cl/sentinel/service/service.go Comment spacing tweaks for commentFormatting.
cl/sentinel/sentinel.go Comment spacing tweaks for commentFormatting.
cl/sentinel/handlers/heartbeats.go Comment spacing tweaks for commentFormatting.
cl/rpc/peer_selection.go Comment spacing tweaks for commentFormatting.
cl/phase1/network/services/voluntary_exit_service_test.go Comment spacing tweaks for commentFormatting.
cl/phase1/network/services/data_column_sidecar_service_test.go Comment spacing tweaks for commentFormatting.
cl/phase1/network/services/attestation_service.go Comment spacing tweaks for commentFormatting.
cl/phase1/network/services/attestation_service_test.go Comment spacing tweaks for commentFormatting.
cl/phase1/network/gossip/gossip_manager.go Comment spacing tweaks for commentFormatting.
cl/phase1/forkchoice/optimistic/optimistic_impl.go Comment spacing tweaks for commentFormatting.
cl/phase1/core/state/raw/setters_test.go Comment spacing tweaks for commentFormatting.
cl/das/peer_das.go Comment spacing tweaks for commentFormatting.
cl/cltypes/solid/validator.go captLocal param renames in constructor helper.
cl/clparams/config.go Comment spacing tweaks for commentFormatting.
cl/beacon/handler/validators.go Comment spacing tweaks for commentFormatting.
cl/beacon/handler/subscription.go Comment spacing tweaks for commentFormatting.
cl/beacon/handler/states_test.go Comment spacing tweaks for commentFormatting.
cl/beacon/handler/rewards_test.go Comment spacing tweaks for commentFormatting.
cl/beacon/builder/types.go Comment spacing tweaks for commentFormatting.
.golangci.yml Enables gocritic checks by removing them from disabled-checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread execution/vm/instructions.go Outdated
return pc, nil, &ErrStackUnderflow{stackLen: scope.Stack.len(), required: n}
}

// The n‘th stack item is duplicated at the top of the stack.
Comment thread db/recsplit/index.go Outdated
Comment on lines +158 to +162
// }
// // pos := 1 + 8 + idx.bytesPerRec*int(idx.keyCount)
// // panic(err)
// // }
// }
Comment thread execution/types/block.go Outdated
}

//()go:generate gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
// ()go:generate gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
@AskAlexSharov

Copy link
Copy Markdown
Collaborator

let's ignore commentFormatting - it only will add friction to local lints and ci - with no real profit.

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

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

.golangci.yml:53

  • PR title/description say both gocritic checks captLocal and commentFormatting were enabled, but .golangci.yml still keeps commentFormatting in disabled-checks (and even adds a note explaining why it stays disabled). Please either remove commentFormatting from disabled-checks to match the PR intent, or update the PR title/description to reflect that only captLocal is being enabled.
    gocritic:
      enabled-checks:
        - ruleguard
      disabled-checks:
        - commentFormatting # disabled to avoid unnecessary friction on local lints and CI for minor whitespace changes without functional benefit

@taratorio
taratorio enabled auto-merge July 30, 2026 16:28
@taratorio
taratorio added this pull request to the merge queue Jul 30, 2026
Merged via the queue into erigontech:main with commit a04894f Jul 30, 2026
109 checks passed
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.

4 participants