From 3e1f46acd19383dabe489c90182fe860cdc1808f Mon Sep 17 00:00:00 2001 From: Joe Turki Date: Sun, 12 Jan 2025 02:37:28 -0600 Subject: [PATCH] Remove funlen linter (#290) --- .golangci.yml | 2 +- abscapturetimeextension_test.go | 2 +- codecs/av1_packet_test.go | 4 ++-- codecs/common_test.go | 2 +- codecs/g711_packet_test.go | 2 +- codecs/g722_packet_test.go | 2 +- codecs/h264_packet.go | 4 ++-- codecs/h264_packet_test.go | 4 ++-- codecs/h265_packet.go | 4 ++-- codecs/h265_packet_test.go | 16 ++++++++-------- codecs/vp8_packet.go | 4 ++-- codecs/vp8_packet_test.go | 4 ++-- codecs/vp9/header.go | 2 +- codecs/vp9/header_test.go | 2 +- codecs/vp9_packet.go | 2 +- codecs/vp9_packet_test.go | 4 ++-- packet.go | 4 ++-- packet_test.go | 4 ++-- packetizer_test.go | 2 +- vlaextension_test.go | 6 +++--- 20 files changed, 38 insertions(+), 38 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 50211be..88cb4fb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -59,7 +59,6 @@ linters: - exportloopref # checks for pointers to enclosing loop variables - forbidigo # Forbids identifiers - forcetypeassert # finds forced type assertions - - funlen # Tool for detection of long functions - gci # Gci control golang package import order and make it always deterministic. - gochecknoglobals # Checks that no globals are present in Go code - gocognit # Computes and checks the cognitive complexity of functions @@ -106,6 +105,7 @@ linters: - whitespace # Tool for detection of leading and trailing whitespace disable: - depguard # Go linter that checks if package imports are in a list of acceptable packages + - funlen # Tool for detection of long functions - gochecknoinits # Checks that no init functions are present in Go code - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. - interfacebloat # A linter that checks length of interface. diff --git a/abscapturetimeextension_test.go b/abscapturetimeextension_test.go index 395e02b..60c397f 100644 --- a/abscapturetimeextension_test.go +++ b/abscapturetimeextension_test.go @@ -8,7 +8,7 @@ import ( "time" ) -func TestAbsCaptureTimeExtension_Roundtrip(t *testing.T) { // nolint: funlen,cyclop +func TestAbsCaptureTimeExtension_Roundtrip(t *testing.T) { //nolint:cyclop t.Run("positive captureClockOffset", func(t *testing.T) { t0 := time.Now() e1 := NewAbsCaptureTimeExtension(t0) diff --git a/codecs/av1_packet_test.go b/codecs/av1_packet_test.go index bbe6a8f..8330ab8 100644 --- a/codecs/av1_packet_test.go +++ b/codecs/av1_packet_test.go @@ -12,7 +12,7 @@ import ( "github.com/pion/rtp/codecs/av1/obu" ) -func TestAV1_Marshal(t *testing.T) { // nolint:funlen,cyclop +func TestAV1_Marshal(t *testing.T) { //nolint:cyclop payloader := &AV1Payloader{} t.Run("Unfragmented OBU", func(t *testing.T) { @@ -103,7 +103,7 @@ func TestAV1_Unmarshal_Error(t *testing.T) { } } -func TestAV1_Unmarshal(t *testing.T) { // nolint: funlen +func TestAV1_Unmarshal(t *testing.T) { // nolint: dupl av1Payload := []byte{ 0x68, 0x0c, 0x08, 0x00, 0x00, 0x00, 0x2c, diff --git a/codecs/common_test.go b/codecs/common_test.go index 5955c60..c472d2a 100644 --- a/codecs/common_test.go +++ b/codecs/common_test.go @@ -24,7 +24,7 @@ func TestCommon_Min(t *testing.T) { } } -func TestZeroAllocations(t *testing.T) { // nolint: funlen, maintidx +func TestZeroAllocations(t *testing.T) { //nolint:maintidx type unmarshaller interface { Unmarshal(data []byte) ([]byte, error) } diff --git a/codecs/g711_packet_test.go b/codecs/g711_packet_test.go index bde1da3..2056327 100644 --- a/codecs/g711_packet_test.go +++ b/codecs/g711_packet_test.go @@ -10,7 +10,7 @@ import ( "testing" ) -func TestG711Payloader(t *testing.T) { // nolint:funlen +func TestG711Payloader(t *testing.T) { payloader := G711Payloader{} const ( diff --git a/codecs/g722_packet_test.go b/codecs/g722_packet_test.go index 2bfa04c..d098e73 100644 --- a/codecs/g722_packet_test.go +++ b/codecs/g722_packet_test.go @@ -10,7 +10,7 @@ import ( "testing" ) -func TestG722Payloader(t *testing.T) { // nolint:funlen +func TestG722Payloader(t *testing.T) { payloader := G722Payloader{} const ( diff --git a/codecs/h264_packet.go b/codecs/h264_packet.go index e97a880..0e199f5 100644 --- a/codecs/h264_packet.go +++ b/codecs/h264_packet.go @@ -66,7 +66,7 @@ func emitNalus(nals []byte, emit func([]byte)) { } // Payload fragments a H264 packet across one or more byte arrays. -func (p *H264Payloader) Payload(mtu uint16, payload []byte) [][]byte { // nolint:funlen,cyclop +func (p *H264Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint:cyclop var payloads [][]byte if len(payload) == 0 { return payloads @@ -221,7 +221,7 @@ func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) { return p.parseBody(payload) } -func (p *H264Packet) parseBody(payload []byte) ([]byte, error) { // nolint:funlen,cyclop +func (p *H264Packet) parseBody(payload []byte) ([]byte, error) { //nolint:cyclop if len(payload) == 0 { return nil, fmt.Errorf("%w: %d <=0", errShortPacket, len(payload)) } diff --git a/codecs/h264_packet_test.go b/codecs/h264_packet_test.go index f405782..a807c10 100644 --- a/codecs/h264_packet_test.go +++ b/codecs/h264_packet_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func TestH264Payloader_Payload(t *testing.T) { // nolint:funlen,cyclop +func TestH264Payloader_Payload(t *testing.T) { //nolint:cyclop pck := H264Payloader{} smallpayload := []byte{0x90, 0x90, 0x90} multiplepayload := []byte{0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x01, 0x90} @@ -94,7 +94,7 @@ func TestH264Payloader_Payload(t *testing.T) { // nolint:funlen,cyclop } } -func TestH264Packet_Unmarshal(t *testing.T) { // nolint:funlen,cyclop +func TestH264Packet_Unmarshal(t *testing.T) { //nolint:cyclop singlePayload := []byte{0x90, 0x90, 0x90} singlePayloadUnmarshaled := []byte{0x00, 0x00, 0x00, 0x01, 0x90, 0x90, 0x90} singlePayloadUnmarshaledAVC := []byte{0x00, 0x00, 0x00, 0x03, 0x90, 0x90, 0x90} diff --git a/codecs/h265_packet.go b/codecs/h265_packet.go index 591566d..ff24f08 100644 --- a/codecs/h265_packet.go +++ b/codecs/h265_packet.go @@ -300,7 +300,7 @@ func (p *H265AggregationPacket) WithDONL(value bool) { } // Unmarshal parses the passed byte slice and stores the result in the H265AggregationPacket this method is called upon. -func (p *H265AggregationPacket) Unmarshal(payload []byte) ([]byte, error) { // nolint: funlen, cyclop +func (p *H265AggregationPacket) Unmarshal(payload []byte) ([]byte, error) { //nolint:cyclop // sizeof(headers) const totalHeaderSize = h265NaluHeaderSize if payload == nil { @@ -860,7 +860,7 @@ type H265Payloader struct { } // Payload fragments a H265 packet across one or more byte arrays. -func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint: gocognit,cyclop,funlen +func (p *H265Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint:gocognit,cyclop var payloads [][]byte if len(payload) == 0 || mtu == 0 { return payloads diff --git a/codecs/h265_packet_test.go b/codecs/h265_packet_test.go index e756627..dff6a84 100644 --- a/codecs/h265_packet_test.go +++ b/codecs/h265_packet_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func TestH265_NALU_Header(t *testing.T) { // nolint: funlen +func TestH265_NALU_Header(t *testing.T) { tt := [...]struct { RawHeader []byte @@ -105,7 +105,7 @@ func TestH265_NALU_Header(t *testing.T) { // nolint: funlen } } -func TestH265_FU_Header(t *testing.T) { // nolint:funlen +func TestH265_FU_Header(t *testing.T) { tt := [...]struct { header H265FragmentationUnitHeader @@ -172,7 +172,7 @@ func TestH265_FU_Header(t *testing.T) { // nolint:funlen } } -func TestH265_SingleNALUnitPacket(t *testing.T) { // nolint:funlen,cyclop +func TestH265_SingleNALUnitPacket(t *testing.T) { //nolint:cyclop tt := [...]struct { Raw []byte WithDONL bool @@ -269,7 +269,7 @@ func TestH265_SingleNALUnitPacket(t *testing.T) { // nolint:funlen,cyclop } } -func TestH265_AggregationPacket(t *testing.T) { // nolint:funlen,cyclop +func TestH265_AggregationPacket(t *testing.T) { //nolint:cyclop tt := [...]struct { Raw []byte WithDONL bool @@ -436,7 +436,7 @@ func TestH265_AggregationPacket(t *testing.T) { // nolint:funlen,cyclop } } -func TestH265_FragmentationUnitPacket(t *testing.T) { // nolint:funlen,cyclop +func TestH265_FragmentationUnitPacket(t *testing.T) { //nolint:cyclop tt := [...]struct { Raw []byte WithDONL bool @@ -595,7 +595,7 @@ func TestH265_TemporalScalabilityControlInformation(t *testing.T) { } } -func TestH265_PACI_Packet(t *testing.T) { // nolint:funlen, cyclop +func TestH265_PACI_Packet(t *testing.T) { //nolint:cyclop tt := [...]struct { Raw []byte ExpectedFU *H265PACIPacket @@ -723,7 +723,7 @@ func TestH265_PACI_Packet(t *testing.T) { // nolint:funlen, cyclop } } -func TestH265_Packet(t *testing.T) { // nolint: funlen +func TestH265_Packet(t *testing.T) { tt := [...]struct { Raw []byte WithDONL bool @@ -873,7 +873,7 @@ func TestH265_Packet_Real(t *testing.T) { } } -func TestH265Payloader_Payload(t *testing.T) { // nolint: funlen +func TestH265Payloader_Payload(t *testing.T) { tt := []struct { Name string Data []byte diff --git a/codecs/vp8_packet.go b/codecs/vp8_packet.go index 2634d5a..64471f8 100644 --- a/codecs/vp8_packet.go +++ b/codecs/vp8_packet.go @@ -14,7 +14,7 @@ const ( ) // Payload fragments a VP8 packet across one or more byte arrays. -func (p *VP8Payloader) Payload(mtu uint16, payload []byte) [][]byte { // nolint:funlen,cyclop +func (p *VP8Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint:cyclop /* * https://tools.ietf.org/html/rfc7741#section-4.2 * @@ -123,7 +123,7 @@ type VP8Packet struct { } // Unmarshal parses the passed byte slice and stores the result in the VP8Packet this method is called upon. -func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) { // nolint: gocognit, funlen, cyclop +func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) { //nolint:gocognit,cyclop if payload == nil { return nil, errNilPacket } diff --git a/codecs/vp8_packet_test.go b/codecs/vp8_packet_test.go index 4224074..446bbe1 100644 --- a/codecs/vp8_packet_test.go +++ b/codecs/vp8_packet_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func TestVP8Packet_Unmarshal(t *testing.T) { // nolint: funlen, cyclop +func TestVP8Packet_Unmarshal(t *testing.T) { //nolint:cyclop pck := VP8Packet{} // Nil packet @@ -134,7 +134,7 @@ func TestVP8Packet_Unmarshal(t *testing.T) { // nolint: funlen, cyclop } } -func TestVP8Payloader_Payload(t *testing.T) { // nolint: funlen +func TestVP8Payloader_Payload(t *testing.T) { testCases := map[string]struct { payloader VP8Payloader mtu uint16 diff --git a/codecs/vp9/header.go b/codecs/vp9/header.go index ed49335..2631474 100644 --- a/codecs/vp9/header.go +++ b/codecs/vp9/header.go @@ -119,7 +119,7 @@ type Header struct { } // Unmarshal decodes a Header. -func (h *Header) Unmarshal(buf []byte) error { // nolint:funlen,cyclop +func (h *Header) Unmarshal(buf []byte) error { //nolint:cyclop pos := 0 err := hasSpace(buf, pos, 4) diff --git a/codecs/vp9/header_test.go b/codecs/vp9/header_test.go index eccc71b..41fb46a 100644 --- a/codecs/vp9/header_test.go +++ b/codecs/vp9/header_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func TestHeaderUnmarshal(t *testing.T) { // nolint: funlen +func TestHeaderUnmarshal(t *testing.T) { cases := []struct { name string byts []byte diff --git a/codecs/vp9_packet.go b/codecs/vp9_packet.go index 4c2306e..57bd46e 100644 --- a/codecs/vp9_packet.go +++ b/codecs/vp9_packet.go @@ -110,7 +110,7 @@ func (p *VP9Payloader) payloadFlexible(mtu uint16, payload []byte) [][]byte { return payloads } -func (p *VP9Payloader) payloadNonFlexible(mtu uint16, payload []byte) [][]byte { // nolint:funlen,cyclop +func (p *VP9Payloader) payloadNonFlexible(mtu uint16, payload []byte) [][]byte { //nolint:cyclop /* * Non-flexible mode (F=0) * 0 1 2 3 4 5 6 7 diff --git a/codecs/vp9_packet_test.go b/codecs/vp9_packet_test.go index 4534903..1073365 100644 --- a/codecs/vp9_packet_test.go +++ b/codecs/vp9_packet_test.go @@ -10,7 +10,7 @@ import ( "testing" ) -func TestVP9Packet_Unmarshal(t *testing.T) { // nolint: funlen +func TestVP9Packet_Unmarshal(t *testing.T) { cases := map[string]struct { b []byte pkt VP9Packet @@ -214,7 +214,7 @@ func TestVP9Packet_Unmarshal(t *testing.T) { // nolint: funlen } } -func TestVP9Payloader_Payload(t *testing.T) { // nolint: funlen, cyclop +func TestVP9Payloader_Payload(t *testing.T) { //nolint:cyclop r0 := int(rand.New(rand.NewSource(0)).Int31n(0x7FFF)) //nolint:gosec var rands [][2]byte for i := 0; i < 10; i++ { diff --git a/packet.go b/packet.go index e2eaf1a..c51d8c7 100644 --- a/packet.go +++ b/packet.go @@ -85,7 +85,7 @@ func (p Packet) String() string { // Unmarshal parses the passed byte slice and stores the result in the Header. // It returns the number of bytes read n and any error. -func (h *Header) Unmarshal(buf []byte) (n int, err error) { // nolint: funlen,gocognit,cyclop +func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit,cyclop if len(buf) < headerLength { return 0, fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficient, len(buf), headerLength) } @@ -246,7 +246,7 @@ func (h Header) Marshal() (buf []byte, err error) { } // MarshalTo serializes the header and writes to the buffer. -func (h Header) MarshalTo(buf []byte) (n int, err error) { // nolint: funlen, cyclop +func (h Header) MarshalTo(buf []byte) (n int, err error) { //nolint:cyclop /* * 0 1 2 3 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 diff --git a/packet_test.go b/packet_test.go index 0813ee0..fd58088 100644 --- a/packet_test.go +++ b/packet_test.go @@ -12,7 +12,7 @@ import ( "testing" ) -func TestBasic(t *testing.T) { // nolint:funlen,maintidx,cyclop +func TestBasic(t *testing.T) { // nolint:maintidx,cyclop packet := &Packet{} if err := packet.Unmarshal([]byte{}); err == nil { @@ -441,7 +441,7 @@ func TestRFC8285OneByteTwoExtensionOfTwoBytes(t *testing.T) { } } -func TestRFC8285OneByteMultipleExtensionsWithPadding(t *testing.T) { // nolint:funlen +func TestRFC8285OneByteMultipleExtensionsWithPadding(t *testing.T) { packet := &Packet{} // 0 1 2 3 diff --git a/packetizer_test.go b/packetizer_test.go index 2842a05..765d44e 100644 --- a/packetizer_test.go +++ b/packetizer_test.go @@ -75,7 +75,7 @@ func TestPacketizer_AbsSendTime(t *testing.T) { } } -func TestPacketizer_Roundtrip(t *testing.T) { // nolint:funlen, cyclop +func TestPacketizer_Roundtrip(t *testing.T) { //nolint:cyclop multiplepayload := make([]byte, 128) packetizer := NewPacketizer(100, 98, 0x1234ABCD, &codecs.G722Payloader{}, NewRandomSequencer(), 90000) packets := packetizer.Packetize(multiplepayload, 1000) diff --git a/vlaextension_test.go b/vlaextension_test.go index 73e9595..e25d87a 100644 --- a/vlaextension_test.go +++ b/vlaextension_test.go @@ -11,7 +11,7 @@ import ( "testing" ) -func TestVLAMarshal(t *testing.T) { // nolint: funlen,cyclop +func TestVLAMarshal(t *testing.T) { //nolint:cyclop requireNoError := func(t *testing.T, err error) { t.Helper() @@ -244,7 +244,7 @@ func TestVLAMarshal(t *testing.T) { // nolint: funlen,cyclop }) } -func TestVLAUnmarshal(t *testing.T) { // nolint: funlen +func TestVLAUnmarshal(t *testing.T) { requireEqualInt := func(t *testing.T, expected, actual int) { t.Helper() @@ -435,7 +435,7 @@ func TestVLAUnmarshal(t *testing.T) { // nolint: funlen }) } -func TestVLAMarshalThenUnmarshal(t *testing.T) { // nolint:funlen, cyclop +func TestVLAMarshalThenUnmarshal(t *testing.T) { //nolint:cyclop requireEqualInt := func(t *testing.T, expected, actual int) { t.Helper()