all: remove redundant embedded-field references (staticcheck QF1008)#3694
Open
Deln0r wants to merge 1 commit into
Open
all: remove redundant embedded-field references (staticcheck QF1008)#3694Deln0r wants to merge 1 commit into
Deln0r wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
staticcheck
QF1008flags the formouter.Embedded.FieldwhenFieldis reachable via promotion from the embedded type. The selector reads more naturally asouter.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.go—events[0].PDU.OriginServerTS()→events[0].OriginServerTS()clientapi/auth/login_token.go—r.Login.Identifier.X→r.Identifier.X(×2)federationapi/routing/devices.go—dev.DeviceKeys.KeyJSON→dev.KeyJSON(×2)federationapi/routing/{profile,query,send}_test.go—cfg.FederationAPI.Matrix.SigningIdentity.ServerName→cfg.FederationAPI.Matrix.ServerName(×3)roomserver/internal/api.go—r.Inputer.Start()→r.Start(),r.Inviter.ProcessInviteMembership→r.ProcessInviteMembershiproomserver/internal/perform/perform_invite.go—q.Database.X→q.X(×2)roomserver/state/state.go—event.PDU.EventID()→event.EventID()roomserver/types/headered_event.go—h.PDU.ToHeaderedJSON()→h.ToHeaderedJSON()userapi/internal/user_api.go—req.Pusher.X→req.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.Pusheris intentionally left in place at the one site inPerformPusherSetwhere it's passed by value toUpsertPusher— that needs the embedded struct itself, not a field on it.Test plan
go build ./...cleango 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)Happy to split this up by package or drop individual hunks if any of them is sensitive.