From d5293ad01271b551d63f245477df88443f435c28 Mon Sep 17 00:00:00 2001 From: BrianChen <46628572+brianchennn@users.noreply.github.com> Date: Fri, 1 Dec 2023 23:07:26 +0800 Subject: [PATCH] style: fix naked return (#115) --- internal/sbi/consumer/am_policy.go | 4 ++-- internal/sbi/consumer/communication.go | 10 +++++----- internal/sbi/consumer/nf_mangement.go | 8 ++++---- internal/sbi/consumer/sm_context.go | 4 ++-- internal/sbi/consumer/subscriber_data_management.go | 10 +++++----- internal/sbi/consumer/ue_authentication.go | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/sbi/consumer/am_policy.go b/internal/sbi/consumer/am_policy.go index 4660a2f7..6dd4d480 100644 --- a/internal/sbi/consumer/am_policy.go +++ b/internal/sbi/consumer/am_policy.go @@ -115,11 +115,11 @@ func AMPolicyControlUpdate(ue *amf_context.AmfUe, updateRequest models.PolicyAss // TODO: Presence Reporting Area handling (TS 23.503 6.1.2.5, TS 23.501 5.6.11) // } } - return + return problemDetails, err } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem diff --git a/internal/sbi/consumer/communication.go b/internal/sbi/consumer/communication.go index 8f545afb..1970e1a5 100644 --- a/internal/sbi/consumer/communication.go +++ b/internal/sbi/consumer/communication.go @@ -139,7 +139,7 @@ func CreateUEContextRequest(ue *amf_context.AmfUe, ueContextCreateData models.Ue } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return ueContextCreatedData, problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -182,11 +182,11 @@ func ReleaseUEContextRequest(ue *amf_context.AmfUe, ngapCause models.NgApCause) } }() if localErr == nil { - return + return problemDetails, err } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -240,7 +240,7 @@ func UEContextTransferRequest( } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return ueContextTransferRspData, problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -274,7 +274,7 @@ func RegistrationStatusUpdate(ue *amf_context.AmfUe, request models.UeRegStatusU } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return regStatusTransferComplete, problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem diff --git a/internal/sbi/consumer/nf_mangement.go b/internal/sbi/consumer/nf_mangement.go index 1c506d06..f99c31a8 100644 --- a/internal/sbi/consumer/nf_mangement.go +++ b/internal/sbi/consumer/nf_mangement.go @@ -32,25 +32,25 @@ func BuildNFInstance(context *amf_context.AMFContext) (profile models.NfProfile, amfInfo := models.AmfInfo{} if len(context.ServedGuamiList) == 0 { err = fmt.Errorf("Gumai List is Empty in AMF") - return + return profile, err } regionId, setId, _, err1 := util.SeperateAmfId(context.ServedGuamiList[0].AmfId) if err1 != nil { err = err1 - return + return profile, err } amfInfo.AmfRegionId = regionId amfInfo.AmfSetId = setId amfInfo.GuamiList = &context.ServedGuamiList if len(context.SupportTaiLists) == 0 { err = fmt.Errorf("SupportTaiList is Empty in AMF") - return + return profile, err } amfInfo.TaiList = &context.SupportTaiLists profile.AmfInfo = &amfInfo if context.RegisterIPv4 == "" { err = fmt.Errorf("AMF Address is empty") - return + return profile, err } profile.Ipv4Addresses = append(profile.Ipv4Addresses, context.RegisterIPv4) service := []models.NfService{} diff --git a/internal/sbi/consumer/sm_context.go b/internal/sbi/consumer/sm_context.go index 3cfa459b..43204b55 100644 --- a/internal/sbi/consumer/sm_context.go +++ b/internal/sbi/consumer/sm_context.go @@ -147,7 +147,7 @@ func SendCreateSmContextRequest(ue *amf_context.AmfUe, smContext *amf_context.Sm } else if httpResponse != nil { if httpResponse.Status != err.Error() { err1 = err - return + return response, smContextRef, errorResponse, problemDetail, err1 } switch httpResponse.StatusCode { case 400, 403, 404, 500, 503, 504: @@ -451,7 +451,7 @@ func SendUpdateSmContextRequest(smContext *amf_context.SmContext, } else if httpResponse != nil { if httpResponse.Status != err.Error() { err1 = err - return + return response, errorResponse, problemDetail, err1 } switch httpResponse.StatusCode { case 400, 403, 404, 500, 503: diff --git a/internal/sbi/consumer/subscriber_data_management.go b/internal/sbi/consumer/subscriber_data_management.go index 5f961923..cf1a64e8 100644 --- a/internal/sbi/consumer/subscriber_data_management.go +++ b/internal/sbi/consumer/subscriber_data_management.go @@ -61,7 +61,7 @@ func SDMGetAmData(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -94,7 +94,7 @@ func SDMGetSmfSelectData(ue *amf_context.AmfUe) (problemDetails *models.ProblemD } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -159,11 +159,11 @@ func SDMSubscribe(ue *amf_context.AmfUe) (problemDetails *models.ProblemDetails, }() if localErr == nil { ue.SdmSubscriptionId = resSubscription.SubscriptionId - return + return problemDetails, err } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem @@ -215,7 +215,7 @@ func SDMGetSliceSelectionSubscriptionData(ue *amf_context.AmfUe) (problemDetails } else if httpResp != nil { if httpResp.Status != localErr.Error() { err = localErr - return + return problemDetails, err } problem := localErr.(openapi.GenericOpenAPIError).Model().(models.ProblemDetails) problemDetails = &problem diff --git a/internal/sbi/consumer/ue_authentication.go b/internal/sbi/consumer/ue_authentication.go index 5d08fb7f..6d41fb22 100644 --- a/internal/sbi/consumer/ue_authentication.go +++ b/internal/sbi/consumer/ue_authentication.go @@ -141,7 +141,7 @@ func SendEapAuthConfirmRequest(ue *amf_context.AmfUe, eapMsg nasType.EAPMessage) } else if httpResponse != nil { if httpResponse.Status != err.Error() { err1 = err - return + return response, problemDetails, err1 } switch httpResponse.StatusCode { case 400, 500: