Skip to content

Commit 9d49944

Browse files
authored
Remove funlen linter (#433)
1 parent d6b6f05 commit 9d49944

33 files changed

+40
-40
lines changed

.golangci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ linters:
5959
- exportloopref # checks for pointers to enclosing loop variables
6060
- forbidigo # Forbids identifiers
6161
- forcetypeassert # finds forced type assertions
62-
- funlen # Tool for detection of long functions
6362
- gci # Gci control golang package import order and make it always deterministic.
6463
- gochecknoglobals # Checks that no globals are present in Go code
6564
- gocognit # Computes and checks the cognitive complexity of functions
@@ -106,6 +105,7 @@ linters:
106105
- whitespace # Tool for detection of leading and trailing whitespace
107106
disable:
108107
- depguard # Go linter that checks if package imports are in a list of acceptable packages
108+
- funlen # Tool for detection of long functions
109109
- gochecknoinits # Checks that no init functions are present in Go code
110110
- 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.
111111
- interfacebloat # A linter that checks length of interface.
@@ -135,4 +135,4 @@ issues:
135135
# Allow forbidden identifiers in CLI commands
136136
- path: cmd
137137
linters:
138-
- forbidigo
138+
- forbidigo

client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (c *Client) SendBindingRequest() (net.Addr, error) {
240240
return c.SendBindingRequestTo(c.stunServerAddr)
241241
}
242242

243-
func (c *Client) sendAllocateRequest(protocol proto.Protocol) ( // nolint:cyclop,funlen
243+
func (c *Client) sendAllocateRequest(protocol proto.Protocol) ( //nolint:cyclop
244244
proto.RelayedAddress,
245245
proto.Lifetime,
246246
stun.Nonce,
@@ -507,7 +507,7 @@ func (c *Client) HandleInbound(data []byte, from net.Addr) (bool, error) {
507507
return false, nil
508508
}
509509

510-
func (c *Client) handleSTUNMessage(data []byte, from net.Addr) error { // nolint:cyclop,funlen
510+
func (c *Client) handleSTUNMessage(data []byte, from net.Addr) error { //nolint:cyclop
511511
raw := make([]byte, len(data))
512512
copy(raw, data)
513513

client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func createListeningTestClientWithSTUNServ(t *testing.T, loggerFactory logging.L
6565
return c, conn, true
6666
}
6767

68-
func TestClientWithSTUN(t *testing.T) { // nolint:funlen
68+
func TestClientWithSTUN(t *testing.T) {
6969
loggerFactory := logging.NewDefaultLoggerFactory()
7070
log := loggerFactory.NewLogger("test")
7171

@@ -198,7 +198,7 @@ func TestClientNonceExpiration(t *testing.T) {
198198
}
199199

200200
// Create a TCP-based allocation and verify allocation can be created.
201-
func TestTCPClient(t *testing.T) { // nolint:funlen
201+
func TestTCPClient(t *testing.T) {
202202
// Setup server
203203
tcpListener, err := net.Listen("tcp4", "0.0.0.0:13478") //nolint: gosec
204204
require.NoError(t, err)

examples/turn-client/tcp-alloc/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func setupSignalingChannel(addrCh chan string, signaling bool, relayAddr string)
6161
}
6262
}
6363

64-
func main() { // nolint:funlen,cyclop
64+
func main() { //nolint:cyclop
6565
host := flag.String("host", "", "TURN Server name.")
6666
port := flag.Int("port", 3478, "Listening port.")
6767
user := flag.String("user", "", "A pair of username and password (e.g. \"user=pass\")")

examples/turn-client/tcp/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/pion/turn/v4"
1717
)
1818

19-
func main() { // nolint:funlen,cyclop
19+
func main() { //nolint:cyclop
2020
host := flag.String("host", "", "TURN Server name.")
2121
port := flag.Int("port", 3478, "Listening port.")
2222
user := flag.String("user", "", "A pair of username and password (e.g. \"user=pass\")")
@@ -92,7 +92,7 @@ func main() { // nolint:funlen,cyclop
9292
}
9393
}
9494

95-
func doPingTest(client *turn.Client, relayConn net.PacketConn) error { // nolint:cyclop,funlen
95+
func doPingTest(client *turn.Client, relayConn net.PacketConn) error { //nolint:cyclop
9696
// Send BindingRequest to learn our external IP
9797
mappedAddr, err := client.SendBindingRequest()
9898
if err != nil {

examples/turn-client/udp/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/pion/turn/v4"
1717
)
1818

19-
func main() { // nolint:funlen,cyclop
19+
func main() { //nolint:cyclop
2020
host := flag.String("host", "", "TURN Server name.")
2121
port := flag.Int("port", 3478, "Listening port.")
2222
user := flag.String("user", "", "A pair of username and password (e.g. \"user=pass\")")
@@ -96,7 +96,7 @@ func main() { // nolint:funlen,cyclop
9696
}
9797
}
9898

99-
func doPingTest(client *turn.Client, relayConn net.PacketConn) error { // nolint:cyclop,funlen
99+
func doPingTest(client *turn.Client, relayConn net.PacketConn) error { //nolint:cyclop
100100
// Send BindingRequest to learn our external IP
101101
mappedAddr, err := client.SendBindingRequest()
102102
if err != nil {

examples/turn-server/add-software-attribute/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (s *attributeAdder) WriteTo(payload []byte, addr net.Addr) (n int, err erro
4343
return s.PacketConn.WriteTo(payload, addr)
4444
}
4545

46-
func main() { // nolint:funlen
46+
func main() {
4747
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
4848
port := flag.Int("port", 3478, "Listening port.")
4949
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/log/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (s *stunLogger) ReadFrom(p []byte) (n int, addr net.Addr, err error) {
5151
return
5252
}
5353

54-
func main() { // nolint:funlen
54+
func main() {
5555
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
5656
port := flag.Int("port", 3478, "Listening port.")
5757
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/perm-filter/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/pion/turn/v4"
2222
)
2323

24-
func main() { // nolint:funlen
24+
func main() {
2525
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2626
port := flag.Int("port", 3478, "Listening port.")
2727
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/port-range/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/pion/turn/v4"
1919
)
2020

21-
func main() { // nolint:funlen
21+
func main() {
2222
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2323
port := flag.Int("port", 3478, "Listening port.")
2424
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/simple-multithreaded/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"golang.org/x/sys/unix"
2222
)
2323

24-
func main() { // nolint:funlen,cyclop
24+
func main() { //nolint:cyclop
2525
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2626
port := flag.Int("port", 3478, "Listening port.")
2727
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/pion/turn/v4"
1818
)
1919

20-
func main() { // nolint:funlen
20+
func main() {
2121
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2222
port := flag.Int("port", 3478, "Listening port.")
2323
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/tcp/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/pion/turn/v4"
1818
)
1919

20-
func main() { // nolint:funlen
20+
func main() {
2121
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2222
port := flag.Int("port", 3478, "Listening port.")
2323
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

examples/turn-server/tls/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/pion/turn/v4"
1919
)
2020

21-
func main() { // nolint:funlen
21+
func main() {
2222
publicIP := flag.String("public-ip", "", "IP Address that TURN can be contacted by.")
2323
port := flag.Int("port", 5349, "Listening port.")
2424
users := flag.String("users", "", "List of username and password (e.g. \"user=pass,user=pass\")")

internal/allocation/allocation_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func subTestAllocationClose(t *testing.T) {
276276
assert.True(t, isClose(alloc.RelaySocket), "should be closed")
277277
}
278278

279-
func subTestPacketHandler(t *testing.T) { // nolint:funlen
279+
func subTestPacketHandler(t *testing.T) {
280280
t.Helper()
281281

282282
network := "udp"

internal/client/binding_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13-
func TestBindingManager(t *testing.T) { // nolint:funlen
13+
func TestBindingManager(t *testing.T) {
1414
t.Run("number assignment", func(t *testing.T) {
1515
bm := newBindingManager()
1616
var chanNum uint16

internal/client/permission_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestPermission(t *testing.T) {
2222
})
2323
}
2424

25-
func TestPermissionMap(t *testing.T) { // nolint:funlen
25+
func TestPermissionMap(t *testing.T) {
2626
t.Run("Basic operations", func(t *testing.T) {
2727
pm := newPermissionMap()
2828
assert.NotNil(t, pm)

internal/client/tcp_alloc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (a *TCPAllocation) DialTCPWithConn(conn net.Conn, _ string, rAddr *net.TCPA
220220
}
221221

222222
// BindConnection associates the provided connection.
223-
func (a *TCPAllocation) BindConnection(dataConn *TCPConn, cid proto.ConnectionID) error { // nolint:cyclop,funlen
223+
func (a *TCPAllocation) BindConnection(dataConn *TCPConn, cid proto.ConnectionID) error { //nolint:cyclop
224224
msg, err := stun.Build(
225225
stun.TransactionID,
226226
stun.NewType(stun.MethodConnectionBind, stun.ClassRequest),

internal/client/tcp_conn_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c dummyTCPConn) Read(b []byte) (int, error) {
4545
return len(msg.Raw), nil
4646
}
4747

48-
func TestTCPConn(t *testing.T) { //nolint:funlen
48+
func TestTCPConn(t *testing.T) {
4949
t.Run("Connect()", func(t *testing.T) {
5050
var cid proto.ConnectionID = 5
5151
client := &mockClient{

internal/client/udp_conn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (a *allocation) createPermission(perm *permission, addr net.Addr) error {
149149
// an Error with Timeout() == true after a fixed time limit;
150150
// see SetDeadline and SetWriteDeadline.
151151
// On packet-oriented connections, write timeouts are rare.
152-
func (c *UDPConn) WriteTo(payload []byte, addr net.Addr) (int, error) { //nolint:gocognit,cyclop,funlen
152+
func (c *UDPConn) WriteTo(payload []byte, addr net.Addr) (int, error) { //nolint:gocognit,cyclop
153153
var err error
154154
_, ok := addr.(*net.UDPAddr)
155155
if !ok {

internal/client/udp_conn_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14-
func TestUDPConn(t *testing.T) { //nolint:funlen
14+
func TestUDPConn(t *testing.T) {
1515
t.Run("bind()", func(t *testing.T) {
1616
client := &mockClient{
1717
performTransaction: func(*stun.Message, net.Addr, bool) (TransactionResult, error) {

internal/proto/chandata_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestChannelData_Encode(t *testing.T) {
3131
}
3232
}
3333

34-
func TestChannelData_Equal(t *testing.T) { // nolint:funlen
34+
func TestChannelData_Equal(t *testing.T) {
3535
for _, tc := range []struct {
3636
name string
3737
a, b *ChannelData

internal/proto/chann_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func BenchmarkChannelNumber(b *testing.B) {
3535
})
3636
}
3737

38-
func TestChannelNumber(t *testing.T) { // nolint:cyclop,funlen
38+
func TestChannelNumber(t *testing.T) { //nolint:cyclop
3939
t.Run("String", func(t *testing.T) {
4040
n := ChannelNumber(112)
4141
if n.String() != "112" {

internal/proto/evenport_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
)
1313

14-
func TestEvenPort(t *testing.T) { // nolint:cyclop,funlen
14+
func TestEvenPort(t *testing.T) { //nolint:cyclop
1515
t.Run("String", func(t *testing.T) {
1616
p := EvenPort{}
1717
if p.String() != "reserve: false" {

internal/proto/lifetime_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func BenchmarkLifetime(b *testing.B) {
3636
})
3737
}
3838

39-
func TestLifetime(t *testing.T) { // nolint:cyclop,funlen
39+
func TestLifetime(t *testing.T) { //nolint:cyclop
4040
t.Run("String", func(t *testing.T) {
4141
l := Lifetime{time.Second * 10}
4242
if l.String() != "10s" {

internal/proto/reqfamily_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/pion/stun/v3"
1111
)
1212

13-
func TestRequestedAddressFamily(t *testing.T) { // nolint:cyclop,funlen
13+
func TestRequestedAddressFamily(t *testing.T) { //nolint:cyclop
1414
t.Run("String", func(t *testing.T) {
1515
if RequestedFamilyIPv4.String() != "IPv4" {
1616
t.Errorf("bad string %q, expected %q", RequestedFamilyIPv4,

internal/proto/reqtrans_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/pion/stun/v3"
1111
)
1212

13-
func TestRequestedTransport(t *testing.T) { // nolint:cyclop,funlen
13+
func TestRequestedTransport(t *testing.T) { //nolint:cyclop
1414
t.Run("String", func(t *testing.T) {
1515
transAttr := RequestedTransport{
1616
Protocol: ProtoUDP,

internal/proto/rsrvtoken_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/pion/stun/v3"
1212
)
1313

14-
func TestReservationToken(t *testing.T) { // nolint:cyclop,funlen
14+
func TestReservationToken(t *testing.T) { //nolint:cyclop
1515
t.Run("NoAlloc", func(t *testing.T) {
1616
stunMsg := &stun.Message{}
1717
tok := make([]byte, 8)

internal/server/turn.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const runesAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
1818

1919
// See: https://tools.ietf.org/html/rfc5766#section-6.2
2020
// .
21-
func handleAllocateRequest(req Request, stunMsg *stun.Message) error { // nolint:cyclop,funlen
21+
func handleAllocateRequest(req Request, stunMsg *stun.Message) error { //nolint:cyclop
2222
req.Log.Debugf("Received AllocateRequest from %s", req.SrcAddr)
2323

2424
// 1. The server MUST require that the request be authenticated. This

internal/server/turn_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/stretchr/testify/assert"
1919
)
2020

21-
func TestAllocationLifeTime(t *testing.T) { // nolint:funlen
21+
func TestAllocationLifeTime(t *testing.T) {
2222
t.Run("Parsing", func(t *testing.T) {
2323
lifetime := proto.Lifetime{
2424
Duration: 5 * time.Second,

internal/server/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func buildMsg(
4848
return append([]stun.Setter{&stun.Message{TransactionID: transactionID}, msgType}, additional...)
4949
}
5050

51-
func authenticateRequest(req Request, stunMsg *stun.Message, callingMethod stun.Method) ( // nolint:funlen
51+
func authenticateRequest(req Request, stunMsg *stun.Message, callingMethod stun.Method) (
5252
stun.MessageIntegrity,
5353
bool,
5454
error,

server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Server struct {
3535
}
3636

3737
// NewServer creates the Pion TURN server.
38-
func NewServer(config ServerConfig) (*Server, error) { // nolint:gocognit,cyclop,funlen
38+
func NewServer(config ServerConfig) (*Server, error) { //nolint:gocognit,cyclop
3939
if err := config.validate(); err != nil {
4040
return nil, err
4141
}

server_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/stretchr/testify/assert"
2222
)
2323

24-
func TestServer(t *testing.T) { // nolint:funlen,maintidx
24+
func TestServer(t *testing.T) { //nolint:maintidx
2525
lim := test.TimeOut(time.Second * 30)
2626
defer lim.Stop()
2727

@@ -381,7 +381,7 @@ func (v *VNet) Close() error {
381381
return v.wan.Stop()
382382
}
383383

384-
func buildVNet() (*VNet, error) { // nolint:cyclop,funlen
384+
func buildVNet() (*VNet, error) { //nolint:cyclop
385385
loggerFactory := logging.NewDefaultLoggerFactory()
386386

387387
// WAN
@@ -635,7 +635,7 @@ func TestSTUNOnly(t *testing.T) {
635635
assert.Equal(t, err.Error(), "Allocate error response (error 400: )")
636636
}
637637

638-
func RunBenchmarkServer(b *testing.B, clientNum int) { // nolint:cyclop,funlen
638+
func RunBenchmarkServer(b *testing.B, clientNum int) { //nolint:cyclop
639639
b.Helper()
640640

641641
loggerFactory := logging.NewDefaultLoggerFactory()

0 commit comments

Comments
 (0)