From 114df0da9223d4352ba2736271f0389d16ab2354 Mon Sep 17 00:00:00 2001 From: Pion <59523206+pionbot@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:18:44 +0000 Subject: [PATCH] Update CI configs to v0.11.15 Update lint scripts and CI configs. --- .github/workflows/test.yaml | 6 +++--- .golangci.yml | 8 ++++---- codecs/av1_packet.go | 2 +- codecs/common.go | 2 +- codecs/common_test.go | 6 +++--- codecs/h264_packet.go | 4 ++-- codecs/vp8_packet.go | 4 ++-- codecs/vp9_packet.go | 6 +++--- header_extension.go | 2 +- packet.go | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) 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/codecs/av1_packet.go b/codecs/av1_packet.go index bcea6905..84c6c99b 100644 --- a/codecs/av1_packet.go +++ b/codecs/av1_packet.go @@ -61,7 +61,7 @@ func (p *AV1Payloader) Payload(mtu uint16, payload []byte) (payloads [][]byte) { metadataSize += leb128Size + len(p.sequenceHeader) } - out := make([]byte, min(int(mtu), payloadDataRemaining+metadataSize)) + out := make([]byte, minInt(int(mtu), payloadDataRemaining+metadataSize)) outOffset := av1PayloaderHeadersize out[0] = obuCount << wBitshift diff --git a/codecs/common.go b/codecs/common.go index e807a0ac..5b7dd14a 100644 --- a/codecs/common.go +++ b/codecs/common.go @@ -3,7 +3,7 @@ package codecs -func min(a, b int) int { +func minInt(a, b int) int { if a < b { return a } diff --git a/codecs/common_test.go b/codecs/common_test.go index 7f0e38a8..4c1f393e 100644 --- a/codecs/common_test.go +++ b/codecs/common_test.go @@ -8,17 +8,17 @@ import ( ) func TestCommon_Min(t *testing.T) { - res := min(1, -1) + res := minInt(1, -1) if res != -1 { t.Fatal("Error: -1 < 1") } - res = min(1, 2) + res = minInt(1, 2) if res != 1 { t.Fatal("Error: 1 < 2") } - res = min(3, 3) + res = minInt(3, 3) if res != 3 { t.Fatal("Error: 3 == 3") } diff --git a/codecs/h264_packet.go b/codecs/h264_packet.go index 973a8315..227cb9d8 100644 --- a/codecs/h264_packet.go +++ b/codecs/h264_packet.go @@ -138,12 +138,12 @@ func (p *H264Payloader) Payload(mtu uint16, payload []byte) [][]byte { naluLength := len(nalu) - naluIndex naluRemaining := naluLength - if min(maxFragmentSize, naluRemaining) <= 0 { + if minInt(maxFragmentSize, naluRemaining) <= 0 { return } for naluRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, naluRemaining) + currentFragmentSize := minInt(maxFragmentSize, naluRemaining) out := make([]byte, fuaHeaderSize+currentFragmentSize) // +---------------+ diff --git a/codecs/vp8_packet.go b/codecs/vp8_packet.go index 4ddd15bc..87560abe 100644 --- a/codecs/vp8_packet.go +++ b/codecs/vp8_packet.go @@ -56,12 +56,12 @@ func (p *VP8Payloader) Payload(mtu uint16, payload []byte) [][]byte { var payloads [][]byte // Make sure the fragment/payload size is correct - if min(maxFragmentSize, payloadDataRemaining) <= 0 { + if minInt(maxFragmentSize, payloadDataRemaining) <= 0 { return payloads } first := true for payloadDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) out := make([]byte, usingHeaderSize+currentFragmentSize) if first { diff --git a/codecs/vp9_packet.go b/codecs/vp9_packet.go index 98920be0..e2ffab79 100644 --- a/codecs/vp9_packet.go +++ b/codecs/vp9_packet.go @@ -81,12 +81,12 @@ func (p *VP9Payloader) payloadFlexible(mtu uint16, payload []byte) [][]byte { payloadDataIndex := 0 var payloads [][]byte - if min(maxFragmentSize, payloadDataRemaining) <= 0 { + if minInt(maxFragmentSize, payloadDataRemaining) <= 0 { return [][]byte{} } for payloadDataRemaining > 0 { - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) out := make([]byte, headerSize+currentFragmentSize) out[0] = 0x90 // F=1, I=1 @@ -149,7 +149,7 @@ func (p *VP9Payloader) payloadNonFlexible(mtu uint16, payload []byte) [][]byte { } maxFragmentSize := int(mtu) - headerSize - currentFragmentSize := min(maxFragmentSize, payloadDataRemaining) + currentFragmentSize := minInt(maxFragmentSize, payloadDataRemaining) if currentFragmentSize <= 0 { return [][]byte{} } diff --git a/header_extension.go b/header_extension.go index fe542151..cdb16bd7 100644 --- a/header_extension.go +++ b/header_extension.go @@ -163,7 +163,7 @@ type TwoByteHeaderExtension struct { // Set sets the extension payload for the specified ID. func (e *TwoByteHeaderExtension) Set(id uint8, buf []byte) error { - if id < 1 || id > 255 { + if id < 1 { return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderIDRange, id) } if len(buf) > 255 { diff --git a/packet.go b/packet.go index 61d341d1..e74d48d2 100644 --- a/packet.go +++ b/packet.go @@ -383,7 +383,7 @@ func (h *Header) SetExtension(id uint8, payload []byte) error { //nolint:gocogni } // RFC 8285 RTP Two Byte Header Extension case extensionProfileTwoByte: - if id < 1 || id > 255 { + if id < 1 { return fmt.Errorf("%w actual(%d)", errRFC8285TwoByteHeaderIDRange, id) } if len(payload) > 255 {