From 2e35e762b06665feb7ae2769638564ddfa5f650b Mon Sep 17 00:00:00 2001 From: Guillaume Belanger Date: Wed, 3 Jan 2024 15:31:28 -0500 Subject: [PATCH] chore: Adds lint checks to CI --- .github/workflows/master.yml | 15 +++++++++++++++ .golangci.yml | 31 ++++++++++++++----------------- service/init.go | 3 +-- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 680a6e4..9608b0d 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -35,3 +35,18 @@ jobs: - name: Unit tests run: go test ./... + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.7.0 + with: + version: latest + args: -v --config ./.golangci.yml diff --git a/.golangci.yml b/.golangci.yml index f8422d0..66b41aa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -220,19 +220,16 @@ linters-settings: linters: enable: - - gofmt - - govet - - errcheck - - staticcheck - - unused - - gosimple - - structcheck - - varcheck - - ineffassign - - deadcode + # - gofmt + # - govet + # - errcheck + # - staticcheck + # - unused + # - gosimple + # - ineffassign - typecheck # Additional - - lll + # - lll - godox #- gomnd #- goconst @@ -240,16 +237,16 @@ linters: # - maligned # - nestif # - gomodguard - - nakedret - - gci + # - nakedret + # - gci - misspell - - gofumpt - - whitespace - - unconvert + # - gofumpt + # - whitespace + # - unconvert - predeclared - noctx - dogsled - - bodyclose + # - bodyclose - asciicheck #- stylecheck # - unparam diff --git a/service/init.go b/service/init.go index e4aae41..066c8ac 100644 --- a/service/init.go +++ b/service/init.go @@ -686,10 +686,9 @@ func (pcf *PCF) UpdatePcfSubsriberPolicyData(slice *protos.NetworkSlice) { for _, imsi := range slice.AddUpdatedImsis { if ImsiExistInDeviceGroup(devgroup, imsi) { - policyData, _ := self.PcfSubscriberPolicyData[imsi] // TODO policy exists, so compare and get difference with existing policy then notify the subscriber self.PcfSubscriberPolicyData[imsi] = &context.PcfSubscriberPolicyData{} - policyData = self.PcfSubscriberPolicyData[imsi] + policyData := self.PcfSubscriberPolicyData[imsi] policyData.CtxLog = logger.CtxLog.WithField(logger.FieldSupi, "imsi-"+imsi) policyData.PccPolicy = make(map[string]*context.PccPolicy) policyData.PccPolicy[sliceid] = &context.PccPolicy{make(map[string]*models.PccRule),