Skip to content

all: remove redundant embedded-field references (staticcheck QF1008)#3694

Open
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/qf1008-embedded-fields
Open

all: remove redundant embedded-field references (staticcheck QF1008)#3694
Deln0r wants to merge 1 commit into
element-hq:mainfrom
Deln0r:lint/qf1008-embedded-fields

Conversation

@Deln0r
Copy link
Copy Markdown

@Deln0r Deln0r commented May 14, 2026

Summary

staticcheck QF1008 flags the form outer.Embedded.Field when Field is reachable via promotion from the embedded type. The selector reads more naturally as outer.Field, matches how the Go language already resolves the reference, and avoids drawing the reader's attention to a structural detail (which type happens to embed which) that is not relevant at the call site.

This PR rewrites 13 such call sites across:

  • appservice/consumers/roomserver.goevents[0].PDU.OriginServerTS()events[0].OriginServerTS()
  • clientapi/auth/login_token.gor.Login.Identifier.Xr.Identifier.X (×2)
  • federationapi/routing/devices.godev.DeviceKeys.KeyJSONdev.KeyJSON (×2)
  • federationapi/routing/{profile,query,send}_test.gocfg.FederationAPI.Matrix.SigningIdentity.ServerNamecfg.FederationAPI.Matrix.ServerName (×3)
  • roomserver/internal/api.gor.Inputer.Start()r.Start(), r.Inviter.ProcessInviteMembershipr.ProcessInviteMembership
  • roomserver/internal/perform/perform_invite.goq.Database.Xq.X (×2)
  • roomserver/state/state.goevent.PDU.EventID()event.EventID()
  • roomserver/types/headered_event.goh.PDU.ToHeaderedJSON()h.ToHeaderedJSON()
  • userapi/internal/user_api.goreq.Pusher.Xreq.X (×6 field reads/writes)

No behavior change: the referenced field is the same in each case, only the explicit traversal through the embedded type is dropped.

req.Pusher is intentionally left in place at the one site in PerformPusherSet where it's passed by value to UpsertPusher — that needs the embedded struct itself, not a field on it.

Test plan

  • go build ./... clean
  • go test ./roomserver/state/ ./roomserver/types/ passes (other affected packages need a live Postgres which I don't have locally; CI here is the better signal)
  • CI lint/test on this PR

Happy to split this up by package or drop individual hunks if any of them is sensitive.

staticcheck QF1008 flags the form `outer.Embedded.Field` when `Field` is
reachable via promotion from the embedded type. The selector reads more
naturally as `outer.Field`, matches how the Go language already resolves
the reference, and avoids drawing the reader's attention to a structural
detail (which type happens to embed which) that is not relevant at the
call site.

This change rewrites 13 such call sites across appservice, clientapi,
federationapi, roomserver and userapi. There is no behavior change: the
referenced field is the same in each case, only the explicit traversal
through the embedded type is dropped. The `req.Pusher` argument in
PerformPusherSet is intentionally left in place at the one site where it
is passed by value (UpsertPusher), since that needs the embedded struct
itself, not a field on it.

Spotted while looking for low-risk cleanups; happy to split this up or
drop individual hunks if any of them is sensitive.

Signed-off-by: Ian Chechin <ian00chechin@gmail.com>
@Deln0r Deln0r requested a review from a team as a code owner May 14, 2026 15:34
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

Successfully merging this pull request may close these issues.

1 participant