Repository navigation
chore(lint): clear the lint findings from the client refresh change - #111
Merged
Merged
Conversation
The request helpers in these two test files hand back an *http.Response and close its body from t.Cleanup. bodyclose cannot see through the function boundary, so it blamed all eight callers instead. Only three were reported, because max-same-issues stops at three, which is why fixing the named lines would have surfaced the next batch on the following run. The helpers now return the response facts the tests actually assert on, and close the body where it is read. Nothing reads the body in any of these tests. anonRequest went through http.Client.Get, which has no context, so it now builds a request the same way its two siblings do. refreshThreshold was passed 5 minutes at every call site. Rather than delete the parameter, there is now a test that pins it: the same 50 minute session that is left alone under a 5 minute threshold gets rotated under a 60 minute one. Nothing proved the configured value was read before. errcheck runs with check-blank, so the bare _ = on json.Unmarshal was not enough on its own. It carries the reason now, matching the line above it.
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.
ci / Linthas been red on main since the client refresh work landed. This clears it. No behaviour changes, and one new test.The bodyclose hits were not what they looked like
CI named three
bodyclosefindings inclient_autorefresh_test.go. The helpers on those lines already close the body, fromt.Cleanup. bodyclose cannot see through a function that returns*http.Response, so it blames whoever calls it.Eight callers matched, not three. golangci-lint reports at most three of the same issue by default, so patching the named lines would have handed you the next three on the following run.
response_delivery_test.gohas the same helper shape and was sitting entirely behind that cap.The helpers now return the response facts the tests assert on, and close the body where it is read. Nothing in any of these tests ever touched the body.
noctx
anonRequestwent throughhttp.Client.Get, which carries no context. It builds its request the waycookieRequestandbearerRequestalready do.unparam, and a decision you may want to reverse
Every call site handed
refreshRoutera 5 minute threshold, so unparam called the parameter dead weight. Two ways to silence that: delete the parameter, or use it. This takes the second.There is now a test where the same 50 minute session that
SkipsWhenFarFromExpiryleaves alone gets rotated under a 60 minute threshold. That is worth slightly more than the lint fix, because nothing previously provedAutoRefreshConfig.Thresholdwas read at all. The test discriminates: hardcode the threshold insiderefreshRouterand it fails. If you would rather just drop the parameter, say so and it can go.errcheck
errcheckruns withcheck-blank, so a bare_ = json.Unmarshal(...)does not satisfy it. It carries its reason now, matching theio.ReadAllline directly above it.Verified
golangci-lint run ./...clean, and clean again under--max-same-issues=0 --max-issues-per-linter=0, so nothing is hiding behind the capgo test -raceon the touched tests