mirror of
https://github.com/gortc/stun.git
synced 2025-09-26 20:41:36 +08:00
all: improve linters config and fix some warnings
This commit is contained in:
@@ -4,7 +4,7 @@ linters-settings:
|
|||||||
golint:
|
golint:
|
||||||
min-confidence: 0
|
min-confidence: 0
|
||||||
gocyclo:
|
gocyclo:
|
||||||
min-complexity: 10
|
min-complexity: 15
|
||||||
maligned:
|
maligned:
|
||||||
suggest-new: true
|
suggest-new: true
|
||||||
dupl:
|
dupl:
|
||||||
@@ -23,18 +23,23 @@ linters-settings:
|
|||||||
lll:
|
lll:
|
||||||
line-length: 140
|
line-length: 140
|
||||||
goimports:
|
goimports:
|
||||||
local-prefixes: github.com/golangci/golangci-lint
|
local-prefixes: github.com/gortc
|
||||||
gocritic:
|
gocritic:
|
||||||
enabled-tags:
|
enabled-tags:
|
||||||
- performance
|
- performance
|
||||||
- style
|
- style
|
||||||
- experimental
|
- experimental
|
||||||
disabled-checks:
|
disabled-checks:
|
||||||
- wrapperFunc
|
- sloppyReassign
|
||||||
- commentFormatting # https://github.com/go-critic/go-critic/issues/755
|
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
|
exclude:
|
||||||
|
- "`assertHMACSize` - `blocksize` always receives `64`"
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
|
- text: "string `<nil>`"
|
||||||
|
linters:
|
||||||
|
- goconst
|
||||||
|
|
||||||
# Exclude some linters from running on tests files.
|
# Exclude some linters from running on tests files.
|
||||||
- path: _test\.go
|
- path: _test\.go
|
||||||
linters:
|
linters:
|
||||||
@@ -42,10 +47,11 @@ issues:
|
|||||||
- errcheck
|
- errcheck
|
||||||
- dupl
|
- dupl
|
||||||
- gosec
|
- gosec
|
||||||
|
- goconst
|
||||||
|
|
||||||
# Ease some gocritic warnings on test files.
|
# Ease some gocritic warnings on test files.
|
||||||
- path: _test\.go
|
- path: _test\.go
|
||||||
text: "(unnamedResult|exitAfterDefer)"
|
text: "(unnamedResult|exitAfterDefer|unlambda)"
|
||||||
linters:
|
linters:
|
||||||
- gocritic
|
- gocritic
|
||||||
|
|
||||||
@@ -65,10 +71,26 @@ issues:
|
|||||||
linters:
|
linters:
|
||||||
- gosec
|
- gosec
|
||||||
- errcheck
|
- errcheck
|
||||||
|
- unparam
|
||||||
|
|
||||||
|
- path: ^cmd/
|
||||||
|
linters:
|
||||||
|
- gocyclo
|
||||||
|
- path: ^cmd/
|
||||||
|
text: "(unnamedResult|exitAfterDefer)"
|
||||||
|
linters:
|
||||||
|
- gocritic
|
||||||
|
- path: ^message.go$
|
||||||
|
text: "commentedOutCode"
|
||||||
|
linters:
|
||||||
|
- gocritic
|
||||||
|
|
||||||
|
linters:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
disable:
|
disable:
|
||||||
- prealloc
|
- prealloc
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
|
- scopelint
|
||||||
|
|
||||||
run:
|
run:
|
||||||
skip-dirs:
|
skip-dirs:
|
||||||
|
@@ -230,7 +230,7 @@ func putClientTransaction(t *clientTransaction) {
|
|||||||
clientTransactionPool.Put(t)
|
clientTransactionPool.Put(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t clientTransaction) nextTimeout(now time.Time) time.Time {
|
func (t *clientTransaction) nextTimeout(now time.Time) time.Time {
|
||||||
return now.Add(time.Duration(t.attempt+1) * t.rto)
|
return now.Add(time.Duration(t.attempt+1) * t.rto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
addr := flag.Arg(0)
|
addr := flag.Arg(0)
|
||||||
if len(addr) == 0 {
|
if addr == "" {
|
||||||
addr = "stun.l.google.com:19302"
|
addr = "stun.l.google.com:19302"
|
||||||
}
|
}
|
||||||
c, err := stun.Dial("udp", addr)
|
c, err := stun.Dial("udp", addr)
|
||||||
|
@@ -33,7 +33,7 @@ func TestFingerprint_Check(t *testing.T) {
|
|||||||
if err := Fingerprint.Check(m); err != nil {
|
if err := Fingerprint.Check(m); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
m.Raw[3] = m.Raw[3] + 1
|
m.Raw[3]++
|
||||||
if err := Fingerprint.Check(m); err == nil {
|
if err := Fingerprint.Check(m); err == nil {
|
||||||
t.Error("should error")
|
t.Error("should error")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user