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

Nilaway complains about generated mock #167

Open
marcelloh opened this issue Mar 24, 2024 · 2 comments
Open

Nilaway complains about generated mock #167

marcelloh opened this issue Mar 24, 2024 · 2 comments

Comments

@marcelloh
Copy link

Actual behavior A clear and concise description of what the bug is.
generated code

// GetMoreRecordsJSON mocks base method.
func (m *MockCountryRepositoryInterface) GetMoreRecordsJSON(arg0 map[string][]string) ([]byte, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "GetMoreRecordsJSON", arg0)
	ret0, _ := ret[0].([]byte)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

Nilaway message:

error: Potential nil panic detected. Observed nil flow from source to dereference point: 
        - gomock/controller.go:234:9: unassigned variable `rets` returned from `Call()` in position 0
        - mocks/countryRepoMocks.go:46:13: result 0 of `Call()` sliced into via the assignment(s):
                - `m.ctrl.Call(...)` to `ret` at mocks/countryRepoMocks.go:45:2

Expected behavior A clear and concise description of what you expected to
happen.

Perhaps: nilaway can skip mocks, or the mocks should test for 'ret' not being nil

To Reproduce Steps to reproduce the behavior

have a mock file where this is generated
run nilaway

nilaway ./... 

Additional Information

mockgen -version
v0.4.0

go version
go version go1.22.1 darwin/arm64

Triage Notes for the Maintainers

@JacobOaks
Copy link
Contributor

Hey @marcelloh, thanks for reporting this issue. We'll follow up with nilaway maintainers on the best approach to resolving this.

@marcelloh
Copy link
Author

Awesome (very pleased with nilaway & generating mocks)

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

No branches or pull requests

2 participants