Skip to content

lint: enable errcheck incrementally across packages #22538

Description

@taratorio

Rationale

errcheck catches ignored error return values that can hide failed I/O, cleanup, persistence, and other operations.

It currently appears in golangci-lint's standard enabled set, but .golangci.yml effectively disables it repository-wide with this exclusion:

- linters:
    - errcheck
  text: not checked

This is observable today:

go tool golangci-lint run --config ./.golangci.yml --enable-only errcheck --max-issues-per-linter 0 --max-same-issues 0 ./...
0 issues.

Running errcheck without the repository exclusion immediately reports findings, including in cmd/pics/visual, node/app/util, and p2p.

Enabling it in one repository-wide cleanup would be risky and difficult to review. Some ignored errors are intentional, and blindly changing every site to return the error can alter behavior—for example, cleanup errors may need to remain secondary to an earlier operation error, while some operations are deliberately best-effort. Each finding therefore needs package-specific semantic review rather than a mechanical fix.

This supersedes #11180, which was closed as stale; the broad suppression is still present.

Implementation

Bootstrap enforcement in one PR:

  1. Temporarily remove the broad text: not checked exclusion and run errcheck with unlimited issue counts to produce a complete baseline grouped by Go package.
  2. Add temporary path-based exclusions only for packages with baseline findings.
  3. Keep errcheck enabled for every package that already passes, so clean and newly added packages cannot introduce unchecked errors.
  4. Record the excluded-package list and finding counts in a checklist on this issue.

Then migrate one package per PR:

  1. Review every finding in the package and determine whether the error must be propagated, handled locally, combined with an existing error, or intentionally ignored.
  2. Add or adjust tests before production changes wherever error handling affects behavior.
  3. Use narrowly scoped suppressions only where ignoring the error is demonstrably intentional; do not replace the repository-wide exclusion with another broad function or message exclusion.
  4. Remove that package's temporary exclusion.
  5. Run make lint repeatedly until clean, followed by make erigon integration.
  6. Link the PR from the package checklist item.

Completion criteria

  • The broad errcheck message exclusion is removed.
  • CI enforces errcheck for all packages not in the temporary baseline exclusion list.
  • Every initially failing package has a tracked checklist item and is handled in a focused PR.
  • All temporary package exclusions are removed.
  • Any remaining intentional ignores are narrow, explicit, and reviewed.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions