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 two bugs: 173 and 174 #175

Merged
merged 2 commits into from
Nov 11, 2024
Merged

Fix two bugs: 173 and 174 #175

merged 2 commits into from
Nov 11, 2024

Conversation

nunnatsa
Copy link
Owner

Description

Bug fix: false positive for func returns error func

The linter triggers a warning for this case:

func errFunc() func() error {
	return func() error {
		return errors.New("error")
	}
}

var _ = Describe("test if issue 174 was solved", func() {
	It("should not trigger", func() {
		Eventually(errFunc()).Should(MatchError(ContainSubstring("error")))
	})
})

The linter fails to identify the actual value as error value.

Fixes #174

Fix bug: ginkgolinter ignores the Error() method

as in:

Expect(func() (int, error) {return 42, nil}()).Error().ToNot(HaveOccurred())

Fixes #173

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

The linter triggers a warning for this case:
```go
func errFunc() func() error {
	return func() error {
		return errors.New("error")
	}
}

var _ = Describe("test if issue 174 was solved", func() {
	It("should not trigger", func() {
		Eventually(errFunc()).Should(MatchError(ContainSubstring("error")))
	})
})
```

The linter fails to identify the actual value as error value.
as in:

```go
Expect(func() (int, error) {return 42, nil}()).Error().ToNot(HaveOccurred())
```
Copy link

Pull Request Test Coverage Report for Build 11781038284

Details

  • 19 of 29 (65.52%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 77.628%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/gomegahandler/dothandler.go 0 5 0.0%
internal/gomegahandler/namedhandler.go 0 5 0.0%
Totals Coverage Status
Change from base Build 11773770027: -0.05%
Covered Lines: 2193
Relevant Lines: 2825

💛 - Coveralls

@nunnatsa nunnatsa merged commit 608f078 into main Nov 11, 2024
1 check passed
@nunnatsa nunnatsa deleted the bug-fixes branch November 11, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant