Skip to content

[refactor] Drop the pkg/query.QueryStore interface — one implementation, no mocks, no test usage #224

Description

@radimsem

Summary

QueryStore in pkg/query/engine.go:11 is an 8-method interface that has exactly one implementation (*store.Store) and is not mocked anywhere — not in production code, not in engine_test.go. The indirection earns nothing: Engine already imports pkg/store for *store.Node, *store.RankedNode, *store.DiffRecord in the interface signatures themselves.

Location

  • pkg/query/engine.go:11-27 — interface definition
  • pkg/query/engine.go:30,34 — only usage sites

Category

refactor (over-abstraction)

Impact

Low–Medium — small line count, but every new store method Engine consumes forces a triple-edit (store method, interface method, callsite). And the "make Engine testable" rationale is unrealized (engine_test.go uses the real store, not a mock).

Rationale

Verified: grep -rn QueryStore --include='*.go' returns three lines, all in engine.go. Karpathy lens: the interface adds indirection without enabling a single concrete use case. The simpler, more obvious code is the direct dependency.

Suggested direction

Change store QueryStorestore *store.Store in the Engine struct, update the NewEngine signature accordingly, delete the QueryStore interface block. If a test mock ever appears, reintroduce the interface then. ~20 line net deletion.

Filed by the nightly enhancement-scanner routine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auto-reviewFiled by the nightly enhancement-scanner routinerefactorCode refactoring / architecture cleanup

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions