Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add missing resp.Body.Close() #260

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

alexandear
Copy link
Contributor

The PR adds missing response body closing and enables bodyclose linter.

The code

defer func(body io.ReadCloser) {
	_ = body.Close()
}(resp.Body)

is simplified to

defer func() {
	_ = resp.Body.Close()
}()

to workaround bodyclose false positive:

internal/webui/net.go:51:23: response body must be closed (bodyclose)
        resp, err := http.Get(BaseURL)
                             ^

Copy link

codecov bot commented Nov 8, 2024

Bundle Report

Bundle size has no change ✅

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #260      +/-   ##
==========================================
- Coverage   91.77%   91.75%   -0.03%     
==========================================
  Files          86       86              
  Lines        4793     4793              
  Branches      241      241              
==========================================
- Hits         4399     4398       -1     
- Misses        313      314       +1     
  Partials       81       81              
Flag Coverage Δ
integration 65.91% <ø> (-0.03%) ⬇️
ui 91.06% <ø> (ø)
unit 40.69% <100.00%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

📢 Thoughts on this report? Let us know!

Copy link
Owner

@Zxilly Zxilly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@Zxilly Zxilly merged commit d4c9783 into Zxilly:master Nov 8, 2024
35 checks passed
@alexandear alexandear deleted the test/fix-bodyclose branch November 9, 2024 06:12
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