diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 08e4272..b024289 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 e06de4d..a3235be 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/crypto_test.go b/crypto_test.go index 1aaa29c..1f7c5c9 100644 --- a/crypto_test.go +++ b/crypto_test.go @@ -26,24 +26,24 @@ func TestCryptoRandomGenerator(t *testing.T) { } func TestCryptoUint64(t *testing.T) { - min := uint64(0xFFFFFFFFFFFFFFFF) - max := uint64(0) + localMin := uint64(0xFFFFFFFFFFFFFFFF) + localMax := uint64(0) for i := 0; i < 10000; i++ { r, err := CryptoUint64() if err != nil { t.Fatal(err) } - if r < min { - min = r + if r < localMin { + localMin = r } - if r > max { - max = r + if r > localMax { + localMax = r } } - if min > 0x1000000000000000 { + if localMin > 0x1000000000000000 { t.Error("Value around lower boundary was not generated") } - if max < 0xF000000000000000 { + if localMax < 0xF000000000000000 { t.Error("Value around upper boundary was not generated") } } diff --git a/math_test.go b/math_test.go index ea8803c..4beb322 100644 --- a/math_test.go +++ b/math_test.go @@ -26,24 +26,24 @@ func TestMathRandomGenerator(t *testing.T) { func TestIntn(t *testing.T) { g := NewMathRandomGenerator() - min := 100 - max := 0 + localMin := 100 + localMax := 0 for i := 0; i < 10000; i++ { r := g.Intn(100) if r < 0 || r >= 100 { t.Fatalf("Out of range of Intn(100): %d", r) } - if r < min { - min = r + if r < localMin { + localMin = r } - if r > max { - max = r + if r > localMax { + localMax = r } } - if min > 10 { + if localMin > 10 { t.Error("Value around lower boundary was not generated") } - if max < 90 { + if localMax < 90 { t.Error("Value around upper boundary was not generated") } } @@ -51,21 +51,21 @@ func TestIntn(t *testing.T) { func TestUint64(t *testing.T) { g := NewMathRandomGenerator() - min := uint64(0xFFFFFFFFFFFFFFFF) - max := uint64(0) + localMin := uint64(0xFFFFFFFFFFFFFFFF) + localMax := uint64(0) for i := 0; i < 10000; i++ { r := g.Uint64() - if r < min { - min = r + if r < localMin { + localMin = r } - if r > max { - max = r + if r > localMax { + localMax = r } } - if min > 0x1000000000000000 { + if localMin > 0x1000000000000000 { t.Error("Value around lower boundary was not generated") } - if max < 0xF000000000000000 { + if localMax < 0xF000000000000000 { t.Error("Value around upper boundary was not generated") } } @@ -73,21 +73,21 @@ func TestUint64(t *testing.T) { func TestUint32(t *testing.T) { g := NewMathRandomGenerator() - min := uint32(0xFFFFFFFF) - max := uint32(0) + localMin := uint32(0xFFFFFFFF) + localMax := uint32(0) for i := 0; i < 10000; i++ { r := g.Uint32() - if r < min { - min = r + if r < localMin { + localMin = r } - if r > max { - max = r + if r > localMax { + localMax = r } } - if min > 0x10000000 { + if localMin > 0x10000000 { t.Error("Value around lower boundary was not generated") } - if max < 0xF0000000 { + if localMax < 0xF0000000 { t.Error("Value around upper boundary was not generated") } }