Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
golangci-lint upgrade to v1.56.2 added more checks

Relates to pion/.goassets#201
  • Loading branch information
Sean-Der committed Apr 3, 2024
1 parent a3cf77e commit 3ff88c8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// NoopHandler just discards any event.
func NoopHandler() Handler {
return func(e Event) {}
return func(Event) {}
}

// NewAgent initializes and returns new Agent with provided handler.
Expand Down
28 changes: 14 additions & 14 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func BenchmarkClient_Do(b *testing.B) {
}
}()

noopF := func(event Event) {
noopF := func(Event) {
// pass
}
b.RunParallel(func(pb *testing.PB) {
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestClient_Start(t *testing.T) {
t.Error(err)
}
t.Log("starting the second transaction")
if err := c.Start(m, func(e Event) {
if err := c.Start(m, func(Event) {
t.Error("should not be called")
}); !errors.Is(err, ErrTransactionExists) {
t.Errorf("unexpected error %v", err)
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestClientAgentError(t *testing.T) {

func TestClientConnErr(t *testing.T) {
conn := &testConnection{
write: func(bytes []byte) (int, error) {
write: func([]byte) (int, error) {
return 0, io.ErrClosedPipe
},
}
Expand All @@ -404,7 +404,7 @@ func TestClientConnErr(t *testing.T) {

func TestClientConnErrStopErr(t *testing.T) {
conn := &testConnection{
write: func(bytes []byte) (int, error) {
write: func([]byte) (int, error) {
return 0, io.ErrClosedPipe
},
}
Expand Down Expand Up @@ -629,7 +629,7 @@ func TestClientFinalizer(t *testing.T) {
clientFinalizer(nil) // should not panic
clientFinalizer(&Client{})
conn := &testConnection{
write: func(bytes []byte) (int, error) {
write: func([]byte) (int, error) {
return 0, io.ErrClosedPipe
},
}
Expand Down Expand Up @@ -681,7 +681,7 @@ func TestClientFinalizer(t *testing.T) {
func TestCallbackWaitHandler(*testing.T) {
h := callbackWaitHandlerPool.Get().(*callbackWaitHandler) //nolint:forcetypeassert
for i := 0; i < 100; i++ {
h.setCallback(func(event Event) {})
h.setCallback(func(Event) {})
go func() {
time.Sleep(time.Microsecond * 100)
h.HandleEvent(Event{})
Expand Down Expand Up @@ -775,7 +775,7 @@ func TestClientRetransmission(t *testing.T) {
clock := &manualClock{current: time.Now()}
agent := &manualAgent{}
attempt := 0
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
if attempt == 0 {
attempt++
go agent.h(Event{
Expand Down Expand Up @@ -841,7 +841,7 @@ func testClientDoConcurrent(t *testing.T, concurrency int) {
collector := new(manualCollector)
clock := &manualClock{current: time.Now()}
agent := &manualAgent{}
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
go agent.h(Event{
TransactionID: id,
Message: response,
Expand Down Expand Up @@ -1033,7 +1033,7 @@ func TestWithNoRetransmit(t *testing.T) {
clock := &manualClock{current: time.Now()}
agent := &manualAgent{}
attempt := 0
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
if attempt == 0 {
attempt++
go agent.h(Event{
Expand Down Expand Up @@ -1125,7 +1125,7 @@ func TestClientRTOStartErr(t *testing.T) {
c *Client
startClientErr error
)
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
t.Log("start", attempt)
if attempt == 0 {
attempt++
Expand Down Expand Up @@ -1242,10 +1242,10 @@ func TestClientRTOWriteErr(t *testing.T) {
startClientErr error
)
agentStopErr := errClientAgentCantStop
agent.stop = func(id [TransactionIDSize]byte) error {
agent.stop = func([TransactionIDSize]byte) error {
return agentStopErr
}
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
t.Log("start", attempt)
if attempt == 0 {
attempt++
Expand Down Expand Up @@ -1350,7 +1350,7 @@ func TestClientRTOAgentErr(t *testing.T) {
startClientErr error
)
agentStartErr := errClientStartRefused
agent.start = func(id [TransactionIDSize]byte, deadline time.Time) error {
agent.start = func(id [TransactionIDSize]byte, _ time.Time) error {
t.Log("start", attempt)
if attempt == 0 {
attempt++
Expand Down Expand Up @@ -1413,7 +1413,7 @@ func TestClient_HandleProcessError(t *testing.T) {
agent := &manualAgent{}
gotWrites := make(chan struct{})
processCalled := make(chan struct{}, 1)
agent.process = func(m *Message) error {
agent.process = func(*Message) error {
processCalled <- struct{}{}
return ErrAgentClosed
}
Expand Down
12 changes: 11 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
module github.com/pion/stun/v2

go 1.12
go 1.19

require (
github.com/pion/dtls/v2 v2.2.10
github.com/pion/logging v0.2.2
github.com/pion/transport/v3 v3.0.1
github.com/stretchr/testify v1.8.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pion/transport/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
8 changes: 4 additions & 4 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestHelpersErrorHandling(t *testing.T) {
t.Error(err, "!=", e.Err)
}
t.Run("MustBuild", func(t *testing.T) {
t.Run("Positive", func(t *testing.T) {
t.Run("Positive", func(*testing.T) {
MustBuild(NewTransactionIDSetter(transactionID{}))
})
defer func() {
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestMessage_ForEach(t *testing.T) {
if !m.Equal(initial) {
t.Error("m should be equal to initial")
}
if err := m.ForEach(AttrUsername, func(m *Message) error {
if err := m.ForEach(AttrUsername, func(*Message) error {
t.Error("should not be called")
return nil
}); err != nil {
Expand All @@ -155,7 +155,7 @@ func TestMessage_ForEach(t *testing.T) {
t.Run("ReturnOnError", func(t *testing.T) {
m := newMessage()
var calls int
if err := m.ForEach(AttrRealm, func(m *Message) error {
if err := m.ForEach(AttrRealm, func(*Message) error {
if calls > 0 {
t.Error("called multiple times")
}
Expand Down Expand Up @@ -235,7 +235,7 @@ func BenchmarkMessage_ForEach(b *testing.B) {
NewRealm("realm4"),
)
for i := 0; i < b.N; i++ {
if err := m.ForEach(AttrRealm, func(m *Message) error {
if err := m.ForEach(AttrRealm, func(*Message) error {
return nil
}); err != nil {
b.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/hmac/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestHMACPool_SHA256(t *testing.T) { //nolint:dupl
}

func TestAssertBlockSize(t *testing.T) {
t.Run("Positive", func(t *testing.T) {
t.Run("Positive", func(*testing.T) {
h := AcquireSHA1(make([]byte, 0, 1024))
assertHMACSize(h.(*hmac), sha1.Size, sha1.BlockSize) //nolint:forcetypeassert
})
Expand Down
3 changes: 1 addition & 2 deletions message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"fmt"
"hash/crc64"
"io"
"io/ioutil"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -558,7 +557,7 @@ func loadData(tb testing.TB, name string) []byte {
tb.Fatal(errClose)
}
}()
v, err := ioutil.ReadAll(f)
v, err := io.ReadAll(f)
if err != nil {
tb.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions rfc5769_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func TestRFC5769(t *testing.T) {
// Test Vectors for Session Traversal Utilities for NAT (STUN)
// see https://tools.ietf.org/html/rfc5769
t.Run("Request", func(t *testing.T) {
// nolint
m := &Message{
Raw: []byte("\x00\x01\x00\x58" +
"\x21\x12\xa4\x42" +
Expand Down

0 comments on commit 3ff88c8

Please sign in to comment.