Skip to content

Commit

Permalink
ci: upgrade to golangci-lint v1.62.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcloughlin committed Dec 22, 2024
1 parent e925bec commit 9206684
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 48 deletions.
18 changes: 5 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,33 @@ linters:
enable-all: true
disable:
- cyclop
- deadcode
- dupword
- err113
- errname
- exhaustruct
- exhaustivestruct
- forbidigo
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- goconst
- godox
- goerr113
- golint
- gomnd
- gosec
- ifshort
- iface
- inamedparam
- interfacer
- ireturn
- lll
- maligned
- mnd
- nlreturn
- nonamedreturns
- nosnakecase
- paralleltest
- prealloc
- perfsprint
- prealloc
- recvcheck
- rowserrcheck
- scopelint
- structcheck
- tagliatelle
- testpackage
- unparam
- varcheck
- varnamelen
- wastedassign
- wrapcheck
Expand Down
8 changes: 4 additions & 4 deletions build/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func (e ErrorList) Error() string {
}

// LogError logs a list of errors, one error per line, if the err parameter is
// an ErrorList. Otherwise it just logs the err string. Reports at most max
// errors, or unlimited if max is 0.
func LogError(l *log.Logger, err error, max int) {
// an ErrorList. Otherwise it just logs the err string. Reports at most mx
// errors, or unlimited if mx is 0.
func LogError(l *log.Logger, err error, mx int) {
var list ErrorList
if errors.As(err, &list) {
for i, e := range list {
if max > 0 && i == max {
if mx > 0 && i == mx {
l.Print("too many errors")
return
}
Expand Down
2 changes: 1 addition & 1 deletion gotypes/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (c *component) Field(n string) Component {
// }
//
fields := make([]*types.Var, s.NumFields())
for i := 0; i < s.NumFields(); i++ {
for i := range s.NumFields() {
fields[i] = s.Field(i)
}
offsets := Sizes.Offsetsof(fields)
Expand Down
3 changes: 1 addition & 2 deletions gotypes/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func TestComponentDeconstruction(t *testing.T) {
// For every test case, generate the same case but when the type is wrapped in
// a named type.
n := len(cases)
for i := 0; i < n; i++ {
for i := range n {
wrapped := cases[i]
wrapped.Name += "_wrapped"
wrapped.Type = types.NewNamed(
Expand All @@ -204,7 +204,6 @@ func TestComponentDeconstruction(t *testing.T) {
}

for _, c := range cases {
c := c // avoid scopelint error
t.Run(c.Name, func(t *testing.T) {
t.Log(c.Type)
base := operand.NewParamAddr("test", 0)
Expand Down
4 changes: 2 additions & 2 deletions gotypes/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func newTuple(t *types.Tuple, offsets []int64, size int64, defaultprefix string)
byname: map[string]Component{},
size: int(size),
}
for i := 0; i < t.Len(); i++ {
for i := range t.Len() {
v := t.At(i)
name := v.Name()
if name == "" {
Expand Down Expand Up @@ -172,7 +172,7 @@ func (t *Tuple) Bytes() int { return t.size }

func tuplevars(t *types.Tuple) []*types.Var {
vs := make([]*types.Var, t.Len())
for i := 0; i < t.Len(); i++ {
for i := range t.Len() {
vs[i] = t.At(i)
}
return vs
Expand Down
2 changes: 1 addition & 1 deletion gotypes/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TypesTuplesEqual(a, b *types.Tuple) bool {
return false
}
n := a.Len()
for i := 0; i < n; i++ {
for i := range n {
if !TypesVarsEqual(a.At(i), b.At(i)) {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion internal/api/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (f *Function) Signature() Signature {
n := f.Arity()
ops := make([]string, n)
count := map[string]int{}
for j := 0; j < n; j++ {
for j := range n {
// Collect unique lowercase bytes from first characters of operand types.
s := map[byte]bool{}
for _, form := range f.Forms {
Expand Down
3 changes: 1 addition & 2 deletions internal/api/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ func TestFunctionsDuplicateFormSignatures(t *testing.T) {
// manifest as duplicate case statements in generated code.
fns := InstructionsFunctions(inst.Instructions)
for _, fn := range fns {
fn := fn // scopelint
t.Run(fn.Name(), func(t *testing.T) {
seen := map[string]bool{}
for _, f := range fn.Forms {
Expand All @@ -36,7 +35,7 @@ func TestFunctionsUniqueArgNames(t *testing.T) {
continue
}
names := map[string]bool{}
for j := 0; j < n; j++ {
for j := range n {
names[s.ParameterName(j)] = true
}
if len(names) != n {
Expand Down
16 changes: 8 additions & 8 deletions internal/gen/optab.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ func (t *optab) Generate(is []inst.Instruction) ([]byte, error) {
}

func (t *optab) maxOperands(is []inst.Instruction) {
max := 0
mx := 0
for _, i := range inst.Instructions {
for _, f := range i.Forms {
a := len(f.Operands) + len(f.ImplicitOperands)
if a > max {
max = a
if a > mx {
mx = a
}
}
}

t.Comment("maxoperands is the maximum number of operands in an instruction form, including implicit operands.")
t.Printf("const maxoperands = %d\n\n", max)
t.Printf("const maxoperands = %d\n\n", mx)
}

func (t *optab) operandTypeEnum(is []inst.Instruction) {
Expand Down Expand Up @@ -109,17 +109,17 @@ func (t *optab) implicitRegisterEnum(is []inst.Instruction) {
func (t *optab) suffixesType(is []inst.Instruction) {
// Declare the type as an array. This requires us to know the maximum number
// of suffixes an instruction can have.
max := 0
mx := 0
for _, class := range inst.SuffixesClasses(is) {
for _, suffixes := range class {
if len(suffixes) > max {
max = len(suffixes)
if len(suffixes) > mx {
mx = len(suffixes)
}
}
}

t.Comment("maxsuffixes is the maximum number of suffixes an instruction can have.")
t.Printf("const maxsuffixes = %d\n\n", max)
t.Printf("const maxsuffixes = %d\n\n", mx)

name := t.table.SuffixesTypeName()
t.Printf("type %s [maxsuffixes]%s\n", name, t.table.Suffix().Name())
Expand Down
2 changes: 1 addition & 1 deletion internal/inst/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestFormDupes(t *testing.T) {

func HasFormDupe(i inst.Instruction) bool {
n := len(i.Forms)
for a := 0; a < n; a++ {
for a := range n {
for b := a + 1; b < n; b++ {
if reflect.DeepEqual(i.Forms[a], i.Forms[b]) {
return true
Expand Down
6 changes: 3 additions & 3 deletions internal/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strings"
)

// Frames returns at most max callstack Frames, starting with its caller and
// Frames returns at most m callstack Frames, starting with its caller and
// skipping skip Frames.
func Frames(skip, max int) []runtime.Frame {
pc := make([]uintptr, max)
func Frames(skip, m int) []runtime.Frame {
pc := make([]uintptr, m)
n := runtime.Callers(skip+2, pc)
if n == 0 {
return nil
Expand Down
1 change: 1 addition & 0 deletions internal/stack/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestMatchFirst(t *testing.T) {
first := stack.Match(0, func(_ runtime.Frame) bool { return true })
if first == nil {
t.Fatalf("nil match")
return
}
got := first.Function
expect := pkg + ".TestMatchFirst"
Expand Down
2 changes: 1 addition & 1 deletion pass/alloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestAllocatorPriority(t *testing.T) {
a.Add(x[i].ID())
}

for i := 0; i < n; i++ {
for i := range n {
for j := i + 1; j < n; j++ {
a.AddInterference(x[i].ID(), x[j].ID())
}
Expand Down
2 changes: 1 addition & 1 deletion pass/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func CFG(fn *ir.Function) error {
n := len(is)

// Populate successors.
for i := 0; i < n; i++ {
for i := range n {
cur := is[i]
var nxt *ir.Instruction
if i+1 < n {
Expand Down
2 changes: 1 addition & 1 deletion pass/reg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestAllocateRegistersBasePointerDeprioritized(t *testing.T) {
ctx.SignatureExpr("func() uint64")

x := make([]reg.GPVirtual, n)
for i := 0; i < n; i++ {
for i := range n {
x[i] = ctx.GP64()
ctx.MOVQ(operand.U64(i), x[i])
}
Expand Down
2 changes: 1 addition & 1 deletion script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
go install ./internal/cmd/asmvet

# golangci-lint for linting
golangci_lint_version='v1.55.2'
golangci_lint_version='v1.62.2'
golangci_install_script="https://raw.githubusercontent.com/golangci/golangci-lint/${golangci_lint_version}/install.sh"
curl -sfL "${golangci_install_script}" | sh -s -- -b "$(go env GOPATH)/bin" "${golangci_lint_version}"

Expand Down
2 changes: 1 addition & 1 deletion tests/alloc/zeroing/zeroing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestZeroing(t *testing.T) {
var got [8]uint64
Zeroing(&got)

for i := 0; i < 8; i++ {
for i := range 8 {
if got[i] != expect {
t.Errorf("got[%d] = %d; expect %d", i, got[i], expect)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixedbugs/issue387/issue387_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
//go:generate go run asm.go -out issue387.s -stubs stub.go

func TestFloat32(t *testing.T) {
for i := 0; i < 10; i++ {
for i := range 10 {
got := Float32(i)
expect := float32(i)
if got != expect {
Expand All @@ -17,7 +17,7 @@ func TestFloat32(t *testing.T) {
}

func TestFloat64(t *testing.T) {
for i := 0; i < 10; i++ {
for i := range 10 {
got := Float64(i)
expect := float64(i)
if got != expect {
Expand Down
1 change: 0 additions & 1 deletion tests/thirdparty/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func TestValidateErrors(t *testing.T) {
},
}
for _, c := range cases {
c := c // scopelint
t.Run(c.Name, func(t *testing.T) {
err := c.Item.Validate()
if err == nil {
Expand Down
1 change: 0 additions & 1 deletion tests/thirdparty/packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func TestPackages(t *testing.T) {
}

for _, tst := range s.Projects.Tests() {
tst := tst // scopelint
t.Run(tst.ID(), func(t *testing.T) {
if tst.Project.Skip() {
t.Skipf("skip: %s", tst.Project.Reason())
Expand Down
1 change: 0 additions & 1 deletion x86/inst_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestCases(t *testing.T) {
}

for _, c := range cases {
c := c // scopelint
t.Run(c.Name, func(t *testing.T) {
if !reflect.DeepEqual(c.Instruction, c.Expect) {
t.Logf(" got = %#v", c.Instruction)
Expand Down

0 comments on commit 9206684

Please sign in to comment.