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

Add staticcheck github action, resolve existing lint #254

Merged
merged 16 commits into from
Feb 29, 2024

Conversation

echlebek
Copy link
Contributor

This commit adds staticcheck as a github action and resolves existing issues flagged by staticcheck. I've grouped the issues into individual commits so that they can be considered independently. Most of the issues are deprecated uses of stdlib, unused errors, and ineffective branches or statements. But, there is one stylistic issue too that is more subjective.

staticcheck is a very conservative linter that has a focus on minimizing false positives. I've found that staticcheck has improved the quality of my own work, and has also made pull requests easier to evaluate.

Each issue is tagged with an identifier that can be consulted here: https://staticcheck.dev/docs/checks/

@echlebek echlebek requested a review from a team February 23, 2024 22:25
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 73.80%. Comparing base (8b26910) to head (5b987ff).

Files Patch % Lines
client/internal/mockserver.go 40.00% 2 Missing and 1 partial ⚠️
internal/certs.go 0.00% 2 Missing ⚠️
client/internal/packagessyncer.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #254      +/-   ##
==========================================
+ Coverage   73.74%   73.80%   +0.06%     
==========================================
  Files          25       25              
  Lines        1550     1550              
==========================================
+ Hits         1143     1144       +1     
+ Misses        297      295       -2     
- Partials      110      111       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@echlebek
Copy link
Contributor Author

Looks like one of the tests caught a data race somewhere, I'm assuming it's unrelated to this PR. I can probably fix it and make another PR for it.

Copy link
Member

@tigrannajaryan tigrannajaryan left a comment

Choose a reason for hiding this comment

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

Thanks for adding this.

client/httpclient_test.go Show resolved Hide resolved
client/internal/mockserver.go Show resolved Hide resolved
internal/retryafter_test.go Show resolved Hide resolved
internal/wsmessage.go Outdated Show resolved Hide resolved
@@ -79,19 +78,18 @@ func CreateServerTLSConfig(caCertPath, serverCertPath, serverKeyPath string) (*t
InsecureSkipVerify: true,
ClientCAs: caCertPool,
}
tlsConfig.BuildNameToCertificate()
Copy link
Member

Choose a reason for hiding this comment

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

Reading the deprecation notice this seems to be fine, but I am not entirely sure since the notice is a bit vague.
Are you able to verify that the example server that uses this functionality still works fine? The clients should be able to connect if everything is working correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can add a test with a TLS server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thoughts on using #202?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah #202 will need to be updated, it has conflicts. I don't think you need to add a test as part of this particular PR. If you can confirm by running the examples manually that they still work we should be good and can merge this PR.

Copy link
Member

Choose a reason for hiding this comment

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

make run-examples should build and run the example server and agent and if you go to http://localhost:4321/ you should be able to see a connected agent.

image

Click on it, scroll down and ensure you see it connected using a client certificate, e.g.:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verified that the client certificate is shown on this page. Thanks for the instructions!

image

@echlebek
Copy link
Contributor Author

As an aside, I tried to fix the data race in the example, but architecturally it's actually a bit difficult to do. The Wait() on the command is causing a race when other bits of the system write, and it won't be a simple fix unfortunately. Just thought I'd mention my findings.

@tigrannajaryan
Copy link
Member

As an aside, I tried to fix the data race in the example, but architecturally it's actually a bit difficult to do. The Wait() on the command is causing a race when other bits of the system write, and it won't be a simple fix unfortunately. Just thought I'd mention my findings.

Can you please create an issue and describe your findings so that we can fix it later?

@echlebek
Copy link
Contributor Author

Filed #256

@tigrannajaryan tigrannajaryan merged commit d986f58 into open-telemetry:main Feb 29, 2024
6 of 7 checks passed
@tigrannajaryan
Copy link
Member

Thank you for the PR @echlebek !

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