Skip to content

Comments

chore: enable errcheck, nolintlint, and nilnil linters#3122

Merged
ritmun merged 2 commits intoopenshift:mainfrom
christophermancini:errcheck
Feb 24, 2026
Merged

chore: enable errcheck, nolintlint, and nilnil linters#3122
ritmun merged 2 commits intoopenshift:mainfrom
christophermancini:errcheck

Conversation

@christophermancini
Copy link
Contributor

@christophermancini christophermancini commented Feb 18, 2026

Enable three new golangci-lint checks to improve error handling and code quality.

New PR to replace #3111

Changes

errcheck - Detects unchecked errors

Ensures all error returns are explicitly handled or intentionally ignored to prevent silent failures.

Fixed:

  • internal/sanitizer/sanitizer.go - Wrapped async audit logging in closure to explicitly discard error. Audit logging is fire-and-forget to avoid blocking sanitization.

nilnil - Prevents ambiguous (nil, nil) returns

Functions returning (nil, nil) are ambiguous - callers cannot distinguish between success-with-no-data and error states.

Fixed:

  • pkg/common/cluster/clusterutil.go - Removed special handling of ErrReserveFull. Library code now reports all errors naturally using %w for proper error wrapping.
  • cmd/osde2e/provision/cmd.go - Handles ErrReserveFull at application boundary where business logic belongs. Treats "reserve full" as success, all other errors propagate.
  • pkg/e2e/e2e.go + pkg/common/aws/s3.go - Moved S3 bucket check to caller. Application layer decides whether to upload; library layer just uploads. Added TODO for future refactor to use
    dependency injection.
  • test/sdn_migration/sdn_migration_test.go - Changed terraform destroy to return empty map instead of (nil, nil) to indicate success-with-no-output.

nolintlint - Validates //nolint directive formatting

Ensures linter suppressions are properly formatted and prevents malformed directives.

Fixed:

  • pkg/common/providers/ocmprovider/cluster.go - Fixed //nolint:gocyclo formatting (removed space).
  • pkg/common/concurrentviper/generated.go - Removed malformed // nolint directive. File is already excluded via config since generator is broken.
  • cmd/osde2e/provision/cmd.go - Removed unnecessary //nolint:gocyclo directive. Function complexity was reduced.

Impact

  • Clearer error contracts - No more ambiguous (nil, nil) returns
  • Better separation of concerns - Libraries report errors, applications interpret them
  • Explicit error handling - All errors are handled or intentionally discarded
  • Type-safe error wrapping - Using %w instead of %v for proper error chains

All changes maintain existing behavior while making error handling more explicit and maintainable.

…ode quality.

Ensures all error returns are explicitly handled or intentionally ignored to prevent silent failures.

**Fixed:**

- `internal/sanitizer/sanitizer.go` - Wrapped async audit logging in closure to explicitly discard error. Audit logging is fire-and-forget to avoid blocking sanitization.

Functions returning `(nil, nil)` are ambiguous - callers cannot distinguish between success-with-no-data and error states.

**Fixed:**

- `pkg/common/cluster/clusterutil.go` - Removed special handling of `ErrReserveFull`. Library code now reports all errors naturally using `%w` for proper error wrapping.
- `cmd/osde2e/provision/cmd.go` - Handles `ErrReserveFull` at application boundary where business logic belongs. Treats "reserve full" as success, all other errors propagate.
- `pkg/e2e/e2e.go` + `pkg/common/aws/s3.go` - Moved S3 bucket check to caller. Application layer decides whether to upload; library layer just uploads. Added TODO for future refactor to use
  dependency injection.
- `test/sdn_migration/sdn_migration_test.go` - Changed terraform destroy to return empty map instead of `(nil, nil)` to indicate success-with-no-output.

Ensures linter suppressions are properly formatted and prevents malformed directives.

**Fixed:**

- `pkg/common/providers/ocmprovider/cluster.go` - Fixed `//nolint:gocyclo` formatting (removed space).
- `pkg/common/concurrentviper/generated.go` - Removed malformed `// nolint` directive. File is already excluded via config since generator is broken.
- `cmd/osde2e/provision/cmd.go` - Removed unnecessary `//nolint:gocyclo` directive. Function complexity was reduced.

- **Clearer error contracts** - No more ambiguous (nil, nil) returns
- **Better separation of concerns** - Libraries report errors, applications interpret them
- **Explicit error handling** - All errors are handled or intentionally discarded
- **Type-safe error wrapping** - Using `%w` instead of `%v` for proper error chains

All changes maintain existing behavior while making error handling more explicit and maintainable.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@christophermancini
Copy link
Contributor Author

/retest

@christophermancini
Copy link
Contributor Author

/test hypershift-pr-check

@christophermancini
Copy link
Contributor Author

/test hypershift-pr-check

@ritmun
Copy link
Contributor

ritmun commented Feb 24, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2026

@christophermancini: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@ritmun
Copy link
Contributor

ritmun commented Feb 24, 2026

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christophermancini, ritmun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2026
@ritmun ritmun merged commit d445d0e into openshift:main Feb 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants