Skip to content

Commit

Permalink
fix(lint): update golangci-lint configuration to resolve deprecatio…
Browse files Browse the repository at this point in the history
…n warnings

- Replace deprecated `run.skip-dirs` with `issues.exclude-dirs`
- Update `output.format` to `output.formats`
- Remove deprecated linters:
  - `megacheck` (it's been split into `gosimple`, `staticcheck`, and `unused`)
  - `exportloopref` (no longer relevant since Go 1.22 - replaced by `copyloopvar`)
- Adjuste the defer statement comment in `localsdk.go` to
  use `staticcheck` instead of the deprecated `megacheck`

Signed-off-by: Paulina Kalicka <[email protected]>
  • Loading branch information
paulinek13 committed Jan 5, 2025
1 parent 56563a9 commit ec717e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ run:
# list of build tags, all linters use it. Default is empty list.
build-tags:

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- test/sdk/restapi

# 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
Expand All @@ -34,8 +26,15 @@ run:
modules-download-mode: vendor
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number
# the formats used to render issues
# formats: colored-line-number, line-number, json, colored-tab,
# tab, html, checkstyle, code-climate, junit-xml,
# junit-xml-extended, github-actions, teamcity, sarif
# output path can be either `stdout`, `stderr`
# or path to the file to write to
formats:
- format: colored-line-number
path: stdout

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -46,13 +45,11 @@ linters:
enable:
- bodyclose
- dupl
- exportloopref
- goconst
- gocritic
- gocyclo
- goimports
- govet
- megacheck
- misspell
- nakedret
- revive
Expand Down Expand Up @@ -88,3 +85,10 @@ issues:
- path: (.+)_test\.go|^test/|^cmd/.*|^pkg/apis/.*
# fieldalignment is in the `govet` linter, so exclude based on text instead of all of govet
text: '^fieldalignment: .*'

# which dirs to exclude: issues from them won't be reported
# default dirs are skipped independently of this option's value
# (see exclude-dirs-use-default)
# default: []
exclude-dirs:
- test/sdk/restapi
2 changes: 1 addition & 1 deletion pkg/sdkserver/localsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ func (l *LocalSDKServer) setGameServerFromFilePath(filePath string) error {
l.logger.WithField("filePath", filePath).Info("Reading GameServer configuration")

reader, err := os.Open(filePath) // nolint: gosec
defer reader.Close() // nolint: megacheck,errcheck
defer reader.Close() // nolint: staticcheck,errcheck

if err != nil {
return err
Expand Down

0 comments on commit ec717e3

Please sign in to comment.