Skip to content

Commit

Permalink
Updates related to golangci (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Arrobo, Gabriel <[email protected]>
  • Loading branch information
gab-arrobo authored Oct 23, 2024
1 parent 2a4923f commit cd83b39
Show file tree
Hide file tree
Showing 201 changed files with 230 additions and 565 deletions.
45 changes: 17 additions & 28 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-FileCopyrightText: 2024 Intel Corporation
# Copyright 2019 free5GC.org
#
# SPDX-License-Identifier: Apache-2.0
#

# This file contains all available configuration options
# with their default values.
Expand All @@ -14,7 +13,7 @@ run:
# exit code when at least one issue was found, default is 1
issues-exit-code: 1
# include test files or not, default is true
tests: false
tests: true
# list of build tags, all linters use it. Default is empty list.
build-tags:
# which dirs to skip: issues from them won't be reported;
Expand All @@ -24,24 +23,9 @@ run:
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- nasType
- nasMessage
# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- "api_.*\\.go$"
- "model_.*\\.go$"
- "routers.go"
- "client.go"
- "configuration.go"
- "nas.go"
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
Expand All @@ -57,7 +41,7 @@ run:
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
Expand Down Expand Up @@ -140,10 +124,14 @@ linters-settings:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks:
- argument
- case
- condition
- operation
- return
- assign
gomodguard:
allowed:
modules: # List of allowed modules
Expand All @@ -161,8 +149,6 @@ linters-settings:
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
govet:
# report about shadowed variables
check-shadowing: true
# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand Down Expand Up @@ -210,14 +196,17 @@ linters-settings:
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
misspell:
#locale: US
ignore-words:
custom:
# Each custom linter should have a unique name.

linters:
enable:
- gofmt
- govet
- errcheck
# - errcheck
- staticcheck
- unused
- gosimple
Expand All @@ -235,9 +224,9 @@ linters:
- gci
- misspell
- gofumpt
- whitespace
# - whitespace
# - unconvert
- predeclared
# - predeclared
- noctx
- dogsled
- asciicheck
Expand Down
10 changes: 5 additions & 5 deletions nas.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (a *Message) PlainNasDecode(byteArray *[]byte) error {
case nasMessage.Epd5GSSessionManagementMessage:
return a.GsmMessageDecode(byteArray)
}
return fmt.Errorf("extended Protocol Discriminator[%d] is not allowed in Nas Message Deocde", epd)
return fmt.Errorf("extended Protocol Discriminator[%d] is not allowed in Nas Message Decode", epd)
}

func (a *Message) PlainNasEncode() ([]byte, error) {
Expand Down Expand Up @@ -288,7 +288,7 @@ func (a *Message) GmmMessageDecode(byteArray *[]byte) error {
a.GmmMessage.DLNASTransport = nasMessage.NewDLNASTransport(MsgTypeDLNASTransport)
a.GmmMessage.DecodeDLNASTransport(byteArray)
default:
return fmt.Errorf("NAS decode Fail: MsgType[%d] doesn't exist in GMM Message", a.GmmMessage.GmmHeader.GetMessageType())
return fmt.Errorf("NAS decode fail: MsgType[%d] does not exist in GMM Message", a.GmmMessage.GmmHeader.GetMessageType())
}
return nil
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func (a *Message) GmmMessageEncode(buffer *bytes.Buffer) error {
case MsgTypeDLNASTransport:
a.GmmMessage.EncodeDLNASTransport(buffer)
default:
return fmt.Errorf("NAS Encode Fail: MsgType[%d] doesn't exist in GMM Message", a.GmmMessage.GmmHeader.GetMessageType())
return fmt.Errorf("NAS encode fail: MsgType[%d] does not exist in GMM Message", a.GmmMessage.GmmHeader.GetMessageType())
}
return nil
}
Expand Down Expand Up @@ -450,7 +450,7 @@ func (a *Message) GsmMessageDecode(byteArray *[]byte) error {
a.GsmMessage.Status5GSM = nasMessage.NewStatus5GSM(MsgTypeStatus5GSM)
a.GsmMessage.DecodeStatus5GSM(byteArray)
default:
return fmt.Errorf("NAS Decode Fail: MsgType[%d] doesn't exist in GSM Message", a.GsmMessage.GsmHeader.GetMessageType())
return fmt.Errorf("NAS decode fail: MsgType[%d] does not exist in GSM Message", a.GsmMessage.GsmHeader.GetMessageType())
}
return nil
}
Expand Down Expand Up @@ -490,7 +490,7 @@ func (a *Message) GsmMessageEncode(buffer *bytes.Buffer) error {
case MsgTypeStatus5GSM:
a.GsmMessage.EncodeStatus5GSM(buffer)
default:
return fmt.Errorf("NAS Encode Fail: MsgType[%d] doesn't exist in GSM Message", a.GsmMessage.GsmHeader.GetMessageType())
return fmt.Errorf("NAS encode fail: MsgType[%d] does not exist in GSM Message", a.GsmMessage.GsmHeader.GetMessageType())
}
return nil
}
24 changes: 11 additions & 13 deletions nasMessage/NAS_AuthenticationFailure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ package nasMessage_test

