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 ginkgolinter and fix findings #126

Merged
merged 3 commits into from
Jan 10, 2024

Conversation

nunnatsa
Copy link
Contributor

@nunnatsa nunnatsa commented Jan 10, 2024

Description of the change

ginkgolinter finds bugs and enforces standards of using the ginkgo and gomega packages. See more details here:
https://github.com/nunnatsa/ginkgolinter

This PR enables the ginkgolinter in the .golangci.yml, and fixes all the new finding from running golangci-lint. It also sorts the enabled linter names for better readability.

Note: all the finding were auto fixed by running the ginkgolinter cli with the -fix flag.

While going over the changes, found several more issues:

First, the assertMetrics function in handler/instrumented_enqueue_object_test.go, wasn't really doing anything. The switch-case compared a pointer value to another pointer, so the no case was actually ever selected, because the addresses were not the same.

This PR also fixes that issue.

Then, this PR also improve the error handling in tests in two ways:
Replace this pattern:

err := someFuncRetOnlyErr()
Expect(err).ToNot(HaveOccurred()

With

Expect(someFuncRetOnlyErr()).To(Succeed())

Also, use the MatchError gomega matcher when checking errors.

Copy link

codecov bot commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2bc11dc) 81.03% compared to head (b85b9e7) 81.03%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #126   +/-   ##
=======================================
  Coverage   81.03%   81.03%           
=======================================
  Files          17       17           
  Lines         485      485           
=======================================
  Hits          393      393           
  Misses         82       82           
  Partials       10       10           

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

@ncdc
Copy link
Member

ncdc commented Jan 10, 2024

@nunnatsa thanks for the PR! Let's please coordinate - I have #125 in this space too

@nunnatsa
Copy link
Contributor Author

@nunnatsa thanks for the PR! Let's please coordinate - I have #125 in this space too

Hi. I'll need to rebase anyway, as #125 was merged.

But does the pr makes sense?

@ncdc
Copy link
Member

ncdc commented Jan 10, 2024

Yes, it does, thanks

ginkgolinter finds bugs and enforces standards of using the ginkgo and
gomega packages. See more details here:
https://github.com/nunnatsa/ginkgolinter

This PR enables the ginkgolinter in the .golangci.yml, and fixes all the
new finding from running golangci-lint.

Note: all the finding were auto fixed by running the ginkgolinter cli
with the `-fix` flag.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
The assertMetrics function in
handler/instrumented_enqueue_object_test.go, wasn't really doing
anything. The switch-case compared a pointer value to another pointer,
so the no case was actually ever selected, because the addresses were
not the same.

Tested with a debugger - no value were ever selected.

This commit fixes this test by selecting the value rather than the
address.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
Replace this patter:
```golang
err := someFuncRetOnlyErr()
Expect(err).ToNot(HaveOccurred()
```
With
```golang
Expect(someFuncRetOnlyErr()).To(Succeed())
```

Also, use the `MatchError` gomega matcher when checking errors.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
@nunnatsa
Copy link
Contributor Author

Yes, it does, thanks

Thanks @ncdc. Done.

@ncdc
Copy link
Member

ncdc commented Jan 10, 2024

Thanks, I'm afk for a bit, but will review when I'm back today

@ncdc ncdc merged commit db5035d into operator-framework:main Jan 10, 2024
6 checks passed
@nunnatsa nunnatsa deleted the add-ginkgolinter branch January 10, 2024 19:33
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