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
ourwarmhouse committed Mar 17, 2024
1 parent 10b10d5 commit 836f533
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 67 deletions.
10 changes: 5 additions & 5 deletions datachannel_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestDataChannel_EventHandlers(t *testing.T) {
close(onOpenCalled)
})

dc.OnMessage(func(p DataChannelMessage) {
dc.OnMessage(func(DataChannelMessage) {
close(onMessageCalled)
})

Expand Down Expand Up @@ -222,7 +222,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
}
})

answerDC.OnMessage(func(msg DataChannelMessage) {
answerDC.OnMessage(func(DataChannelMessage) {
atomic.AddUint32(&nAnswerReceived, 1)
})
assert.True(t, answerDC.Ordered(), "Ordered should be set to true")
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
}
})

offerDC.OnMessage(func(msg DataChannelMessage) {
offerDC.OnMessage(func(DataChannelMessage) {
atomic.AddUint32(&nOfferReceived, 1)
})

Expand Down Expand Up @@ -309,7 +309,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
return
}
var nPacketsReceived int
d.OnMessage(func(msg DataChannelMessage) {
d.OnMessage(func(DataChannelMessage) {
nPacketsReceived++

if nPacketsReceived == 10 {
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestDataChannelBufferedAmount(t *testing.T) {
}
})

dc.OnMessage(func(msg DataChannelMessage) {
dc.OnMessage(func(DataChannelMessage) {
})

err = signalPair(offerPC, answerPC)
Expand Down
14 changes: 7 additions & 7 deletions datachannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestDataChannel_Open(t *testing.T) {
d.OnOpen(func() {
openCalls <- true
})
d.OnMessage(func(msg DataChannelMessage) {
d.OnMessage(func(DataChannelMessage) {
go func() {
// Wait a little bit to ensure all messages are processed.
time.Sleep(100 * time.Millisecond)
Expand Down Expand Up @@ -191,7 +191,7 @@ func TestDataChannel_Open(t *testing.T) {
})
assert.NoError(t, err)

answerDC.OnMessage(func(msg DataChannelMessage) {
answerDC.OnMessage(func(DataChannelMessage) {
go func() {
// Wait a little bit to ensure all messages are processed.
time.Sleep(100 * time.Millisecond)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestDataChannel_Send(t *testing.T) {
if d.Label() != expectedLabel {
return
}
d.OnMessage(func(msg DataChannelMessage) {
d.OnMessage(func(DataChannelMessage) {
e := d.Send([]byte("Pong"))
if e != nil {
t.Fatalf("Failed to send string on data channel")
Expand All @@ -259,7 +259,7 @@ func TestDataChannel_Send(t *testing.T) {
t.Fatalf("Failed to send string on data channel")
}
})
dc.OnMessage(func(msg DataChannelMessage) {
dc.OnMessage(func(DataChannelMessage) {
done <- true
})

Expand Down Expand Up @@ -288,7 +288,7 @@ func TestDataChannel_Send(t *testing.T) {
if d.Label() != expectedLabel {
return
}
d.OnMessage(func(msg DataChannelMessage) {
d.OnMessage(func(DataChannelMessage) {
e := d.Send([]byte("Pong"))
if e != nil {
t.Fatalf("Failed to send string on data channel")
Expand All @@ -309,7 +309,7 @@ func TestDataChannel_Send(t *testing.T) {

assert.True(t, dc.Ordered(), "Ordered should be set to true")

dc.OnMessage(func(msg DataChannelMessage) {
dc.OnMessage(func(DataChannelMessage) {
done <- true
})

Expand Down Expand Up @@ -477,7 +477,7 @@ func TestDataChannelParameters(t *testing.T) {

t.Fatal("OnDataChannel must not be fired when negotiated == true")
})
offerPC.OnDataChannel(func(d *DataChannel) {
offerPC.OnDataChannel(func(*DataChannel) {
t.Fatal("OnDataChannel must not be fired when negotiated == true")
})

Expand Down
4 changes: 2 additions & 2 deletions dtlstransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func TestPeerConnection_DTLSRoleSettingEngine(t *testing.T) {
report := test.CheckRoutines(t)
defer report()

t.Run("Server", func(t *testing.T) {
t.Run("Server", func(*testing.T) {
runTest(DTLSRoleServer)
})

t.Run("Client", func(t *testing.T) {
t.Run("Client", func(*testing.T) {
runTest(DTLSRoleClient)
})
}
2 changes: 1 addition & 1 deletion examples/bandwidth-estimation-from-disk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
}

estimatorChan := make(chan cc.BandwidthEstimator, 1)
congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) {
congestionController.OnNewPeerConnection(func(id string, estimator cc.BandwidthEstimator) { //nolint: revive
estimatorChan <- estimator
})

Expand Down
2 changes: 1 addition & 1 deletion examples/broadcast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func main() { // nolint:gocognit
localTrackChan := make(chan *webrtc.TrackLocalStaticRTP)
// Set a handler for when a new remote track starts, this just distributes all our packets
// to connected peers
peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(remoteTrack *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
// Create a local track, all our SFU clients will be fed via this track
localTrack, newTrackErr := webrtc.NewTrackLocalStaticRTP(remoteTrack.Codec().RTPCodecCapability, "video", "pion")
if newTrackErr != nil {
Expand Down
4 changes: 2 additions & 2 deletions examples/pion-to-pion/answer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func main() { // nolint:gocognit
// A HTTP handler that allows the other Pion instance to send us ICE candidates
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
// candidates which may be slower
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
candidate, candidateErr := ioutil.ReadAll(r.Body)
if candidateErr != nil {
panic(candidateErr)
Expand All @@ -91,7 +91,7 @@ func main() { // nolint:gocognit
})

// A HTTP handler that processes a SessionDescription given to us from the other Pion process
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { // nolint: revive
sdp := webrtc.SessionDescription{}
if err := json.NewDecoder(r.Body).Decode(&sdp); err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions examples/pion-to-pion/offer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func main() { //nolint:gocognit
// A HTTP handler that allows the other Pion instance to send us ICE candidates
// This allows us to add ICE candidates faster, we don't have to wait for STUN or TURN
// candidates which may be slower
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/candidate", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
candidate, candidateErr := ioutil.ReadAll(r.Body)
if candidateErr != nil {
panic(candidateErr)
Expand All @@ -91,7 +91,7 @@ func main() { //nolint:gocognit
})

// A HTTP handler that processes a SessionDescription given to us from the other Pion process
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) { //nolint: revive
sdp := webrtc.SessionDescription{}
if sdpErr := json.NewDecoder(r.Body).Decode(&sdp); sdpErr != nil {
panic(sdpErr)
Expand Down
2 changes: 1 addition & 1 deletion examples/reflect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func main() {

// Set a handler for when a new remote track starts, this handler copies inbound RTP packets,
// replaces the SSRC and sends them back
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
for {
// Read RTP packets being sent to Pion
Expand Down
2 changes: 1 addition & 1 deletion examples/rtp-forwarder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func main() {
// Set a handler for when a new remote track starts, this handler will forward data to
// our UDP listeners.
// In your application this is where you would handle/process audio/video
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
// Retrieve udp connection
c, ok := udpConns[track.Kind().String()]
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion examples/save-to-disk-av1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func main() {
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
// an ivf file, since we could have multiple video tracks we provide a counter.
// In your application this is where you would handle/process video
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
if strings.EqualFold(track.Codec().MimeType, webrtc.MimeTypeAV1) {
fmt.Println("Got AV1 track, saving to disk as output.ivf")
saveToDisk(ivfFile, track)
Expand Down
2 changes: 1 addition & 1 deletion examples/save-to-disk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func main() {
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
// an ivf file, since we could have multiple video tracks we provide a counter.
// In your application this is where you would handle/process video
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
codec := track.Codec()
if strings.EqualFold(codec.MimeType, webrtc.MimeTypeOpus) {
fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")
Expand Down
2 changes: 1 addition & 1 deletion examples/simulcast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func main() {
}

// Set a handler for when a new remote track starts
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
fmt.Println("Track has started")

// Start reading from all the streams and sending them to the related output track
Expand Down
2 changes: 1 addition & 1 deletion examples/stats/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func main() {

// Set a handler for when a new remote track starts. We read the incoming packets, but then
// immediately discard them
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
fmt.Printf("New incoming track with codec: %s\n", track.Codec().MimeType)

go func() {
Expand Down
2 changes: 1 addition & 1 deletion examples/swap-tracks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func main() { // nolint:gocognit
packets := make(chan *rtp.Packet, 60)

// Set a handler for when a new remote track starts
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) { //nolint: revive
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().MimeType)
trackNum := trackCount
trackCount++
Expand Down
2 changes: 1 addition & 1 deletion icetransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestICETransport_OnSelectedCandidatePairChange(t *testing.T) {
})

senderCalledCandidateChange := int32(0)
pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(pair *ICECandidatePair) {
pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(*ICECandidatePair) {
atomic.StoreInt32(&senderCalledCandidateChange, 1)
})

Expand Down
10 changes: 5 additions & 5 deletions interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestPeerConnection_Interceptor(t *testing.T) {
assert.NoError(t, err)

seenRTP, seenRTPCancel := context.WithCancel(context.Background())
answerer.OnTrack(func(track *TrackRemote, receiver *RTPReceiver) {
answerer.OnTrack(func(track *TrackRemote, _ *RTPReceiver) {
p, attributes, readErr := track.ReadRTP()
assert.NoError(t, readErr)

Expand Down Expand Up @@ -136,18 +136,18 @@ func Test_Interceptor_BindUnbind(t *testing.T) {
atomic.AddUint32(&cntBindRTCPWriter, 1)
return writer
},
BindLocalStreamFn: func(i *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
BindLocalStreamFn: func(_ *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
atomic.AddUint32(&cntBindLocalStream, 1)
return writer
},
UnbindLocalStreamFn: func(i *interceptor.StreamInfo) {
UnbindLocalStreamFn: func(*interceptor.StreamInfo) {
atomic.AddUint32(&cntUnbindLocalStream, 1)
},
BindRemoteStreamFn: func(i *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader {
BindRemoteStreamFn: func(_ *interceptor.StreamInfo, reader interceptor.RTPReader) interceptor.RTPReader {
atomic.AddUint32(&cntBindRemoteStream, 1)
return reader
},
UnbindRemoteStreamFn: func(i *interceptor.StreamInfo) {
UnbindRemoteStreamFn: func(_ *interceptor.StreamInfo) {
atomic.AddUint32(&cntUnbindRemoteStream, 1)
},
CloseFn: func() error {
Expand Down
20 changes: 10 additions & 10 deletions peerconnection_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ func TestPeerConnection_EventHandlers_Go(t *testing.T) {
assert.NotPanics(t, func() { pc.onTrack(nil, nil) })
assert.NotPanics(t, func() { pc.onICEConnectionStateChange(ICEConnectionStateNew) })

pc.OnTrack(func(t *TrackRemote, r *RTPReceiver) {
pc.OnTrack(func(*TrackRemote, *RTPReceiver) {
close(onTrackCalled)
})

pc.OnICEConnectionStateChange(func(cs ICEConnectionState) {
pc.OnICEConnectionStateChange(func(ICEConnectionState) {
close(onICEConnectionStateChangeCalled)
})

Expand Down Expand Up @@ -601,15 +601,15 @@ func TestPeerConnection_IceLite(t *testing.T) {
closePairNow(t, offerPC, answerPC)
}

t.Run("Offerer", func(t *testing.T) {
t.Run("Offerer", func(*testing.T) {
connectTwoAgents(true, false)
})

t.Run("Answerer", func(t *testing.T) {
t.Run("Answerer", func(*testing.T) {
connectTwoAgents(false, true)
})

t.Run("Both", func(t *testing.T) {
t.Run("Both", func(*testing.T) {
connectTwoAgents(true, true)
})
}
Expand Down Expand Up @@ -808,7 +808,7 @@ func TestMulticastDNSCandidates(t *testing.T) {
assert.NoError(t, signalPair(pcOffer, pcAnswer))

onDataChannel, onDataChannelCancel := context.WithCancel(context.Background())
pcAnswer.OnDataChannel(func(d *DataChannel) {
pcAnswer.OnDataChannel(func(*DataChannel) {
onDataChannelCancel()
})
<-onDataChannel.Done()
Expand Down Expand Up @@ -941,7 +941,7 @@ func TestICERestart_Error_Handling(t *testing.T) {
keepPackets.set(true)

// Add a filter that monitors the traffic on the router
wan.AddChunkFilter(func(c vnet.Chunk) bool {
wan.AddChunkFilter(func(vnet.Chunk) bool {
return keepPackets.get()
})

Expand Down Expand Up @@ -1361,21 +1361,21 @@ func TestPeerConnectionNilCallback(t *testing.T) {
assert.NoError(t, err)

pc.onSignalingStateChange(SignalingStateStable)
pc.OnSignalingStateChange(func(ss SignalingState) {
pc.OnSignalingStateChange(func(SignalingState) {
t.Error("OnSignalingStateChange called")
})
pc.OnSignalingStateChange(nil)
pc.onSignalingStateChange(SignalingStateStable)

pc.onConnectionStateChange(PeerConnectionStateNew)
pc.OnConnectionStateChange(func(pcs PeerConnectionState) {
pc.OnConnectionStateChange(func(PeerConnectionState) {
t.Error("OnConnectionStateChange called")
})
pc.OnConnectionStateChange(nil)
pc.onConnectionStateChange(PeerConnectionStateNew)

pc.onICEConnectionStateChange(ICEConnectionStateNew)
pc.OnICEConnectionStateChange(func(ics ICEConnectionState) {
pc.OnICEConnectionStateChange(func(ICEConnectionState) {
t.Error("OnConnectionStateChange called")
})
pc.OnICEConnectionStateChange(nil)
Expand Down
Loading

0 comments on commit 836f533

Please sign in to comment.