Skip to content

Commit 398ac7c

Browse files
asayyahJoTurk
authored andcommitted
Fix lint issues for golangci-lint v2.10.1
1 parent a289f71 commit 398ac7c

34 files changed

+45
-84
lines changed

active_tcp_test.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

98
import (
10-
"context"
119
"fmt"
1210
"io"
1311
"net"
@@ -324,8 +322,7 @@ func TestNewActiveTCPConn_LocalAddrError_EarlyReturn(t *testing.T) {
324322
logger := logging.NewDefaultLoggerFactory().NewLogger("ice")
325323

326324
// an invalid local address so getTCPAddrOnInterface fails at ResolveTCPAddr.
327-
ctx, cancel := context.WithCancel(context.Background())
328-
defer cancel()
325+
ctx := t.Context()
329326

330327
ra := netip.MustParseAddrPort("127.0.0.1:1")
331328

@@ -347,8 +344,7 @@ func TestActiveTCPConn_ReadLoop_BufferWriteError(t *testing.T) {
347344
ra := netip.MustParseAddrPort(tcpListener.Addr().String())
348345
logger := logging.NewDefaultLoggerFactory().NewLogger("ice")
349346

350-
ctx, cancel := context.WithCancel(context.Background())
351-
defer cancel()
347+
ctx := t.Context()
352348

353349
a := newActiveTCPConn(ctx, "127.0.0.1:0", ra, logger)
354350
require.NotNil(t, a)
@@ -375,8 +371,7 @@ func TestActiveTCPConn_WriteLoop_WriteStreamingError(t *testing.T) {
375371
ra := netip.MustParseAddrPort(tcpListener.Addr().String())
376372
logger := logging.NewDefaultLoggerFactory().NewLogger("ice")
377373

378-
ctx, cancel := context.WithCancel(context.Background())
379-
defer cancel()
374+
ctx := t.Context()
380375

381376
a := newActiveTCPConn(ctx, "127.0.0.1:0", ra, logger)
382377
require.NotNil(t, a)
@@ -396,8 +391,7 @@ func TestActiveTCPConn_WriteLoop_WriteStreamingError(t *testing.T) {
396391
func TestActiveTCPConn_LocalAddr_DefaultWhenUnset(t *testing.T) {
397392
defer test.CheckRoutines(t)()
398393

399-
ctx, cancel := context.WithCancel(context.Background())
400-
defer cancel()
394+
ctx := t.Context()
401395

402396
invalidLocal := "127.0.0.1:65536"
403397
remote := netip.MustParseAddrPort("127.0.0.1:1")
@@ -419,8 +413,7 @@ func TestActiveTCPConn_LocalAddr_DefaultWhenUnset(t *testing.T) {
419413
func TestActiveTCPConn_SetDeadlines_ReturnEOF(t *testing.T) {
420414
defer test.CheckRoutines(t)()
421415

422-
ctx, cancel := context.WithCancel(context.Background())
423-
defer cancel()
416+
ctx := t.Context()
424417

425418
invalidLocal := "127.0.0.1:65536"
426419
remote := netip.MustParseAddrPort("127.0.0.1:1")
@@ -448,8 +441,7 @@ func TestActiveTCPConn_SetDeadlines_WhenConnected(t *testing.T) {
448441

449442
remote := netip.MustParseAddrPort(ln.Addr().String())
450443
logger := logging.NewDefaultLoggerFactory().NewLogger("ice")
451-
ctx, cancel := context.WithCancel(context.Background())
452-
defer cancel()
444+
ctx := t.Context()
453445

454446
active := newActiveTCPConn(ctx, "127.0.0.1:0", remote, logger)
455447
require.NotNil(t, active)

addr_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

agent_get_best_available_candidate_pair_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

agent_get_best_valid_candidate_pair_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

agent_handlers_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ func TestConnectionStateNotifier(t *testing.T) {
2525
}
2626
// Enqueue all updates upfront to ensure that it
2727
// doesn't block
28-
for i := 0; i < 10000; i++ {
28+
for range 10000 {
2929
notifier.EnqueueConnectionState(ConnectionStateNew)
3030
}
3131
done := make(chan struct{})
3232
go func() {
33-
for i := 0; i < 10000; i++ {
33+
for range 10000 {
3434
<-updates
3535
}
3636
select {
@@ -54,7 +54,7 @@ func TestConnectionStateNotifier(t *testing.T) {
5454
}
5555
done := make(chan struct{})
5656
go func() {
57-
for i := 0; i < 10000; i++ {
57+
for i := range 10000 {
5858
assert.Equal(t, ConnectionState(i), <-updates)
5959
}
6060
select {
@@ -64,7 +64,7 @@ func TestConnectionStateNotifier(t *testing.T) {
6464
}
6565
close(done)
6666
}()
67-
for i := 0; i < 10000; i++ {
67+
for i := range 10000 {
6868
notifer.EnqueueConnectionState(ConnectionState(i))
6969
}
7070
<-done

agent_on_selected_candidate_pair_change_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

agent_options_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ func TestWith1To1CandidateIPOptions(t *testing.T) {
698698
}
699699

700700
for _, tc := range testCases {
701-
tc := tc
702701
t.Run(tc.name, func(t *testing.T) {
703702
assertAddressRewriteOption(
704703
t,
@@ -1484,7 +1483,6 @@ func TestAgentConfigNAT1To1IPs(t *testing.T) {
14841483
}
14851484

14861485
for _, tc := range testCases {
1487-
tc := tc
14881486
t.Run(tc.name, func(t *testing.T) {
14891487
stub := newStubNet(t)
14901488
config := tc.config

agent_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

@@ -925,7 +924,7 @@ func TestSelectedCandidatePairStats(t *testing.T) { //nolint:cyclop
925924
agent.addPair(hostLocal, srflxRemote)
926925
candidatePair = agent.findPair(hostLocal, srflxRemote)
927926
}
928-
for i := 0; i < 10; i++ {
927+
for i := range 10 {
929928
candidatePair.UpdateRoundTripTime(time.Duration(i+1) * time.Second)
930929
}
931930

@@ -1466,7 +1465,7 @@ func TestGetRemoteCandidates(t *testing.T) {
14661465

14671466
expectedCandidates := []Candidate{}
14681467

1469-
for i := 0; i < 5; i++ {
1468+
for i := range 5 {
14701469
cfg := CandidateHostConfig{
14711470
Network: "udp",
14721471
Address: "192.168.0.2",
@@ -1499,7 +1498,7 @@ func TestGetLocalCandidates(t *testing.T) {
14991498
dummyConn := &net.UDPConn{}
15001499
expectedCandidates := []Candidate{}
15011500

1502-
for i := 0; i < 5; i++ {
1501+
for i := range 5 {
15031502
cfg := CandidateHostConfig{
15041503
Network: "udp",
15051504
Address: "192.168.0.2",
@@ -2141,7 +2140,7 @@ func TestSetCandidatesUfrag(t *testing.T) {
21412140

21422141
dummyConn := &net.UDPConn{}
21432142

2144-
for i := 0; i < 5; i++ {
2143+
for i := range 5 {
21452144
cfg := CandidateHostConfig{
21462145
Network: "udp",
21472146
Address: "192.168.0.2",

agent_udpmux_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
//go:build !js
5-
// +build !js
65

76
package ice
87

candidate_base.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ func (c *candidateBase) copy() (Candidate, error) {
538538
}
539539

540540
func removeZoneIDFromAddress(addr string) string {
541-
if i := strings.Index(addr, "%"); i != -1 {
542-
return addr[:i]
541+
if before, _, ok := strings.Cut(addr, "%"); ok {
542+
return before
543543
}
544544

545545
return addr

0 commit comments

Comments
 (0)