diff --git a/cardinal/ecs/query.go b/cardinal/ecs/query.go index 814e3f899..d1e38b3c6 100644 --- a/cardinal/ecs/query.go +++ b/cardinal/ecs/query.go @@ -229,11 +229,9 @@ func validateQuery[Request any, Reply any]( } if !repValid || !reqValid { - return errors.New( - fmt.Sprintf( - "invalid query: %s: the Request and Reply generics must be both structs", - name, - ), + return fmt.Errorf( + "invalid query: %s: the Request and Reply generics must be both structs", + name, ) } return nil diff --git a/cardinal/ecs/world.go b/cardinal/ecs/world.go index 83437334c..b5ef230b2 100644 --- a/cardinal/ecs/world.go +++ b/cardinal/ecs/world.go @@ -237,9 +237,8 @@ func RegisterQuery[Request any, Reply any]( func (w *World) GetQueryByName(name string) (Query, error) { if q, ok := w.nameToQuery[name]; ok { return q, nil - } else { - return nil, fmt.Errorf("query with name %s not found", name) } + return nil, fmt.Errorf("query with name %s not found", name) } func (w *World) RegisterMessages(txs ...message.Message) error { @@ -649,8 +648,10 @@ func (w *World) RecoverFromChain(ctx context.Context) error { "be sure to use the `WithAdapter` option when creating the world") } if w.CurrentTick() > 0 { - return fmt.Errorf("world recovery should not occur in a world with existing state. please verify all " + - "state has been cleared before running recovery") + return fmt.Errorf( + "world recovery should not occur in a world with existing state. please verify all " + + "state has been cleared before running recovery", + ) } w.isRecovering = true diff --git a/cardinal/query_test.go b/cardinal/query_test.go index 820c0ef78..2f4bcf0d5 100644 --- a/cardinal/query_test.go +++ b/cardinal/query_test.go @@ -19,7 +19,10 @@ type QueryHealthResponse struct { IDs []cardinal.EntityID } -func handleQueryHealth(worldCtx cardinal.WorldContext, request *QueryHealthRequest) (*QueryHealthResponse, error) { +func handleQueryHealth( + worldCtx cardinal.WorldContext, + request *QueryHealthRequest, +) (*QueryHealthResponse, error) { q, err := worldCtx.NewSearch(cardinal.Exact(Health{})) if err != nil { return nil, err @@ -65,7 +68,14 @@ func TestNewQueryTypeWithEVMSupport(t *testing.T) { func TestQueryExample(t *testing.T) { world, _ := testutils.MakeWorldAndTicker(t) assert.NilError(t, cardinal.RegisterComponent[Health](world)) - assert.NilError(t, cardinal.RegisterQuery[QueryHealthRequest, QueryHealthResponse](world, "query_health", handleQueryHealth)) + assert.NilError( + t, + cardinal.RegisterQuery[QueryHealthRequest, QueryHealthResponse]( + world, + "query_health", + handleQueryHealth, + ), + ) worldCtx := testutils.WorldToWorldContext(world) ids, err := cardinal.CreateMany(worldCtx, 100, Health{}) diff --git a/cardinal/server/query.go b/cardinal/server/query.go index fd05e708a..bca38c13d 100644 --- a/cardinal/server/query.go +++ b/cardinal/server/query.go @@ -41,7 +41,7 @@ func (handler *Handler) registerQueryHandlerSwagger(api *untyped.API) error { return middleware.Error( http.StatusNotFound, fmt.Errorf("query %s not found", queryTypeString), - ), nil + ), nil //lint:ignore nilerr this is a middleware error that should 404 } bodyData, ok := mapStruct["queryBody"]