Skip to content
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
15 changes: 7 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ jobs:
uses: actions/checkout@v4

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: 'latest'

staticcheck:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: 'stable'
- run: go install honnef.co/go/tools/cmd/staticcheck@latest
- uses: actions/checkout@v4
- run: make static
- run: make check

test:
runs-on: ubuntu-latest
Expand All @@ -55,8 +54,8 @@ jobs:
run: make test

release:
name: "tf2bdd release"
runs-on: "ubuntu-latest"
name: "steamid release"
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
Expand All @@ -71,7 +70,7 @@ jobs:

- run: go mod tidy

- uses: goreleaser/goreleaser-action@v5
- uses: goreleaser/goreleaser-action@v6
if: success() && startsWith(github.ref, 'refs/tags/v')
with:
distribution: goreleaser
Expand All @@ -82,7 +81,7 @@ jobs:

- name: Upload snapshot
if: success() && ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: snapshot
path: build/*
Expand Down
128 changes: 36 additions & 92 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,144 +1,88 @@
run:
skip-files:
- internal/web/data.go
- pkg/msqp/*
- pkg/mm/*

version: "2"
linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
default: none
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
#- cyclop
- decorder
#- depguard
- dogsled
#- dupl
#- dupword
#- durationcheck
- err113
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
#- exhaustive
#- exhaustruct
- exportloopref
#- forbidigo
- forcetypeassert
#- funlen
#- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoglobals
#- gochecknoinits
#- gocognit
#- goconst
- gocritic
#- gocyclo
- godot
#- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
#- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- interfacebloat
#- ireturn
#- lll
- loggercheck
- maintidx
- makezero
- misspell
#- musttag
- nakedret
#- nestif
- nilerr
- nilnil
#- nlreturn
- noctx
#- nolintlint
- nonamedreturns
- nosprintfhostport
#- paralleltest
#- prealloc
- predeclared
#- promlinter
- reassign
#- revive
- rowserrcheck
- sqlclosecheck
#- staticcheck
- stylecheck
#- tagliatelle
- tenv
- staticcheck
- testableexamples
- testpackage
- thelper
#- tparallel
- typecheck
- unconvert
#- unparam
#- unused
- usestdlibvars
#- varnamelen
- wastedassign
- whitespace
- wrapcheck
#- wsl
#- zerologlint
# Disable specific linter
# https://golangci-lint.run/usage/linters/#disabled-by-default
#disable:
# - staticcheck
# Enable presets.
# https://golangci-lint.run/usage/linters
# presets:
# - bugs
# #- comment
# - complexity
# #- error
# - format
# - import
# - metalinter
# - module
# #- performance
# - sql
# #- style
# #- test
# #- unused

linters-settings:
tagliatelle:
case:
use-field-name: true
rules:
json: snake
yaml: snake
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 100
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: -1
settings:
funlen:
lines: 100
statements: -1
tagliatelle:
case:
rules:
json: snake
yaml: snake
use-field-name: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
13 changes: 3 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,15 @@ test:

fmt:
#gci write . --skip-generated -s standard -s default
gofumpt -l -w .
go tool gofumpt -l -w .

check: fmt lint_golangci static

lint_golangci:
@golangci-lint run --timeout 3m
go tool golangci-lint run --timeout 3m

static:
@staticcheck -go 1.20 ./...

check_deps:
go install github.com/daixiang0/gci@v0.13.0
go install mvdan.cc/gofumpt@v0.6.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
go install github.com/goreleaser/goreleaser@v1.24.0
go tool staticcheck -go 1.24 ./...

dev_db:
docker compose -f docker-compose-dev.yml up --force-recreate -V postgres
Expand Down
4 changes: 3 additions & 1 deletion cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ All formats are parsed from the file and duplicates are removed`,
}

if err := extra.ParseReader(reader, writer, format, idType); err != nil {
log.Fatalf(err.Error())
log.Println(err.Error()) //nolint:govet,staticcheck

os.Exit(1)
}
os.Exit(0)
},
Expand Down
2 changes: 1 addition & 1 deletion extra/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ParseReader(input io.Reader, output io.Writer, format string, idType string
value = string(id.Steam(false))
}

_, errWrite := writer.WriteString(fmt.Sprintf(format, value))
_, errWrite := fmt.Fprintf(writer, format, value)
if errWrite != nil {
return errors.Join(errWrite, ErrWrite)
}
Expand Down
15 changes: 7 additions & 8 deletions extra/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func parseMaxPlayers(part string) int {
return -1
}

return int(m)
return int(m) //nolint:gosec
}

func parseEdits(part string) []int {
Expand All @@ -114,7 +114,7 @@ func parseEdits(part string) []int {
return []int{-1, -1}
}

return []int{int(l), int(m)}
return []int{int(l), int(m)} //nolint:gosec
}

var (
Expand Down Expand Up @@ -230,7 +230,7 @@ func ParseStatus(status string, full bool) (Status, error) {
return Status{}, errors.Join(errUint, ErrParseSeconds)
}

totalSec += int(v) * []int{1, 60, 3600}[i]
totalSec += int(v) * []int{1, 60, 3600}[i] //nolint:gosec
}

dur, errDur := time.ParseDuration(fmt.Sprintf("%ds", totalSec))
Expand All @@ -240,12 +240,12 @@ func ParseStatus(status string, full bool) (Status, error) {
}

p := Player{
UserID: int(userID),
UserID: int(userID), //nolint:gosec
Name: m[2],
SID: steamid.New(m[3]),
ConnectedTime: dur,
Ping: int(ping),
Loss: int(loss),
Ping: int(ping), //nolint:gosec
Loss: int(loss), //nolint:gosec
State: m[7],
}

Expand All @@ -261,12 +261,11 @@ func ParseStatus(status string, full bool) (Status, error) {
}

p.IP = ip
p.Port = int(port)
p.Port = int(port) //nolint:gosec
}

s.Players = append(s.Players, p)
}

}
}

Expand Down
Loading
Loading