Skip to content

fix: resolve staticcheck SA5011 and prealloc lint errors#88

Merged
mchmarny merged 1 commit intoNVIDIA:mainfrom
yuanchen8911:fix/staticcheck-lint-errors
Feb 10, 2026
Merged

fix: resolve staticcheck SA5011 and prealloc lint errors#88
mchmarny merged 1 commit intoNVIDIA:mainfrom
yuanchen8911:fix/staticcheck-lint-errors

Conversation

@yuanchen8911
Copy link
Contributor

@yuanchen8911 yuanchen8911 commented Feb 10, 2026

Summary

Fix 34 pre-existing lint errors that cause CI failures on all PRs. The errors are blocking PR #80 #83 #87.

Changes

  • Add return after t.Fatal() in nil-check blocks across 6 test files to resolve 33 staticcheck SA5011 (possible nil pointer dereference) warnings
  • Preallocate allPaths slice in components_test.go to resolve 1 prealloc warning

Files

  • 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.Fatal stops test execution, so an explicit return is needed after the call to prevent SA5011 warnings. This is consistent with the existing pattern used elsewhere in the codebase.

Test plan

  • make test passes
  • make lint-go passes with 0 issues

@yuanchen8911 yuanchen8911 requested a review from a team as a code owner February 10, 2026 19:27
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>
@mchmarny mchmarny merged commit 5652b9e into NVIDIA:main Feb 10, 2026
5 checks passed
@yuanchen8911 yuanchen8911 mentioned this pull request Feb 10, 2026
15 tasks
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.

2 participants