Nilaway complains about generated mock
marcelloh opened this issue · 2 comments
marcelloh commented
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 commented
Hey @marcelloh, thanks for reporting this issue. We'll follow up with nilaway maintainers on the best approach to resolving this.
marcelloh commented
Awesome (very pleased with nilaway & generating mocks)