fix: resolve staticcheck SA5011 and prealloc lint errors#88
Merged
mchmarny merged 1 commit intoNVIDIA:mainfrom Feb 10, 2026
Merged
fix: resolve staticcheck SA5011 and prealloc lint errors#88mchmarny merged 1 commit intoNVIDIA:mainfrom
mchmarny merged 1 commit intoNVIDIA:mainfrom
Conversation
Add lint exclusion for SA5011 (possible nil pointer dereference) in test files. This is a known false positive — staticcheck doesn't recognize that t.Fatal() stops test execution via runtime.Goexit(), so it warns about nil dereferences after nil-check + t.Fatal blocks. The exclusion is scoped to test files only; SA5011 remains active in production code where it catches real bugs. Signed-off-by: Yuan Chen <yuanchen8911@gmail.com>
15d4c9b to
c92ccba
Compare
This was referenced Feb 10, 2026
mchmarny
approved these changes
Feb 10, 2026
15 tasks
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.
Summary
Fix 34 pre-existing lint errors that cause CI failures on all PRs. The errors are blocking PR #80 #83 #87.
Changes
returnaftert.Fatal()in nil-check blocks across 6 test files to resolve 33staticcheck SA5011(possible nil pointer dereference) warningsallPathsslice incomponents_test.goto resolve 1preallocwarningFiles
pkg/collector/systemd/systemd_test.go(2 fixes)pkg/component/base_test.go(1 fix)pkg/component/generic_test.go(3 fixes)pkg/component/testing_test.go(4 fixes)pkg/k8s/agent/deployer_test.go(2 fixes)pkg/oci/push_test.go(2 fixes)pkg/recipe/components_test.go(1 fix)Context
The linter does not recognize that
t.Fatalstops test execution, so an explicitreturnis needed after the call to prevent SA5011 warnings. This is consistent with the existing pattern used elsewhere in the codebase.Test plan
make testpassesmake lint-gopasses with 0 issues