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 false positive when asserting an error pointer #184

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

nunnatsa
Copy link
Owner

Description

When using a pointer as an error, like in:

type myErr struct {
    code int
}

func (e *myErr) Error() string {
    ...
}

...
err = &myErr{code: 404}
Expect(err).To(HaveOccured())

ginkgolinter mistakely detects err as not error type.

This PR fixes this issue.

Fixes #183
Originally found here: containernetworking/cni#1148

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Refactoring

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added test case and related test data
  • Update the functional test

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I ran make goimports
  • I ran golangci-lint

When using a pointer as an error, like in:

```go
type myErr struct {
    code int
}

func (e *myErr) Error() string {
    ...
}

...
err = &myErr{code: 404}
Expect(err).To(HaveOccured())
```

ginkgolinter mistakely detects `err` as not error type.

This PR fixes this issue.
Copy link

Pull Request Test Coverage Report for Build 12272058134

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 77.561%

Totals Coverage Status
Change from base Build 12256570117: 0.02%
Covered Lines: 2188
Relevant Lines: 2821

💛 - Coveralls

@nunnatsa nunnatsa merged commit db3b623 into main Dec 11, 2024
1 check passed
@nunnatsa nunnatsa deleted the fix-false-positive branch December 11, 2024 08:07
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.

[BUG] False positive when asserting an error pointer
1 participant