diff --git a/federationapi/routing/join.go b/federationapi/routing/join.go index c5a974065..6cadbd759 100644 --- a/federationapi/routing/join.go +++ b/federationapi/routing/join.go @@ -130,8 +130,8 @@ func MakeJoin( } // SendJoin implements the /send_join API -// TODO: Is there a way to break this function up in a way that actually -// makes sense? +// The make-join send-join dance makes much more sense as a single +// flow so the cyclomatic complexity is high: // nolint:gocyclo func SendJoin( httpReq *http.Request, diff --git a/federationsender/internal/perform.go b/federationsender/internal/perform.go index 62a50291e..161b689e1 100644 --- a/federationsender/internal/perform.go +++ b/federationsender/internal/perform.go @@ -49,7 +49,6 @@ func (r *FederationSenderInternalAPI) PerformJoin( // Try each server that we were provided until we land on one that // successfully completes the make-join send-join dance. - succeeded := false for _, serverName := range request.ServerNames { // Try to perform a make_join using the information supplied in the // request. @@ -138,20 +137,14 @@ func (r *FederationSenderInternalAPI) PerformJoin( } // We're all good. - succeeded = true - break + return nil } - if succeeded { - // Everything went to plan. - return nil - } else { - // We didn't complete a join for some reason. - return fmt.Errorf( - "failed to join user %q to room %q through %d server(s)", - request.UserID, request.RoomID, len(request.ServerNames), - ) - } + // If we reach here then we didn't complete a join for some reason. + return fmt.Errorf( + "failed to join user %q to room %q through %d server(s)", + request.UserID, request.RoomID, len(request.ServerNames), + ) } // PerformLeaveRequest implements api.FederationSenderInternalAPI