import (
"bytes"
"reflect"
"testing"

"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"reflect"

"github.com/stretchr/testify/assert"
)

type nasMessageAuthenticationFailureData struct {
inExtendedProtocolDiscriminator uint8
inSecurityHeader uint8
inSpareHalfOctet uint8
inAuthenticationFailureMessageIdentity uint8
in5GMMCause nasType.Cause5GMM
inAuthenticationFailureParameter nasType.AuthenticationFailureParameter
inExtendedProtocolDiscriminator uint8
inSecurityHeader uint8
inSpareHalfOctet uint8
inAuthenticationFailureMessageIdentity uint8
in5GMMCause nasType.Cause5GMM
inAuthenticationFailureParameter nasType.AuthenticationFailureParameter
}

var nasMessageAuthenticationFailureTable = []nasMessageAuthenticationFailureData{
Expand All @@ -33,16 +31,16 @@ var nasMessageAuthenticationFailureTable = []nasMessageAuthenticationFailureData
inSecurityHeader: 0x08,
inSpareHalfOctet: 0x01,
inAuthenticationFailureMessageIdentity: 0x01,
in5GMMCause: nasType.Cause5GMM{0, 0xff},
inAuthenticationFailureParameter: nasType.AuthenticationFailureParameter{nasMessage.AuthenticationFailureAuthenticationFailureParameterType, 14, [14]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
in5GMMCause: nasType.Cause5GMM{Iei: 0, Octet: 0xff},
inAuthenticationFailureParameter: nasType.AuthenticationFailureParameter{Iei: nasMessage.AuthenticationFailureAuthenticationFailureParameterType, Len: 14, Octet: [14]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
},
{
inExtendedProtocolDiscriminator: 0x01,
inSecurityHeader: 0x08,
inSpareHalfOctet: 0x01,
inAuthenticationFailureMessageIdentity: 0x01,
in5GMMCause: nasType.Cause5GMM{0, 0xff},
inAuthenticationFailureParameter: nasType.AuthenticationFailureParameter{0x30, 14, [14]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
in5GMMCause: nasType.Cause5GMM{Iei: 0, Octet: 0xff},
inAuthenticationFailureParameter: nasType.AuthenticationFailureParameter{Iei: 0x30, Len: 14, Octet: [14]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
},
}

Expand Down
6 changes: 2 additions & 4 deletions nasMessage/NAS_AuthenticationReject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ package nasMessage_test

import (
"bytes"
"reflect"
"testing"

"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"reflect"

"github.com/stretchr/testify/assert"
)

Expand All @@ -32,7 +30,7 @@ var nasMessageAuthenticationRejectTable = []nasMessageAuthenticationRejectData{
inSecurityHeader: 0x01,
inSpareHalfOctet: 0x01,
inAuthenticationRejectMessageIdentity: 0x01,
inEAPMessage: nasType.EAPMessage{nasMessage.AuthenticationRejectEAPMessageType, 2, []byte{0x00, 0x00}},
inEAPMessage: nasType.EAPMessage{Iei: nasMessage.AuthenticationRejectEAPMessageType, Len: 2, Buffer: []byte{0x00, 0x00}},
},
}

Expand Down
12 changes: 5 additions & 7 deletions nasMessage/NAS_AuthenticationRequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ package nasMessage_test

import (
"bytes"
"reflect"
"testing"

"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"reflect"

"github.com/stretchr/testify/assert"
)

Expand All @@ -41,10 +39,10 @@ var nasMessageAuthenticationRequestTable = []nasMessageAuthenticationRequestData
inTsc: 0x01,
inNASKeySetIdentifier: 0x07,
inSpareHalfOctet2: 0x07,
inABBA: nasType.ABBA{0, 2, []byte{0x00, 0x00}},
inAuthenticationParameterRAND: nasType.AuthenticationParameterRAND{nasMessage.AuthenticationRequestAuthenticationParameterRANDType, [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inAuthenticationParameterAUTN: nasType.AuthenticationParameterAUTN{nasMessage.AuthenticationRequestAuthenticationParameterAUTNType, 16, [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inEAPMessage: nasType.EAPMessage{nasMessage.AuthenticationRequestEAPMessageType, 2, []byte{0x00, 0x00}},
inABBA: nasType.ABBA{Iei: 0, Len: 2, Buffer: []byte{0x00, 0x00}},
inAuthenticationParameterRAND: nasType.AuthenticationParameterRAND{Iei: nasMessage.AuthenticationRequestAuthenticationParameterRANDType, Octet: [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inAuthenticationParameterAUTN: nasType.AuthenticationParameterAUTN{Iei: nasMessage.AuthenticationRequestAuthenticationParameterAUTNType, Len: 16, Octet: [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inEAPMessage: nasType.EAPMessage{Iei: nasMessage.AuthenticationRequestEAPMessageType, Len: 2, Buffer: []byte{0x00, 0x00}},
},
}

Expand Down
12 changes: 4 additions & 8 deletions nasMessage/NAS_AuthenticationResponse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ package nasMessage_test

import (
"bytes"

"github.com/omec-project/nas/logger"

"reflect"
"testing"

"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"reflect"

"github.com/stretchr/testify/assert"
)

Expand All @@ -35,8 +31,8 @@ var nasMessageAuthenticationResponseTable = []nasMessageAuthenticationResponseDa
inSecurityHeader: 0x08,
inSpareHalfOctet: 0x01,
inAuthenticationResponseMessageIdentity: 0x01,
inAuthenticationResponseParameter: nasType.AuthenticationResponseParameter{nasMessage.AuthenticationResponseAuthenticationResponseParameterType, 16, [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inEAPMessage: nasType.EAPMessage{nasMessage.AuthenticationResponseEAPMessageType, 2, []uint8{0x01, 0x01}},
inAuthenticationResponseParameter: nasType.AuthenticationResponseParameter{Iei: nasMessage.AuthenticationResponseAuthenticationResponseParameterType, Len: 16, Octet: [16]uint8{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
inEAPMessage: nasType.EAPMessage{Iei: nasMessage.AuthenticationResponseEAPMessageType, Len: 2, Buffer: []uint8{0x01, 0x01}},
},
}

Expand Down
20 changes: 10 additions & 10 deletions nasMessage/NAS_AuthenticationResult_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"github.com/stretchr/testify/assert"
)

Expand All @@ -35,14 +34,16 @@ var aBBATestData = []nasType.ABBA{
}

var nasMessageAuthenticationResultTable = []nasMessageAuthenticationResultData{
{inExtendedProtocolDiscriminator: nasMessage.Epd5GSSessionManagementMessage,
inSecurityHeaderType: 0x01,
inMessageType: nas.MsgTypeAuthenticationResult,
inTsc: 0x01,
inNASKeySetIdentifier: 0x01,
inEAPLen: 0x02,
inEAPMessage: []uint8{0x10, 0x11},
inABBA: aBBATestData[0]},
{
inExtendedProtocolDiscriminator: nasMessage.Epd5GSSessionManagementMessage,
inSecurityHeaderType: 0x01,
inMessageType: nas.MsgTypeAuthenticationResult,
inTsc: 0x01,
inNASKeySetIdentifier: 0x01,
inEAPLen: 0x02,
inEAPMessage: []uint8{0x10, 0x11},
inABBA: aBBATestData[0],
},
/*{inExtendedProtocolDiscriminator: nasMessage.Epd5GSSessionManagementMessage,
inSecurityHeaderType: 0x01,
inMessageType: nas.MsgTypeAuthenticationResult,
Expand All @@ -59,7 +60,6 @@ func TestNasTypeNewAuthenticationResult(t *testing.T) {
}

func TestNasTypeNewAuthenticationResultMessage(t *testing.T) {

for i, table := range nasMessageAuthenticationResultTable {
logger.NasMsgLog.Infoln("Test Cnt:", i)
a := nasMessage.NewAuthenticationResult(0)
Expand Down
3 changes: 1 addition & 2 deletions nasMessage/NAS_CommInfoIE.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ const (
InternetProtocolControlProtocolUL uint16 = 0x8021
)

//TS 24.008 10.5.6.3

// TS 24.008 10.5.6.3
const (
PCSCFIPv6AddressDL uint16 = 0x0001
IMCNSubsystemSignalingFlagDL uint16 = 0x0002
Expand Down
2 changes: 0 additions & 2 deletions nasMessage/NAS_ConfigurationUpdateCommand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"
"github.com/omec-project/nas/nasType"

"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -132,7 +131,6 @@ func TestNasTypeNewConfigurationUpdateCommand(t *testing.T) {
}

func TestNasTypeNewConfigurationUpdateCommandMessage(t *testing.T) {

for i, table := range nasMessageConfigurationUpdateCommandTable {
logger.NasMsgLog.Infoln("Test Cnt:", i)
a := nasMessage.NewConfigurationUpdateCommand(0)
Expand Down
2 changes: 0 additions & 2 deletions nasMessage/NAS_ConfigurationUpdateComplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/omec-project/nas"
"github.com/omec-project/nas/logger"
"github.com/omec-project/nas/nasMessage"

"github.com/stretchr/testify/assert"
)

Expand All @@ -39,7 +38,6 @@ func TestNasTypeNewConfigurationUpdateComplete(t *testing.T) {
}

func TestNasTypeNewConfigurationUpdateCompleteMessage(t *testing.T) {

for i, table := range nasMessageConfigurationUpdateCompleteTable {
logger.NasMsgLog.Infoln("Test Cnt:", i)
a := nasMessage.NewConfigurationUpdateComplete(0)
Expand Down
Loading

0 comments on commit cd83b39

Please sign in to comment.