Skip to content

Commit

Permalink
chore: Enable 'unused' linter and fix reported problems (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainbourgeois authored Jan 17, 2024
1 parent 0a9ea77 commit 1f28f0e
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ linters:
- govet
- errcheck
- staticcheck
# - unused
- unused
# - gosimple
# - structcheck
- ineffassign
Expand Down
23 changes: 0 additions & 23 deletions consumer/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,6 @@ func setAltSmfProfile(smCtxt *amf_context.SmContext) error {
return fmt.Errorf("no alternate profiles available")
}

func refreshSmfProfiles(ue *amf_context.AmfUe, smCtxt *amf_context.SmContext, ignoreSmfId string) *[]models.NfProfile {
nrfUri := ue.ServingAMF.NrfUri
param := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{
ServiceNames: optional.NewInterface([]models.ServiceName{models.ServiceName_NSMF_PDUSESSION}),
Dnn: optional.NewString(smCtxt.Dnn()),
Snssais: optional.NewInterface(util.MarshToJsonString([]models.Snssai{smCtxt.Snssai()})),
}

result, err := SendSearchNFInstances(nrfUri, models.NfType_SMF, models.NfType_AMF, &param)
if err != nil {
return nil
}

var altSmfInst []models.NfProfile
// iterate over nf instances to ignore failed NF
for _, inst := range result.NfInstances {
if inst.NfInstanceId != ignoreSmfId {
altSmfInst = append(altSmfInst, inst)
}
}
return &altSmfInst
}

func SelectSmf(
ue *amf_context.AmfUe,
anType models.AccessType,
Expand Down
18 changes: 0 additions & 18 deletions gmm/message/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,24 +636,6 @@ func BuildRegistrationAccept(
return nas_security.Encode(ue, m)
}

func includeConfiguredNssaiCheck(ue *context.AmfUe) bool {
if len(ue.ConfiguredNssai) == 0 {
return false
}

registrationRequest := ue.RegistrationRequest
if registrationRequest.RequestedNSSAI == nil {
return true
}
if ue.NetworkSliceInfo != nil && len(ue.NetworkSliceInfo.RejectedNssaiInPlmn) != 0 {
return true
}
if registrationRequest.NetworkSlicingIndication != nil && registrationRequest.NetworkSlicingIndication.GetDCNI() == 1 {
return true
}
return false
}

func BuildStatus5GMM(cause uint8) ([]byte, error) {
m := nas.NewMessage()
m.GmmMessage = nas.NewGmmMessage()
Expand Down
21 changes: 0 additions & 21 deletions metrics/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,6 @@ func (writer Writer) PublishUeCtxtEvent(ctxt mi.CoreSubscriber, op mi.Subscriber
return nil
}

var nfInstanceId string

// initialised by context package
func SetNfInstanceId(s string) {
nfInstanceId = s
}

/*
func PublishMsgEvent(msgType mi.AmfMsgType) error {
smKafkaMsgEvt := mi.MetricEvent{EventType: mi.CMsgTypeEvt, MsgType: mi.CoreMsgType{MsgType: msgType.String(), SourceNfId: nfInstanceId}}
if msg, err := json.Marshal(smKafkaMsgEvt); err != nil {
return err
} else {
logger.KafkaLog.Debugf("publishing msg event[%s] ", msg)
StatWriter.SendMessage(msg)
}
return nil
}
*/

func (writer Writer) PublishNfStatusEvent(msgEvent mi.MetricEvent) error {
if msg, err := json.Marshal(msgEvent); err != nil {
return err
Expand Down
7 changes: 0 additions & 7 deletions producer/oam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ import (
"github.com/stretchr/testify/assert"
)

type TestCases struct {
amfContext context.AMFContext
amfue context.AmfUe
expectedUeFsmState string
description string
}

func init() {
if err := factory.InitConfigFactory("../amfTest/amfcfg.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
Expand Down
3 changes: 1 addition & 2 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ var RocUpdateConfigChannel chan bool
type (
// Config information.
Config struct {
amfcfg string
heartBeatTimer string
amfcfg string
}
)

Expand Down
2 changes: 0 additions & 2 deletions util/init_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/omec-project/amf/context"
"github.com/omec-project/amf/factory"
"github.com/omec-project/amf/logger"
"github.com/omec-project/amf/metrics"
"github.com/omec-project/nas/security"
"github.com/omec-project/openapi/models"
"github.com/omec-project/util/drsm"
Expand Down Expand Up @@ -45,7 +44,6 @@ func InitAmfContext(context *context.AMFContext) {
if context.NfId == "" {
context.NfId = uuid.New().String()
}
metrics.SetNfInstanceId(context.NfId)

if configuration.AmfName != "" {
context.Name = configuration.AmfName
Expand Down

0 comments on commit 1f28f0e

Please sign in to comment.