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 Mar 16, 2024
1 parent 5574fda commit 240c612
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion examples/nack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func sendRoutine() {
streamWriter := chain.BindLocalStream(&interceptor.StreamInfo{
SSRC: ssrc,
RTCPFeedback: []interceptor.RTCPFeedback{{Type: "nack", Parameter: ""}},
}, interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
}, interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, _ interceptor.Attributes) (int, error) {
headerBuf, err := header.Marshal()
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions internal/test/mock_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewMockStream(info *interceptor.StreamInfo, i interceptor.Interceptor) *Moc
rtcpInModified: make(chan RTCPWithError, 1000),
rtpInModified: make(chan RTPWithError, 1000),
}
s.rtcpWriter = i.BindRTCPWriter(interceptor.RTCPWriterFunc(func(pkts []rtcp.Packet, attributes interceptor.Attributes) (int, error) {
s.rtcpWriter = i.BindRTCPWriter(interceptor.RTCPWriterFunc(func(pkts []rtcp.Packet, _ interceptor.Attributes) (int, error) {
select {
case s.rtcpOutModified <- pkts:
default:
Expand All @@ -79,7 +79,7 @@ func NewMockStream(info *interceptor.StreamInfo, i interceptor.Interceptor) *Moc
copy(b, marshaled)
return len(marshaled), a, err
}))
s.rtpWriter = i.BindLocalStream(info, interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
s.rtpWriter = i.BindLocalStream(info, interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, _ interceptor.Attributes) (int, error) {
select {
case s.rtpOutModified <- &rtp.Packet{Header: *header, Payload: payload}:
default:
Expand Down
4 changes: 2 additions & 2 deletions pkg/flexfec/encoder_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (r *FecInterceptor) BindLocalStream(info *interceptor.StreamInfo, writer in
if len(r.packetBuffer) == int(r.minNumMediaPackets) {
fecPackets = r.flexFecEncoder.EncodeFec(r.packetBuffer, 2)

for _, fecPacket := range fecPackets {
fecResult, fecErr := writer.Write(&fecPacket.Header, fecPacket.Payload, attributes)
for i := range fecPackets {
fecResult, fecErr := writer.Write(&(fecPackets[i].Header), fecPackets[i].Payload, attributes)

if fecErr != nil && fecResult == 0 {
break
Expand Down
2 changes: 1 addition & 1 deletion pkg/intervalpli/generator_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *GeneratorInterceptor) loop(rtcpWriter interceptor.RTCPWriter) {
case <-tickerChan:
ssrcs := make([]uint32, 0)

r.streams.Range(func(k, value interface{}) bool {
r.streams.Range(func(k, _ interface{}) bool {
key, ok := k.(uint32)
if !ok {
return false
Expand Down
12 changes: 6 additions & 6 deletions pkg/jitterbuffer/jitter_buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func TestJitterBuffer(t *testing.T) {
assert := assert.New(t)
t.Run("Appends packets in order", func(t *testing.T) {
t.Run("Appends packets in order", func(*testing.T) {
jb := New()
assert.Equal(jb.lastSequence, uint16(0))
jb.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: 5000, Timestamp: 500}, Payload: []byte{0x02}})
Expand All @@ -30,7 +30,7 @@ func TestJitterBuffer(t *testing.T) {
assert.Equal(jb.lastSequence, uint16(5012))
})

t.Run("Appends packets and begins playout", func(t *testing.T) {
t.Run("Appends packets and begins playout", func(*testing.T) {
jb := New()
for i := 0; i < 100; i++ {
jb.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: uint16(5012 + i), Timestamp: uint32(512 + i)}, Payload: []byte{0x02}})
Expand All @@ -42,7 +42,7 @@ func TestJitterBuffer(t *testing.T) {
assert.Equal(head.SequenceNumber, uint16(5012))
assert.Equal(err, nil)
})
t.Run("Wraps playout correctly", func(t *testing.T) {
t.Run("Wraps playout correctly", func(*testing.T) {
jb := New()
for i := 0; i < 100; i++ {
sqnum := uint16((math.MaxUint16 - 32 + i) % math.MaxUint16)
Expand All @@ -64,7 +64,7 @@ func TestJitterBuffer(t *testing.T) {
}
}
})
t.Run("Pops at timestamp correctly", func(t *testing.T) {
t.Run("Pops at timestamp correctly", func(*testing.T) {
jb := New()
for i := 0; i < 100; i++ {
sqnum := uint16((math.MaxUint16 - 32 + i) % math.MaxUint16)
Expand All @@ -83,7 +83,7 @@ func TestJitterBuffer(t *testing.T) {
assert.Equal(head.SequenceNumber, uint16(math.MaxUint16-32))
assert.Equal(err, nil)
})
t.Run("Can peek at a packet", func(t *testing.T) {
t.Run("Can peek at a packet", func(*testing.T) {
jb := New()
jb.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: 5000, Timestamp: 500}, Payload: []byte{0x02}})
jb.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: 5001, Timestamp: 501}, Payload: []byte{0x02}})
Expand All @@ -99,7 +99,7 @@ func TestJitterBuffer(t *testing.T) {
assert.Equal(pkt.SequenceNumber, uint16(5000))
assert.Equal(err, nil)
})
t.Run("Pops at timestamp with multiple packets", func(t *testing.T) {
t.Run("Pops at timestamp with multiple packets", func(*testing.T) {
jb := New()
for i := 0; i < 50; i++ {
sqnum := uint16((math.MaxUint16 - 32 + i) % math.MaxUint16)
Expand Down
10 changes: 5 additions & 5 deletions pkg/jitterbuffer/priority_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

func TestPriorityQueue(t *testing.T) {
assert := assert.New(t)
t.Run("Appends packets in order", func(t *testing.T) {
t.Run("Appends packets in order", func(*testing.T) {
pkt := &rtp.Packet{Header: rtp.Header{SequenceNumber: 5000, Timestamp: 500}, Payload: []byte{0x02}}
q := NewQueue()
q.Push(pkt, pkt.SequenceNumber)
Expand All @@ -22,7 +22,7 @@ func TestPriorityQueue(t *testing.T) {
assert.Equal(q.next.prio, uint16(5000))
assert.Equal(q.next.next.prio, uint16(5004))
})
t.Run("Appends many in order", func(t *testing.T) {
t.Run("Appends many in order", func(*testing.T) {
q := NewQueue()
for i := 0; i < 100; i++ {
q.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: uint16(5012 + i), Timestamp: uint32(512 + i)}, Payload: []byte{0x02}}, uint16(5012+i))
Expand All @@ -40,7 +40,7 @@ func TestPriorityQueue(t *testing.T) {
assert.Equal(q.next.prio, uint16(5012))
assert.Equal(last.prio, uint16(5012+99))
})
t.Run("Can remove an element", func(t *testing.T) {
t.Run("Can remove an element", func(*testing.T) {
pkt := &rtp.Packet{Header: rtp.Header{SequenceNumber: 5000, Timestamp: 500}, Payload: []byte{0x02}}
q := NewQueue()
q.Push(pkt, pkt.SequenceNumber)
Expand All @@ -55,7 +55,7 @@ func TestPriorityQueue(t *testing.T) {
nextPop, _ := q.Pop()
assert.Equal(nextPop.SequenceNumber, uint16(5012))
})
t.Run("Appends in order", func(t *testing.T) {
t.Run("Appends in order", func(*testing.T) {
q := NewQueue()
for i := 0; i < 100; i++ {
q.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: uint16(5012 + i), Timestamp: uint32(512 + i)}, Payload: []byte{0x02}}, uint16(5012+i))
Expand All @@ -67,7 +67,7 @@ func TestPriorityQueue(t *testing.T) {
assert.Equal(uint16(101), q.Length())
assert.Equal(q.next.prio, uint16(5000))
})
t.Run("Can find", func(t *testing.T) {
t.Run("Can find", func(*testing.T) {
q := NewQueue()
for i := 0; i < 100; i++ {
q.Push(&rtp.Packet{Header: rtp.Header{SequenceNumber: uint16(5012 + i), Timestamp: uint32(512 + i)}, Payload: []byte{0x02}}, uint16(5012+i))
Expand Down
8 changes: 4 additions & 4 deletions pkg/mock/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ func TestInterceptor(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
4 changes: 2 additions & 2 deletions pkg/packetdump/packet_dumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func NewPacketDumper(opts ...PacketDumperOption) (*PacketDumper, error) {
rtcpStream: os.Stdout,
rtpFormat: DefaultRTPFormatter,
rtcpFormat: DefaultRTCPFormatter,
rtpFilter: func(pkt *rtp.Packet) bool {
rtpFilter: func(*rtp.Packet) bool {
return true
},
rtcpFilter: func(pkt []rtcp.Packet) bool {
rtcpFilter: func([]rtcp.Packet) bool {
return true
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/packetdump/receiver_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestReceiverFilterEverythingOut(t *testing.T) {
RTPWriter(&buf),
RTCPWriter(&buf),
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
RTPFilter(func(pkt *rtp.Packet) bool {
RTPFilter(func(*rtp.Packet) bool {
return false
}),
RTCPFilter(func(pkt []rtcp.Packet) bool {
RTCPFilter(func([]rtcp.Packet) bool {
return false
}),
)
Expand Down Expand Up @@ -70,10 +70,10 @@ func TestReceiverFilterNothing(t *testing.T) {
RTPWriter(&buf),
RTCPWriter(&buf),
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
RTPFilter(func(pkt *rtp.Packet) bool {
RTPFilter(func(*rtp.Packet) bool {
return true
}),
RTCPFilter(func(pkt []rtcp.Packet) bool {
RTCPFilter(func([]rtcp.Packet) bool {
return true
}),
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/packetdump/sender_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func TestSenderFilterEverythingOut(t *testing.T) {
RTPWriter(&buf),
RTCPWriter(&buf),
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
RTPFilter(func(pkt *rtp.Packet) bool {
RTPFilter(func(*rtp.Packet) bool {
return false
}),
RTCPFilter(func(pkt []rtcp.Packet) bool {
RTCPFilter(func([]rtcp.Packet) bool {
return false
}),
)
Expand Down Expand Up @@ -73,10 +73,10 @@ func TestSenderFilterNothing(t *testing.T) {
RTPWriter(&buf),
RTCPWriter(&buf),
Log(logging.NewDefaultLoggerFactory().NewLogger("test")),
RTPFilter(func(pkt *rtp.Packet) bool {
RTPFilter(func(*rtp.Packet) bool {
return true
}),
RTCPFilter(func(pkt []rtcp.Packet) bool {
RTCPFilter(func([]rtcp.Packet) bool {
return true
}),
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/receiver_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (r *ReceiverInterceptor) loop(rtcpWriter interceptor.RTCPWriter) {
select {
case <-ticker.C:
now := r.now()
r.streams.Range(func(key, value interface{}) bool {
r.streams.Range(func(_, value interface{}) bool {
if stream, ok := value.(*receiverStream); !ok {
r.log.Warnf("failed to cast ReceiverInterceptor stream")
} else if _, err := rtcpWriter.Write([]rtcp.Packet{stream.generateReport(now)}, interceptor.Attributes{}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/sender_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *SenderInterceptor) loop(rtcpWriter interceptor.RTCPWriter) {
select {
case <-ticker.Ch():
now := s.now()
s.streams.Range(func(key, value interface{}) bool {
s.streams.Range(func(_, value interface{}) bool {
if stream, ok := value.(*senderStream); !ok {
s.log.Warnf("failed to cast SenderInterceptor stream")
} else if _, err := rtcpWriter.Write([]rtcp.Packet{stream.generateReport(now)}, interceptor.Attributes{}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/report/sender_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestSenderInterceptor(t *testing.T) {
SenderInterval(time.Millisecond*50),
SenderLog(logging.NewDefaultLoggerFactory().NewLogger("test")),
SenderNow(mNow.Now),
SenderTicker(func(d time.Duration) Ticker { return mTick }),
SenderTicker(func(time.Duration) Ticker { return mTick }),
enableStartTracking(loopStarted),
)
assert.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/rfc8888/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestInterceptor(t *testing.T) {
C: make(chan time.Time),
}
f, err := NewSenderInterceptor(
SenderTicker(func(d time.Duration) ticker {
SenderTicker(func(time.Duration) ticker {
return mTick
}),
SenderNow(mNow.Now),
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestInterceptor(t *testing.T) {
C: make(chan time.Time),
}
f, err := NewSenderInterceptor(
SenderTicker(func(d time.Duration) ticker {
SenderTicker(func(time.Duration) ticker {
return mTick
}),
SenderNow(mNow.Now),
Expand Down
2 changes: 1 addition & 1 deletion pkg/stats/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestInterceptor(t *testing.T) {
mockRecorder := newMockRecorder()
now := time.Now()
f, err := NewInterceptor(
SetRecorderFactory(func(ssrc uint32, clockRate float64) Recorder {
SetRecorderFactory(func(uint32, float64) Recorder {
return mockRecorder
}),
SetNowFunc(func() time.Time {
Expand Down
2 changes: 1 addition & 1 deletion pkg/twcc/header_extension_interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestHeaderExtensionInterceptor(t *testing.T) {
URI: transportCCURI,
ID: 1,
},
}}, interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
}}, interceptor.RTPWriterFunc(func(*rtp.Header, []byte, interceptor.Attributes) (int, error) {
return 0, io.EOF
}))

Expand Down

0 comments on commit 240c612

Please sign in to comment.