chore: enable errcheck, nolintlint, and nilnil linters#3122
Merged
ritmun merged 2 commits intoopenshift:mainfrom Feb 24, 2026
Merged
chore: enable errcheck, nolintlint, and nilnil linters#3122ritmun merged 2 commits intoopenshift:mainfrom
ritmun merged 2 commits intoopenshift:mainfrom
Conversation
…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>
a5c5a1d to
d9ecb0e
Compare
Contributor
Author
|
/retest |
Contributor
Author
|
/test hypershift-pr-check |
ritmun
reviewed
Feb 23, 2026
Contributor
Author
|
/test hypershift-pr-check |
Contributor
|
/lgtm |
Contributor
|
@christophermancini: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
Contributor
|
/approve |
Contributor
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofErrReserveFull. Library code now reports all errors naturally using%wfor proper error wrapping.cmd/osde2e/provision/cmd.go- HandlesErrReserveFullat 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 usedependency 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:gocycloformatting (removed space).pkg/common/concurrentviper/generated.go- Removed malformed// nolintdirective. File is already excluded via config since generator is broken.cmd/osde2e/provision/cmd.go- Removed unnecessary//nolint:gocyclodirective. Function complexity was reduced.Impact
%winstead of%vfor proper error chainsAll changes maintain existing behavior while making error handling more explicit and maintainable.