Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable staticcheck #121

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 Open Networking Foundation <info@opennetworking.org>
#
# SPDX-License-Identifier: Apache-2.0

#

# This file contains all available configuration options
# with their default values.
Expand Down Expand Up @@ -98,7 +98,7 @@ linters-settings:
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# By default list of stable checks is used.
enabled-checks:
#- rangeValCopy
#- rangeValCopy
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
- regexpMust
Expand Down Expand Up @@ -145,19 +145,19 @@ linters-settings:
gomodguard:
allowed:
modules: # List of allowed modules
# - gopkg.in/yaml.v2
# - gopkg.in/yaml.v2
domains: # List of allowed module domains
# - golang.org
# - golang.org
blocked:
modules: # List of blocked modules
# - github.com/uudashr/go-module: # Blocked module
# recommendations: # Recommended modules that should be used instead (Optional)
# - golang.org/x/mod
# reason: "`mod` is the official go.mod parser library." # Reason why the recommended module should be used (Optional)
# - github.com/uudashr/go-module: # Blocked module
# recommendations: # Recommended modules that should be used instead (Optional)
# - golang.org/x/mod
# reason: "`mod` is the official go.mod parser library." # Reason why the recommended module should be used (Optional)
versions: # List of blocked module version constraints
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
# 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)
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
# 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
Expand All @@ -169,10 +169,13 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
# enable all analyzers
enable-all: true
# enable or disable analyzers by name
enable:
- atomicalign
enable-all: false
disable:
- fieldalignment
- shadow
disable-all: false
depguard:
list-type: blacklist
include-go-root: false
Expand Down Expand Up @@ -210,29 +213,44 @@ linters-settings:
misspell:
#locale: US
ignore-words:
wsl:
# If true append is only allowed to be cuddled if appending value is
# matching variables, fields or types on line above. Default is true.
strict-append: true
# Allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types. Default is true.
allow-assign-and-call: true
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow declarations (var) to be cuddled.
allow-cuddle-declarations: false
# Allow trailing comments in ending of blocks
allow-trailing-comment: true
# Force newlines in end of case at this limit (0 = never).
force-case-trailing-whitespace: 0
# Force cuddling of err checks with err var assignment
force-err-cuddling: false
# Allow leading comments to be separated with empty liens
allow-separated-leading-comment: false
custom:
# Each custom linter should have a unique name.
# Each custom linter should have a unique name.

linters:
enable:
- gofmt
- govet
# - errcheck
# - staticcheck
- staticcheck
# - unused
# - gosimple
# - structcheck
# - varcheck
- ineffassign
# - deadcode
# - typecheck
# Additional
# - lll
- godox
# - gomnd
#- gomnd
# - goconst
# - gocognit
# - maligned
# - nestif
# - gomodguard
# - nakedret
Expand All @@ -247,8 +265,8 @@ linters:
# - bodyclose
- asciicheck
#- stylecheck
# - unparam
#- wsl
# - unparam
# - wsl

#disable-all: false
fast: true
Expand All @@ -260,7 +278,7 @@ issues:
exclude:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# Exclude some linters from running on tests files.
# Exclude some linters from running on tests files.
# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
Expand All @@ -271,7 +289,7 @@ issues:
exclude-case-sensitive: false
# The list of ids of default excludes to include or disable. By default it's empty.
include:
#- EXC0002 # disable excluding of issues about comments from golint
#- EXC0002 # disable excluding of issues about comments from golint
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
#max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
Expand Down Expand Up @@ -307,5 +325,5 @@ severity:
# Only affects out formats that support setting severity information.
rules:
- linters:
- gomnd
- gomnd
severity: ignore
4 changes: 2 additions & 2 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
)

const (
GNBSIM_EXPECTED_CONFIG_VERSION string = "1.0.0"
GNBSIM_DEFAULT_CONFIG_PATH = "/gnbsim/config/gnb.conf"
GNBSIM_EXPECTED_CONFIG_VERSION = "1.0.0"
GNBSIM_DEFAULT_CONFIG_PATH = "/gnbsim/config/gnb.conf"
)

type Config struct {
Expand Down
4 changes: 2 additions & 2 deletions factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package factory

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

"gopkg.in/yaml.v2"

Expand All @@ -22,7 +22,7 @@ var AppConfig *Config

// TODO: Support configuration update from REST api
func InitConfigFactory(f string) error {
content, err := ioutil.ReadFile(f)
content, err := os.ReadFile(f)
if err != nil {
logger.CfgLog.Errorln("Failed to read", f, "file:", err)
return err
Expand Down
7 changes: 0 additions & 7 deletions gnodeb/context/gnbuedao.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func (dao *GnbUeDao) GetGnbUpUe(teid uint32, downlink bool) *GnbUpUe {
var ok bool
if downlink {
val, ok = dao.dlTeidGnbUpUeMap.Load(teid)
} else {
// TODO
//val, ok = dao.ulTeidGnbUpUeMap.Load(teid)
}

if ok {
Expand All @@ -78,8 +75,6 @@ func (dao *GnbUeDao) AddGnbUpUe(teid uint32, downlink bool, gnbue *GnbUpUe) {
dao.Log.Infoln("Adding new GnbUpUe for TEID:", teid, "Downlink:", downlink)
if downlink {
dao.dlTeidGnbUpUeMap.Store(teid, gnbue)
} else {
// TODO
}
}

Expand All @@ -88,7 +83,5 @@ func (dao *GnbUeDao) RemoveGnbUpUe(teid uint32, downlink bool) {
dao.Log.Infoln("Removing GnbUpUe for TEID:", teid, "Downlink:", downlink)
if downlink {
dao.dlTeidGnbUpUeMap.Delete(teid)
} else {
// TODO
}
}
1 change: 0 additions & 1 deletion gnodeb/worker/gnbamfworker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf,
amf.Log.Errorln("UENGAPIDs is nil")
return
}
break
}
}

Expand Down
2 changes: 0 additions & 2 deletions httpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ func StartHttpServer() (err error) {
serverScheme := "http"
if serverScheme == "http" {
err = server.ListenAndServe()
} else if serverScheme == "https" {
//To Do
}

if err != nil {
Expand Down
Loading