Skip to content

Commit 49369bd

Browse files
committed
Updates golangci-lint to v1.61.0 and fixes code.
1 parent 12a9881 commit 49369bd

File tree

15 files changed

+16
-29
lines changed

15 files changed

+16
-29
lines changed

.github/workflows/ci-actions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
with:
2323
go-version: ${{ matrix.GOVER }}
2424
- name: Linting
25-
uses: golangci/golangci-lint-action@v4
25+
uses: golangci/golangci-lint-action@v6
2626
with:
27-
version: v1.56.2
28-
args: --config=./.etc/golangci.yml ./...
27+
version: v1.61.0
28+
install-mode: goinstall
2929
- name: Check shadowing
3030
run: |
3131
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest

.etc/golangci.yml renamed to .golangci.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ linters:
1212
# - structcheck (deprecated since v1.49.0)
1313
# - varcheck (deprecated since v1.49.0)
1414
# - deadcode (deprecated since v1.49.0)
15+
# - exportloopref (deprecated since v1.60.2)
1516
- bodyclose
17+
- copyloopvar
1618
- depguard
1719
- dogsled
1820
- errcheck
19-
- exportloopref
2021
- forbidigo
2122
- funlen
2223
- goconst
@@ -56,15 +57,17 @@ linters-settings:
5657
goconst:
5758
min-occurrences: 4
5859
govet:
59-
check-shadowing: true
60+
enable-all: true
61+
disable:
62+
- fieldalignment
6063
staticcheck:
6164
# TODO: replace deprecated elliptic.Marshal, elliptic.GenerateKey,
6265
# elliptic.Unmarshal, params.ScalarBaseMult before re-enabling SA1019.
6366
checks: ["*", "-SA1019"]
67+
gosec:
68+
excludes:
69+
- G115
6470

6571
issues:
6672
max-issues-per-linter: 0
6773
max-same-issues: 0
68-
69-
output:
70-
format: github-actions

abe/cpabe/tkn20/internal/dsl/lexer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dsl
22

33
import (
4+
"errors"
45
"fmt"
56
"strings"
67
)
@@ -58,7 +59,7 @@ func (l *Lexer) scanTokens() error {
5859
}
5960
l.addToken(EOF)
6061
if l.hadError {
61-
return fmt.Errorf(strings.TrimSpace(errMsg))
62+
return errors.New(strings.TrimSpace(errMsg))
6263
}
6364
return nil
6465
}

group/group_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var allGroups = []group.Group{
2020
func TestGroup(t *testing.T) {
2121
const testTimes = 1 << 7
2222
for _, g := range allGroups {
23-
g := g
2423
n := g.(fmt.Stringer).String()
2524
t.Run(n+"/Add", func(tt *testing.T) { testAdd(tt, testTimes, g) })
2625
t.Run(n+"/Neg", func(tt *testing.T) { testNeg(tt, testTimes, g) })

group/hash_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ type vector struct {
115115

116116
func BenchmarkHash(b *testing.B) {
117117
for _, g := range allGroups {
118-
g := g
119118
name := g.(fmt.Stringer).String()
120119
b.Run(name+"/HashToElement", func(b *testing.B) {
121120
for i := 0; i < b.N; i++ {

internal/test/test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func ReportError(t testing.TB, got, want interface{}, inputs ...interface{}) {
1616
}
1717
fmt.Fprintf(b, "got: %v\nwant: %v", got, want)
1818
t.Helper()
19-
t.Fatalf(b.String())
19+
t.Fatal(b.String())
2020
}
2121

2222
// CheckOk fails the test if result == false.

kem/frodo/kat_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func TestPQCgenKATKem(t *testing.T) {
2323
{"FrodoKEM-640-SHAKE", "604a10cfc871dfaed9cb5b057c644ab03b16852cea7f39bc7f9831513b5b1cfa"},
2424
}
2525
for _, kat := range kats {
26-
kat := kat
2726
t.Run(kat.name, func(t *testing.T) {
2827
testPQCgenKATKem(t, kat.name, kat.want)
2928
})

kem/kyber/kat_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func TestPQCgenKATKem(t *testing.T) {
3131
{"ML-KEM-1024", "3fba7327d0320cb6134badf2a1bcb963a5b3c0026c7dece8f00d6a6155e47b33"},
3232
}
3333
for _, kat := range kats {
34-
kat := kat
3534
t.Run(kat.name, func(t *testing.T) {
3635
testPQCgenKATKem(t, kat.name, kat.want)
3736
})

kem/schemes/schemes_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func TestCaseSensitivity(t *testing.T) {
1717
func BenchmarkGenerateKeyPair(b *testing.B) {
1818
allSchemes := schemes.All()
1919
for _, scheme := range allSchemes {
20-
scheme := scheme
2120
b.Run(scheme.Name(), func(b *testing.B) {
2221
for i := 0; i < b.N; i++ {
2322
_, _, _ = scheme.GenerateKeyPair()
@@ -29,7 +28,6 @@ func BenchmarkGenerateKeyPair(b *testing.B) {
2928
func BenchmarkEncapsulate(b *testing.B) {
3029
allSchemes := schemes.All()
3130
for _, scheme := range allSchemes {
32-
scheme := scheme
3331
pk, _, _ := scheme.GenerateKeyPair()
3432
b.Run(scheme.Name(), func(b *testing.B) {
3533
for i := 0; i < b.N; i++ {
@@ -42,7 +40,6 @@ func BenchmarkEncapsulate(b *testing.B) {
4240
func BenchmarkDecapsulate(b *testing.B) {
4341
allSchemes := schemes.All()
4442
for _, scheme := range allSchemes {
45-
scheme := scheme
4643
pk, sk, _ := scheme.GenerateKeyPair()
4744
ct, _, _ := scheme.Encapsulate(pk)
4845
b.Run(scheme.Name(), func(b *testing.B) {
@@ -56,7 +53,6 @@ func BenchmarkDecapsulate(b *testing.B) {
5653
func TestApi(t *testing.T) {
5754
allSchemes := schemes.All()
5855
for _, scheme := range allSchemes {
59-
scheme := scheme
6056
t.Run(scheme.Name(), func(t *testing.T) {
6157
if scheme == nil {
6258
t.Fatal()

math/wnaf_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func BenchmarkOmegaNAF(b *testing.B) {
6363
Two128.Lsh(Two128, 128)
6464

6565
for w := uint(2); w < 6; w++ {
66-
w := w // pin variable
6766
b.Run(fmt.Sprintf("%v", w), func(b *testing.B) {
6867
x, _ := rand.Int(rand.Reader, Two128)
6968
b.ResetTimer()
@@ -79,7 +78,6 @@ func BenchmarkOmegaNAFRegular(b *testing.B) {
7978
Two128.Lsh(Two128, 128)
8079

8180
for w := uint(2); w < 6; w++ {
82-
w := w // pin variable
8381
b.Run(fmt.Sprintf("%v", w), func(b *testing.B) {
8482
x, _ := rand.Int(rand.Reader, Two128)
8583
x.SetBit(x, 0, uint(1)) // odd-numbers

0 commit comments

Comments
 (0)