Skip to content

Commit

Permalink
Remove funlen linter
Browse files Browse the repository at this point in the history
  • Loading branch information
joeturki committed Jan 12, 2025
1 parent f1c7226 commit acd8043
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion abscapturetimeextension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions codecs/av1_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion codecs/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion codecs/g711_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
)

func TestG711Payloader(t *testing.T) { // nolint:funlen
func TestG711Payloader(t *testing.T) {
payloader := G711Payloader{}

const (
Expand Down
2 changes: 1 addition & 1 deletion codecs/g722_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
)

func TestG722Payloader(t *testing.T) { // nolint:funlen
func TestG722Payloader(t *testing.T) {
payloader := G722Payloader{}

const (
Expand Down
4 changes: 2 additions & 2 deletions codecs/h264_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions codecs/h264_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions codecs/h265_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions codecs/h265_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions codecs/vp8_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions codecs/vp8_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion codecs/vp9/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion codecs/vp9/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
)

func TestHeaderUnmarshal(t *testing.T) { // nolint: funlen
func TestHeaderUnmarshal(t *testing.T) {
cases := []struct {
name string
byts []byte
Expand Down
2 changes: 1 addition & 1 deletion codecs/vp9_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions codecs/vp9_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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++ {
Expand Down
4 changes: 2 additions & 2 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packetizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions vlaextension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit acd8043

Please sign in to comment.