Fix staticcheck lint warnings#33
Merged
JamieMagee merged 1 commit intomainfrom Feb 10, 2026
Merged
Conversation
- Use tagged type switch in config.GetListOfStrings to avoid redundant type assertions (S1034) - Apply De Morgan's law to negated OR conditions in dialer and handler guard clauses (QF1001) - Replace if-else chain with switch on metricType in collector client (QF1003) - Discard unused return values in docker registry and cache tests (SA4006) - Add explicit return after t.Fatalf in OIDC credential test so staticcheck can see the nil guard (SA5011)
There was a problem hiding this comment.
Pull request overview
This PR reduces staticcheck noise across the proxy codebase by applying small refactors and test cleanups that preserve existing behavior while eliminating flagged patterns.
Changes:
- Refactors type checks / conditionals (tagged type switch, De Morgan rewrite, switch on metric type) to satisfy staticcheck quick-fix recommendations.
- Cleans up tests by discarding unused return values and adding an explicit
returnaftert.Fatalfso staticcheck can prove control flow. - Minor readability improvements in request guard clauses and dialer network-type validation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/oidc/oidc_credential_test.go | Adds an explicit return after t.Fatalf to satisfy SA5011 flow analysis. |
| internal/metrics/collector_client.go | Replaces an if/else chain with a switch when populating metric payload fields (QF1003). |
| internal/handlers/python_index.go | Applies De Morgan rewrite in handler credential matching guard (QF1001). |
| internal/handlers/nuget_feed.go | Applies De Morgan rewrite in handler credential matching guard (QF1001). |
| internal/handlers/maven_repository.go | Applies De Morgan rewrite in handler credential matching guard (QF1001). |
| internal/handlers/goproxy_server_handler.go | Applies De Morgan rewrite in handler credential matching guard (QF1001). |
| internal/handlers/docker_registry_test.go | Discards unused returned req values in tests where they are overwritten (SA4006). |
| internal/dialer/dialer.go | Rewrites negated disjunction to conjunction for readability (QF1001). |
| internal/config/config.go | Uses a tagged type switch to avoid repeated type assertions (S1034). |
| internal/cache/handlers_test.go | Avoids assigning unused return value from OnResponse (SA4006). |
Comments suppressed due to low confidence (1)
internal/config/config.go:71
- In GetListOfStrings, the local variable named
stringsshadows the importedstringspackage in this file, which makes the code harder to read and can lead to confusion if additionalstrings.*calls are added later. Consider renaming the slice to something likeresult/out/list.
strings := make([]string, len(val))
for i, v := range val {
if str, ok := v.(string); ok {
strings[i] = str
}
}
return strings
truggeri
approved these changes
Feb 10, 2026
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.
Fixes 18 of the 24 staticcheck warnings reported by
golangci-lint run --enable-only staticcheck.What changed:
config.GetListOfStringsnow uses a tagged type switch (switch val := value.(type)) instead of switching on the type and then repeating the assertion inside each case.!(a || b)with!a && !b(De Morgan's law) in the dialer and four handler guard clauses. Same logic, easier to read.switchonmetricTypein the metrics collector client._, _) in docker registry and cache tests where the returnedreq/respwas immediately overwritten.returnaftert.Fatalfin the OIDC credential test so staticcheck can proveactualis non-nil past that point.Not included:
The remaining 6 warnings are SA1019 (deprecated
aws-sdk-gov1 imports in the docker registry handler). Migrating toaws-sdk-go-v2changes the API surface and deserves its own PR.