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 linter errors #188

Merged

Conversation

ns-jsattler
Copy link
Contributor

Just noticed that you are running golangci-lint run --out-format=github-actions --enable=golint,bodyclose,gosec,whitespace as part of the CI.

I don't necessarily agree with errors being ignored, but I wanted to just get the lint to pass.

List of lint issues this PR resolves.

::error file=cmd/sriov/main.go,line=115,col=17::Error return value of `ipam.ExecDel` is not checked (errcheck)
::error file=cmd/sriov/main.go,line=170,col=28::Error return value of `utils.CleanCachedNetConf` is not checked (errcheck)
::error file=cmd/sriov/main.go,line=96,col=18::Error return value of `sm.ReleaseVF` is not checked (errcheck)
::error file=pkg/config/config.go,line=90::unnecessary leading newline (whitespace)
::error file=pkg/config/config_suite_test.go,line=28,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)
::error file=pkg/sriov/sriov.go,line=210::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=36,col=2::`lm` is unused (structcheck)
::error file=pkg/sriov/sriov.go,line=220::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=271::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=380::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov_suite_test.go,line=28,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)
::error file=pkg/sriov/sriov_test.go,line=213,col=6::type `mockPciUtils` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=218,col=25::func `(*mockPciUtils).getPciAddress` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=239,col=25::func `(*mockPciUtils).getSriovNumVfs` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=260,col=25::func `(*mockPciUtils).getVFLinkNamesFromVFID` is unused (unused)
::error file=pkg/utils/testing.go,line=76,col=16::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/testing.go,line=92::unnecessary leading newline (whitespace)
::error file=pkg/utils/testing.go,line=94,col=13::G306: Expect WriteFile permissions to be 0600 or less (gosec)
::error file=pkg/utils/utils.go,line=130,col=12::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/utils.go,line=132,col=11::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/utils_suite_test.go,line=22,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)

Just noticed that you are running `golangci-lint run --out-format=github-actions --enable=golint,bodyclose,gosec,whitespace` as part of the CI.

I don't necessarily agree with errors being ignored, but I wanted to just get the lint to pass.

List of lint issues this PR resolves.
```
::error file=cmd/sriov/main.go,line=115,col=17::Error return value of `ipam.ExecDel` is not checked (errcheck)
::error file=cmd/sriov/main.go,line=170,col=28::Error return value of `utils.CleanCachedNetConf` is not checked (errcheck)
::error file=cmd/sriov/main.go,line=96,col=18::Error return value of `sm.ReleaseVF` is not checked (errcheck)
::error file=pkg/config/config.go,line=90::unnecessary leading newline (whitespace)
::error file=pkg/config/config_suite_test.go,line=28,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)
::error file=pkg/sriov/sriov.go,line=210::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=36,col=2::`lm` is unused (structcheck)
::error file=pkg/sriov/sriov.go,line=220::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=271::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov.go,line=380::unnecessary leading newline (whitespace)
::error file=pkg/sriov/sriov_suite_test.go,line=28,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)
::error file=pkg/sriov/sriov_test.go,line=213,col=6::type `mockPciUtils` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=218,col=25::func `(*mockPciUtils).getPciAddress` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=239,col=25::func `(*mockPciUtils).getSriovNumVfs` is unused (unused)
::error file=pkg/sriov/sriov_test.go,line=260,col=25::func `(*mockPciUtils).getVFLinkNamesFromVFID` is unused (unused)
::error file=pkg/utils/testing.go,line=76,col=16::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/testing.go,line=92::unnecessary leading newline (whitespace)
::error file=pkg/utils/testing.go,line=94,col=13::G306: Expect WriteFile permissions to be 0600 or less (gosec)
::error file=pkg/utils/utils.go,line=130,col=12::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/utils.go,line=132,col=11::ineffectual assignment to err (ineffassign)
::error file=pkg/utils/utils_suite_test.go,line=22,col=2::S1021: should merge variable declaration with assignment on next line (gosimple)
```
@ns-jsattler
Copy link
Contributor Author

Let me know if you would like me to fix the ignored errors. I was just trying to do as little changes as possible for this PR.

@@ -209,76 +209,6 @@ func (_m *MockNetlinkManager) LinkSetVfState(_a0 netlink.Link, _a1 int, _a2 uint
return r0
}

// mockPciUtils is an autogenerated mock type for the mockPciUtils type
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems we are not really using this mock in sriov tests, I presume it is safe to delete.
@martinkennelly @adrianchiris wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I did not realize that mockery created that file. So I removed this change for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see its not being used so should be deleted.

Sorry I did not notice that mockery created that file.  So removing my changes.
@ns-jsattler ns-jsattler requested a review from zshi-redhat July 7, 2021 15:03
@adrianchiris
Copy link
Contributor

final issue is : type mockPciUtils is unused (unused) then we can merge and have linter test green.

this is not being used today. and if its needed in the future it should go to its own mock file to avoid mixing with the actual (non auto generated) tests.

This reverts commit ff9cd75.
@ns-jsattler
Copy link
Contributor Author

I removed it again. For some reason I can not run the tests locally. So I was not able to confirm the tests are working but I am sure CI will tell us if it creates a problem.

If you do redo the mock in the future could you put the information and command on creating the mock file in a generate.go file?

@adrianchiris
Copy link
Contributor

If you do redo the mock in the future could you put the information and command on creating the mock file in a generate.go file

yes autogenerated files usually have comments informing about the tool thats used to generate (e.g mockery)

Copy link
Contributor

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

LGTM ! thank you for your contribution

@adrianchiris
Copy link
Contributor

commit messages are abit off, as they should just contain informative information about the changes performed.
i will squash, and reword it before merging.

@adrianchiris adrianchiris merged commit b790ad3 into k8snetworkplumbingwg:master Jul 13, 2021
MichalGuzieniuk pushed a commit to MichalGuzieniuk/sriov-cni that referenced this pull request Sep 6, 2021
golangci-lint which runs as part of CI reports errors. This commit fixes those errors.
jingczhang pushed a commit to nokia/sriov-cni that referenced this pull request Jul 7, 2022
golangci-lint which runs as part of CI reports errors. This commit fixes those errors.
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.

3 participants