Skip to content

openapi: Scope.DeclaredAt, Scope.ModelAt and loops.into are called only from tests #983

Closed

Description

@OmarAlJarrah

Problem

Three methods exist for their tests. No production code calls them:

  • resolve.Scope.DeclaredAt and resolve.Scope.ModelAt, each a one-line forward to Locate(pointer).Declared() and Locate(pointer).Model(), called from 19 test lines;
  • load.loops.into, a wrapper over loops.read that drops its second result, called from 11 test lines.

Production reaches the same answers through Locate and read. Each forwarder carries a doc comment that holds reasoning the real method should hold (the mapping-value rule of #530 and #757 for DeclaredAt; the chain rule of #771 for into).

git grep -nE '\.(DeclaredAt|ModelAt|into)\(' -- '*.go' ':!*_test.go' finds no call; the same pattern over *_test.go finds 30.

Direction

A draft. The tests call Locate(pointer).Declared(), Locate(pointer).Model() and read, or a helper in the test file for into. The reasoning in the three doc comments moves to Location.Declared, Location.Model and loops.read, where the code is.

Out of scope

Other members that only tests call, each kept for a reason:

  • interface satisfiers, which a call through an interface hides from a use count;
  • defs.Reader.Reads, a work counter that the cost-bound tests read;
  • compile.Diags.Len and compile.Types.Len, accessors of the framework a second compiler will use. Decide whether they stay as API in their own issue if wanted;
  • openapi.DefaultStreamingMediaTypes and openapi.DefaultExtensionPromotions, part of the compiler's exported surface.

Priority: P4, rule 1. git grep -nE '\.(DeclaredAt|ModelAt|into)\(' -- '*.go' ':!*_test.go' → no matches (morphic @3a706a7b).

Activity

  1. added
    type:choreRefactor or cleanup, no behavior change
    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formats
    on Oct 19, 2026
  2. OmarAlJarrah commented on Oct 20, 2026

    @OmarAlJarrah
    MemberAuthor

    #1016 removes two of the three. load.loops, with into, went with the cycle check, and Scope.DeclaredAt went with the lookups the schema bindings replaced. resolve.Scope.ModelAt remains, still with no production caller: git grep -nE '\.ModelAt\(' -- '*.go' ':!*_test.go' gives no matches at e7d3c05.

  3. OmarAlJarrah commented on Oct 22, 2026

    @OmarAlJarrah
    MemberAuthor

    Two more members that only tests call, both package functions rather than methods:

    • fragment.Of (compilers/openapi/internal/fragment/fragment.go:51) percent-encodes a pointer into a $ref fragment, the inverse of fragment.Pointer. Only fragment_test.go calls it, to build round-trip inputs.
    • oas.Kinds (compilers/openapi/internal/oas/types.go:45) lists the rule table's kinds. Only minor_test.go and table_test.go call it.

    git grep -nE 'fragment\.Of\(|oas\.Kinds\(' -- '*.go' ':!*_test.go' → no matches (morphic @ff8330ba).

    The direction is the same as for the three above. Each moves into its tests, through an export_test.go where an external test package needs it, and any reasoning in its doc comment moves to the function the production code does call.

  4. OmarAlJarrah commented on Oct 22, 2026

    @OmarAlJarrah
    MemberAuthor

    One more member that only tests call: relation.dropped (compilers/openapi/internal/merge/typejudge.go:37), which reports whether the fold loses the second declaration's type. #1000 added it together with TestRelation_DroppedAndFlipped, and no production code has called it since. The fold decides what it drops from the relation itself.

    git grep -nE '\.dropped\(' -- '*.go' ':!*_test.go' → no matches; the same pattern over *_test.go finds the two assertions in typejudge_internal_test.go (morphic @4ca2dc90).

    Unlike the others, it has no doc-comment reasoning to move: the method and its two assertions go, and TestRelation_DroppedAndFlipped keeps its flipped checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P4Refactors, tests, CI, hostile-input hardening, cosmetic diagnostics, other formatstype:choreRefactor or cleanup, no behavior change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions