Skip to content

Commit

Permalink
fix: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Apr 9, 2024
1 parent 3d1440e commit 1d59148
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.45.2
version: v1.57.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
7 changes: 3 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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 @@ -149,7 +149,7 @@ linters-settings:
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
govet:
# report about shadowed variables
check-shadowing: true
# check-shadowing: true
# settings per analyzer
settings:
printf: # analyzer name, run `go tool vet help` to see all analyzers
Expand All @@ -161,9 +161,8 @@ linters-settings:
# enable or disable analyzers by name
enable:
- atomicalign
enable-all: false
disable:
- shadow
enable-all: false
disable-all: false
depguard:
list-type: blacklist
Expand Down
8 changes: 5 additions & 3 deletions internal/sbi/api_accesstoken.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* NRF OAuth2
*
* NRF OAuth2 Authorization. © 2022, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
* NRF OAuth2 Authorization.
* © 2022, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.2.1
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
Expand All @@ -14,10 +15,11 @@ import (
"net/http"
"reflect"

"github.com/gin-gonic/gin"

"github.com/free5gc/nrf/internal/logger"
"github.com/free5gc/nrf/pkg/factory"
"github.com/free5gc/openapi/models"
"github.com/gin-gonic/gin"
)

// Index is the index handler.
Expand Down Expand Up @@ -89,7 +91,7 @@ func (s *Server) apiAccessTokenRequest(c *gin.Context) {
}
}

if err := s.bindData(c, &accessTokenReq); err != nil {
if err1 := s.bindData(c, &accessTokenReq); err1 != nil {
return
}
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/sbi/processor/accesstoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
"strings"
"time"

"github.com/golang-jwt/jwt"
"go.mongodb.org/mongo-driver/bson"

nrf_context "github.com/free5gc/nrf/internal/context"
"github.com/free5gc/nrf/internal/logger"
"github.com/free5gc/nrf/pkg/factory"
Expand All @@ -14,8 +17,6 @@ import (
"github.com/free5gc/openapi/oauth"
"github.com/free5gc/util/mapstruct"
"github.com/free5gc/util/mongoapi"
"github.com/golang-jwt/jwt"
"go.mongodb.org/mongo-driver/bson"
)

func (p *Processor) AccessTokenProcedure(request models.AccessTokenReq) *HandlerResponse {
Expand Down
2 changes: 2 additions & 0 deletions internal/sbi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (s *Server) startServer(wg *sync.WaitGroup) {
logger.SBILog.Warnf("SBI server (listen on %s) stopped", s.httpServer.Addr)
}

// nolint
func checkContentTypeIsJSON(gc *gin.Context) (string, error) {
var err error
contentType := gc.GetHeader("Content-Type")
Expand All @@ -169,6 +170,7 @@ func checkContentTypeIsJSON(gc *gin.Context) (string, error) {
return contentType, nil
}

// nolint
func (s *Server) deserializeData(gc *gin.Context, data interface{}, contentType string) error {
reqBody, err := gc.GetRawData()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package factory

import (
"fmt"
"io/ioutil"
"os"

"github.com/asaskevich/govalidator"
"gopkg.in/yaml.v2"
Expand All @@ -23,7 +23,7 @@ func InitConfigFactory(f string, cfg *Config) error {
f = NrfDefaultConfigPath
}

if content, err := ioutil.ReadFile(f); err != nil {
if content, err := os.ReadFile(f); err != nil {
return fmt.Errorf("[Factory] %+v", err)
} else {
logger.CfgLog.Infof("Read config from [%s]", f)
Expand Down
6 changes: 3 additions & 3 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package service

import (
"context"
"io/ioutil"
"io"
"os"
"runtime/debug"
"sync"
Expand Down Expand Up @@ -90,15 +90,15 @@ func (a *NrfApp) SetLogEnable(enable bool) {
logger.MainLog.Infof("Log enable is set to [%v]", enable)
if enable && logger.Log.Out == os.Stderr {
return
} else if !enable && logger.Log.Out == ioutil.Discard {
} else if !enable && logger.Log.Out == io.Discard {
return
}

a.cfg.SetLogEnable(enable)
if enable {
logger.Log.SetOutput(os.Stderr)
} else {
logger.Log.SetOutput(ioutil.Discard)
logger.Log.SetOutput(io.Discard)
}
}

Expand Down

0 comments on commit 1d59148

Please sign in to comment.