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

Enable all default golangci-lint linters and fix issues related #37

Merged
merged 13 commits into from
Dec 11, 2023

Conversation

Jdubrick
Copy link
Contributor

@Jdubrick Jdubrick commented Nov 29, 2023

What does this PR do?

This PR enables the default linters that were disabled in a prior issue and fixes all of the issues presented by the default linters.

Which issue(s) does this PR fix

resolves devfile/api#1302

PR acceptance criteria

  • Enable default linters
  • All issues reported by make lint are dealt with and make lint passes
  • All tests pass in make test

How to test changes / Special notes to the reviewer

You can test these changes by first running make lint to verify there are no more lint errors being reported. You can also run make test to ensure all unit tests also pass with the changes.

@openshift-ci openshift-ci bot requested review from elsony and thepetk November 29, 2023 20:57
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (719af19) 70.49% compared to head (ef3687d) 73.12%.

Files Patch % Lines
pkg/utils/detector.go 78.57% 2 Missing and 1 partial ⚠️
test/apis/utils.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
+ Coverage   70.49%   73.12%   +2.63%     
==========================================
  Files          11       11              
  Lines        1566     1563       -3     
==========================================
+ Hits         1104     1143      +39     
+ Misses        395      351      -44     
- Partials       67       69       +2     

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

Copy link
Contributor

@thepetk thepetk left a comment

Choose a reason for hiding this comment

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

In general it looks good to me :) It would be nice if we could add some test cases for the coverage report that is failing.

@Jdubrick
Copy link
Contributor Author

Jdubrick commented Dec 1, 2023

In general it looks good to me :) It would be nice if we could add some test cases for the coverage report that is failing.

Sounds good. Currently working on trying to increase code coverage for these failing portions, just have to familiarize myself with Go testing

@Jdubrick
Copy link
Contributor Author

Jdubrick commented Dec 5, 2023

Pushed some changes that increase coverage a little bit for the defer functions and some error cases in detector.go, still doesn't loook like it hits the same coverage as before but it's only different by 0.03% from this link. What are your thoughts @thepetk ?

@thepetk
Copy link
Contributor

thepetk commented Dec 5, 2023

Pushed some changes that increase coverage a little bit for the defer functions and some error cases in detector.go, still doesn't loook like it hits the same coverage as before but it's only different by 0.03% from this link. What are your thoughts @thepetk ?

Could you try to add some test cases for the DownloadDevfileTypesFromRegistry too?

pkg/utils/detector.go Fixed Show fixed Hide fixed
@Jdubrick
Copy link
Contributor Author

Jdubrick commented Dec 8, 2023

@thepetk I added more tests and was able to increase the patch code coverage as a result. From what I was reading online it seemed that a majority of people ignore the err that could arise from resp.Body.Close() as there isn't really anything you can do about it. In this case I can try and remove the err handling for the close, but then we get a potential problem warning from github, see above for reference to that. Once I reintroduced the error handling we dropped just below the 70% cutoff. What do you think should be the course of action?

Signed-off-by: Jordan Dubrick <[email protected]>
@Jdubrick
Copy link
Contributor Author

Jdubrick commented Dec 8, 2023

@thepetk I added more tests and was able to increase the patch code coverage as a result. From what I was reading online it seemed that a majority of people ignore the err that could arise from resp.Body.Close() as there isn't really anything you can do about it. In this case I can try and remove the err handling for the close, but then we get a potential problem warning from github, see above for reference to that. Once I reintroduced the error handling we dropped just below the 70% cutoff. What do you think should be the course of action?

Last commit fixes our issue as I was able to mock the function throwing an error.

@thepetk
Copy link
Contributor

thepetk commented Dec 8, 2023

@thepetk I added more tests and was able to increase the patch code coverage as a result. From what I was reading online it seemed that a majority of people ignore the err that could arise from resp.Body.Close() as there isn't really anything you can do about it. In this case I can try and remove the err handling for the close, but then we get a potential problem warning from github, see above for reference to that. Once I reintroduced the error handling we dropped just below the 70% cutoff. What do you think should be the course of action?

Last commit fixes our issue as I was able to mock the function throwing an error.

Very complicated failure from the codecov I have to say. I think the addition we make here with the separate functions will let us keep the coverage higher in the future, so is definitely a good addition.

Copy link
Contributor

@thepetk thepetk left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 8, 2023
Copy link

openshift-ci bot commented Dec 8, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Jdubrick, thepetk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Jdubrick Jdubrick merged commit 9ed7d09 into devfile:main Dec 11, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Alizer] Enable all default golangci-lint linters and fix errors reported
2 participants