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

Fix issues reported by errcheck #285

Merged
merged 3 commits into from
Jan 13, 2022
Merged

Conversation

Danielius1922
Copy link
Member

No description provided.

@sonarcloud
Copy link

sonarcloud bot commented Jan 12, 2022

Please retry analysis of this Pull-Request directly on SonarCloud.

@Danielius1922 Danielius1922 force-pushed the adam/feature/errorCheck-2 branch 2 times, most recently from 0f2d78e to 9017ae0 Compare January 12, 2022 21:17
server.go Outdated
s := udp.NewServer(udp.WithMux(handler))
defer func() {
if err := l.Close(); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't sure how to handle this, so there are three suggestions in this file

  1. add public Error method to tcp/udp.Server that handles errors
  2. use log.Printf
  3. ignore it

@jkralik what do you think, which way is the best?

Copy link
Member

Choose a reason for hiding this comment

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

you can handle this error at line 32. If s.Serve returns nil then you use error from l.Close

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess that's alright, we can ignore the Close error if the Serve call fails.

@@ -36,8 +35,8 @@ func (m *inactivityMonitor) LastActivity() time.Time {
return time.Time{}
}

func CloseClientConn(cc ClientConn) {
cc.Close()
func CloseClientConn(cc ClientConn) error {
Copy link
Member Author

Choose a reason for hiding this comment

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

API change, but adding error output shouldn't break most code (only cases I can think of is assigning to function pointer with previous signature or adhering to interface).

Copy link
Member

Choose a reason for hiding this comment

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

This is concrete default implemenetation. So for default, we can ignore the error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, func CloseClientConn is not used anywhere. Do we need it at all? The caller can call Close on CloseClientConn directly without this wrapper.

udp/message/getmid.go Outdated Show resolved Hide resolved
@Danielius1922 Danielius1922 force-pushed the adam/feature/errorCheck-2 branch 2 times, most recently from 5828baa to 4fd49ff Compare January 13, 2022 12:28
@codecov-commenter
Copy link

Codecov Report

Merging #285 (4fd49ff) into master (fb5b479) will decrease coverage by 0.20%.
The diff coverage is 54.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
- Coverage   63.82%   63.61%   -0.21%     
==========================================
  Files          76       76              
  Lines        5708     5755      +47     
==========================================
+ Hits         3643     3661      +18     
- Misses       1688     1705      +17     
- Partials      377      389      +12     
Impacted Files Coverage Δ
net/blockwise/blockwise.go 67.99% <0.00%> (-0.14%) ⬇️
net/connUDP.go 60.69% <0.00%> (-0.94%) ⬇️
net/monitor/inactivity/inactivitymonitor.go 78.26% <0.00%> (ø)
server.go 0.00% <0.00%> (ø)
tcp/server.go 80.12% <0.00%> (-1.01%) ⬇️
udp/server.go 81.50% <54.54%> (-2.88%) ⬇️
udp/client/clientconn.go 73.18% <60.00%> (-0.53%) ⬇️
udp/message/getmid.go 80.00% <60.00%> (-20.00%) ⬇️
udp/client/container.go 93.54% <75.00%> (ø)
udp/client.go 84.87% <79.16%> (+0.05%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb5b479...4fd49ff. Read the comment docs.

@sonarcloud
Copy link

sonarcloud bot commented Jan 13, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

53.9% 53.9% Coverage
17.6% 17.6% Duplication

@Danielius1922 Danielius1922 merged commit 073d2c2 into master Jan 13, 2022
@Danielius1922 Danielius1922 deleted the adam/feature/errorCheck-2 branch January 13, 2022 15:10
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.

None yet

3 participants