diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08e4272a..b0242893 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: uses: pion/.goassets/.github/workflows/test.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -33,7 +33,7 @@ jobs: uses: pion/.goassets/.github/workflows/test-i386.reusable.yml@master strategy: matrix: - go: ["1.22", "1.21"] # auto-update/supported-go-version-list + go: ["1.23", "1.22"] # auto-update/supported-go-version-list fail-fast: false with: go-version: ${{ matrix.go }} @@ -41,5 +41,5 @@ jobs: test-wasm: uses: pion/.goassets/.github/workflows/test-wasm.reusable.yml@master with: - go-version: "1.22" # auto-update/latest-go-version + go-version: "1.23" # auto-update/latest-go-version secrets: inherit diff --git a/.golangci.yml b/.golangci.yml index e06de4d3..a3235bec 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,9 @@ # SPDX-FileCopyrightText: 2023 The Pion community # SPDX-License-Identifier: MIT +run: + timeout: 5m + linters-settings: govet: enable: @@ -48,7 +51,7 @@ linters: - goconst # Finds repeated strings that could be replaced by a constant - gocritic # The most opinionated Go source code linter - godox # Tool for detection of FIXME, TODO and other comment keywords - - goerr113 # Golang linter to check the errors handling expressions + - err113 # Golang linter to check the errors handling expressions - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gofumpt # Gofumpt checks whether code was gofumpt-ed. - goheader # Checks is file header matches to pattern @@ -83,17 +86,14 @@ linters: - depguard # Go linter that checks if package imports are in a list of acceptable packages - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - - exhaustivestruct # Checks if all struct's fields are initialized - funlen # Tool for detection of long functions - gocyclo # Computes and checks the cyclomatic complexity of functions - godot # Check if comments end in a period - gomnd # An analyzer to detect magic numbers. - - ifshort # Checks that your code uses short syntax for if-statements whenever possible - ireturn # Accept Interfaces, Return Concrete Types - lll # Reports long lines - maintidx # maintidx measures the maintainability index of each function. - makezero # Finds slice declarations with non-zero initial length - - maligned # Tool to detect Go structs that would take less memory if their fields were sorted - nakedret # Finds naked returns in functions greater than a specified function length - nestif # Reports deeply nested if statements - nlreturn # nlreturn checks for a new line before return and branch statements to increase code clarity diff --git a/pkg/gcc/gcc.go b/pkg/gcc/gcc.go index bf32150e..1db69390 100644 --- a/pkg/gcc/gcc.go +++ b/pkg/gcc/gcc.go @@ -20,10 +20,10 @@ func maxInt(a, b int) int { return b } -func clampInt(b, min, max int) int { - return maxInt(min, minInt(max, b)) +func clampInt(b, minVal, maxVal int) int { + return maxInt(minVal, minInt(maxVal, b)) } -func clampDuration(d, min, max time.Duration) time.Duration { - return time.Duration(clampInt(int(d), int(min), int(max))) +func clampDuration(d, minVal, maxVal time.Duration) time.Duration { + return time.Duration(clampInt(int(d), int(minVal), int(maxVal))) } diff --git a/pkg/gcc/gcc_test.go b/pkg/gcc/gcc_test.go index 428b9bda..149dfd35 100644 --- a/pkg/gcc/gcc_test.go +++ b/pkg/gcc/gcc_test.go @@ -114,10 +114,10 @@ func TestClamp(t *testing.T) { }) t.Run(fmt.Sprintf("duration/%v", i), func(t *testing.T) { x := time.Duration(tt.x) - min := time.Duration(tt.min) - max := time.Duration(tt.max) + minVal := time.Duration(tt.min) + maxVal := time.Duration(tt.max) expected := time.Duration(tt.expected) - assert.Equal(t, expected, clampDuration(x, min, max)) + assert.Equal(t, expected, clampDuration(x, minVal, maxVal)) }) } } diff --git a/pkg/nack/receive_log_test.go b/pkg/nack/receive_log_test.go index ef459248..1bbdb8ea 100644 --- a/pkg/nack/receive_log_test.go +++ b/pkg/nack/receive_log_test.go @@ -19,9 +19,9 @@ func TestReceivedBuffer(t *testing.T) { t.Fatalf("%+v", err) } - all := func(min uint16, max uint16) []uint16 { + all := func(minVal uint16, maxVal uint16) []uint16 { result := make([]uint16, 0) - for i := min; i != max+1; i++ { + for i := minVal; i != maxVal+1; i++ { result = append(result, i) } return result diff --git a/pkg/stats/stats_recorder.go b/pkg/stats/stats_recorder.go index a9338ee2..a35d0624 100644 --- a/pkg/stats/stats_recorder.go +++ b/pkg/stats/stats_recorder.go @@ -227,7 +227,7 @@ func (r *recorder) recordIncomingRR(latestStats internalStats, pkt *rtcp.Receive latestStats.RemoteInboundRTPStreamStats.Jitter = float64(report.Jitter) / r.clockRate if report.Delay != 0 && report.LastSenderReport != 0 { - for i := min(r.maxLastSenderReports, len(latestStats.lastSenderReports)) - 1; i >= 0; i-- { + for i := minInt(r.maxLastSenderReports, len(latestStats.lastSenderReports)) - 1; i >= 0; i-- { lastReport := latestStats.lastSenderReports[i] if (lastReport&0x0000FFFFFFFF0000)>>16 == uint64(report.LastSenderReport) { dlsr := time.Duration(float64(report.Delay) / 65536.0 * float64(time.Second)) @@ -248,7 +248,7 @@ func (r *recorder) recordIncomingXR(latestStats internalStats, pkt *rtcp.Extende if xr, ok := report.(*rtcp.DLRRReportBlock); ok { for _, xrReport := range xr.Reports { if xrReport.LastRR != 0 && xrReport.DLRR != 0 { - for i := min(r.maxLastReceiverReferenceTimes, len(latestStats.lastReceiverReferenceTimes)) - 1; i >= 0; i-- { + for i := minInt(r.maxLastReceiverReferenceTimes, len(latestStats.lastReceiverReferenceTimes)) - 1; i >= 0; i-- { lastRR := latestStats.lastReceiverReferenceTimes[i] if (lastRR&0x0000FFFFFFFF0000)>>16 == uint64(xrReport.LastRR) { dlrr := time.Duration(float64(xrReport.DLRR) / 65536.0 * float64(time.Second)) @@ -377,7 +377,7 @@ func (r *recorder) QueueOutgoingRTCP(ts time.Time, pkts []rtcp.Packet, attr inte r.ms.Unlock() } -func min(a, b int) int { +func minInt(a, b int) int { if a < b { return a } diff --git a/pkg/twcc/arrival_time_map.go b/pkg/twcc/arrival_time_map.go index abca1ff5..d3e2a8af 100644 --- a/pkg/twcc/arrival_time_map.go +++ b/pkg/twcc/arrival_time_map.go @@ -170,9 +170,9 @@ func (m *packetArrivalTimeMap) adjustToSize(newSize int) { } m.reallocate(newCapacity) } - if m.capacity() > max(minCapacity, newSize*4) { + if m.capacity() > maxInt(minCapacity, newSize*4) { newCapacity := m.capacity() - for newCapacity >= 2*max(newSize, minCapacity) { + for newCapacity >= 2*maxInt(newSize, minCapacity) { newCapacity /= 2 } m.reallocate(newCapacity) diff --git a/pkg/twcc/twcc.go b/pkg/twcc/twcc.go index c7246f30..6464c77b 100644 --- a/pkg/twcc/twcc.go +++ b/pkg/twcc/twcc.go @@ -307,7 +307,7 @@ func (c *chunk) encode() rtcp.PacketStatusChunk { } } - minCap := min(maxTwoBitCap, len(c.deltas)) + minCap := minInt(maxTwoBitCap, len(c.deltas)) svc := &rtcp.StatusVectorChunk{ SymbolSize: rtcp.TypeTCCSymbolSizeTwoBit, SymbolList: c.deltas[:minCap], @@ -337,14 +337,14 @@ func (c *chunk) reset() { c.hasDifferentTypes = false } -func max(a, b int) int { +func maxInt(a, b int) int { if a > b { return a } return b } -func min(a, b int) int { +func minInt(a, b int) int { if a < b { return a }