diff --git a/.golangci.yml b/.golangci.yml index 6fddc53..d61e68d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -80,10 +80,8 @@ linters: staticcheck: checks: - all - # "could remove embedded field", to keep it explicit! - - -QF1008 - # "could use tagged switch on enum", Cases conflicts with exhaustive! - - -QF1003 + - -QF1008 # "could remove embedded field", to keep it explicit! + - -QF1003 # "could use tagged switch on enum", Cases conflicts with exhaustive! exhaustive: default-signifies-exhaustive: true forbidigo: @@ -93,10 +91,6 @@ linters: - pattern: ^os.Exit$ - pattern: ^panic$ - pattern: ^print(ln)?$ - - pattern: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$ - pkg: ^testing$ - msg: use testify/assert instead - analyze-types: true gomodguard: blocked: modules: @@ -106,12 +100,6 @@ linters: govet: enable: - shadow - revive: - rules: - # Prefer 'any' type alias over 'interface{}' for Go 1.18+ compatibility - - name: use-any - severity: warning - disabled: false misspell: locale: US varnamelen: @@ -132,18 +120,15 @@ linters: - linters: - forbidigo - gocognit - path: (examples|main\.go) - - linters: - - gocognit - path: _test\.go + path: (examples|main\.go|_test\.go) - linters: - forbidigo path: cmd formatters: enable: - - gci - - gofmt - - gofumpt - - goimports + - gci # Gci control golang package import order and make it always deterministic. + - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification + - gofumpt # Gofumpt checks whether code was gofumpt-ed. + - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports exclusions: generated: lax diff --git a/active_tcp_test.go b/active_tcp_test.go index 4959976..c6728d9 100644 --- a/active_tcp_test.go +++ b/active_tcp_test.go @@ -230,7 +230,7 @@ func TestActiveTCP_Respect_NetworkTypes(t *testing.T) { defer test.CheckRoutines(t)() defer test.TimeOut(time.Second * 5).Stop() - tcpListener, err := net.Listen("tcp", "127.0.0.1:0") + tcpListener, err := net.Listen("tcp", "127.0.0.1:0") // nolint: noctx require.NoError(t, err) _, port, err := net.SplitHostPort(tcpListener.Addr().String()) diff --git a/agent_options_test.go b/agent_options_test.go index 38ad0e6..27cbaad 100644 --- a/agent_options_test.go +++ b/agent_options_test.go @@ -202,7 +202,7 @@ func TestWithDisableActiveTCP(t *testing.T) { func TestWithBindingRequestHandler(t *testing.T) { t.Run("sets binding request handler", func(t *testing.T) { handlerCalled := false - handler := func(m *stun.Message, local, remote Candidate, pair *CandidatePair) bool { + handler := func(_ *stun.Message, _, _ Candidate, _ *CandidatePair) bool { handlerCalled = true return true @@ -232,7 +232,7 @@ func TestWithBindingRequestHandler(t *testing.T) { t.Run("works with config", func(t *testing.T) { handlerCalled := false - handler := func(m *stun.Message, local, remote Candidate, pair *CandidatePair) bool { + handler := func(_ *stun.Message, _, _ Candidate, _ *CandidatePair) bool { handlerCalled = true return true @@ -268,7 +268,7 @@ func TestMultipleConfigOptions(t *testing.T) { t.Run("can apply multiple options", func(t *testing.T) { customOffset := uint16(100) handlerCalled := false - handler := func(m *stun.Message, local, remote Candidate, pair *CandidatePair) bool { + handler := func(_ *stun.Message, _, _ Candidate, _ *CandidatePair) bool { handlerCalled = true return true diff --git a/agent_test.go b/agent_test.go index 29f99d2..7f381c0 100644 --- a/agent_test.go +++ b/agent_test.go @@ -1952,7 +1952,8 @@ func TestRoleConflict(t *testing.T) { defer test.CheckRoutines(t)() defer test.TimeOut(time.Second * 30).Stop() - runTest := func(doDial bool) { + runTest := func(t *testing.T, doDial bool) { + t.Helper() cfg := &AgentConfig{ NetworkTypes: supportedNetworkTypes(), MulticastDNSMode: MulticastDNSModeDisabled, @@ -2004,10 +2005,10 @@ func TestRoleConflict(t *testing.T) { } t.Run("Controlling", func(t *testing.T) { - runTest(true) + runTest(t, true) }) t.Run("Controlled", func(t *testing.T) { - runTest(false) + runTest(t, false) }) } diff --git a/candidate_relay_test.go b/candidate_relay_test.go index 1a04506..6677f53 100644 --- a/candidate_relay_test.go +++ b/candidate_relay_test.go @@ -29,7 +29,7 @@ func TestRelayOnlyConnection(t *testing.T) { defer test.CheckRoutines(t)() serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) server, err := turn.NewServer(turn.ServerConfig{ diff --git a/candidate_server_reflexive_test.go b/candidate_server_reflexive_test.go index c3e91aa..375d285 100644 --- a/candidate_server_reflexive_test.go +++ b/candidate_server_reflexive_test.go @@ -25,7 +25,7 @@ func TestServerReflexiveOnlyConnection(t *testing.T) { defer test.TimeOut(time.Second * 30).Stop() serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp4", "127.0.0.1:"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) server, err := turn.NewServer(turn.ServerConfig{ diff --git a/gather_test.go b/gather_test.go index 6ef39e1..5dff59d 100644 --- a/gather_test.go +++ b/gather_test.go @@ -129,7 +129,7 @@ func TestLoopbackCandidate(t *testing.T) { muxWithLo, errlo := NewMultiUDPMuxFromPort(12501, UDPMuxFromPortWithLoopback()) require.NoError(t, errlo) - unspecConn, errconn := net.ListenPacket("udp", ":0") + unspecConn, errconn := net.ListenPacket("udp", ":0") // nolint: noctx require.NoError(t, errconn) defer func() { _ = unspecConn.Close() @@ -233,7 +233,7 @@ func TestSTUNConcurrency(t *testing.T) { defer test.TimeOut(time.Second * 30).Stop() serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) server, err := turn.NewServer(turn.ServerConfig{ @@ -388,7 +388,7 @@ func TestTURNConcurrency(t *testing.T) { t.Run("UDP Relay", func(t *testing.T) { serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) runTest(stun.ProtoTypeUDP, stun.SchemeTypeTURN, serverListener, nil, serverPort) @@ -396,7 +396,7 @@ func TestTURNConcurrency(t *testing.T) { t.Run("TCP Relay", func(t *testing.T) { serverPort := randomPort(t) - serverListener, err := net.Listen("tcp", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.Listen("tcp", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) runTest(stun.ProtoTypeTCP, stun.SchemeTypeTURN, nil, serverListener, serverPort) @@ -440,7 +440,7 @@ func TestSTUNTURNConcurrency(t *testing.T) { defer test.TimeOut(time.Second * 8).Stop() serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) server, err := turn.NewServer(turn.ServerConfig{ @@ -513,7 +513,7 @@ func TestTURNSrflx(t *testing.T) { defer test.TimeOut(time.Second * 30).Stop() serverPort := randomPort(t) - serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) + serverListener, err := net.ListenPacket("udp4", localhostIPStr+":"+strconv.Itoa(serverPort)) // nolint: noctx require.NoError(t, err) server, err := turn.NewServer(turn.ServerConfig{ @@ -651,7 +651,7 @@ func TestUDPMuxDefaultWithNAT1To1IPsUsage(t *testing.T) { defer test.TimeOut(time.Second * 30).Stop() - conn, err := net.ListenPacket("udp4", ":0") + conn, err := net.ListenPacket("udp4", ":0") // nolint: noctx require.NoError(t, err) defer func() { _ = conn.Close() diff --git a/go.mod b/go.mod index 5e5d5be..8c11515 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/pion/ice/v4 -go 1.20 +go 1.21 require ( github.com/google/uuid v1.6.0 diff --git a/transport_test.go b/transport_test.go index 0377f81..5bb3e84 100644 --- a/transport_test.go +++ b/transport_test.go @@ -267,7 +267,7 @@ func onConnected() (func(ConnectionState), chan struct{}) { func randomPort(tb testing.TB) int { tb.Helper() - conn, err := net.ListenPacket("udp4", "127.0.0.1:0") + conn, err := net.ListenPacket("udp4", "127.0.0.1:0") // nolint: noctx if err != nil { tb.Fatalf("failed to pickPort: %v", err) }