all: upgrade to golangci-lint v1.49.0 (#329)

Fixes #242
This commit is contained in:
Michael McLoughlin
2022-09-05 17:25:03 -07:00
committed by GitHub
parent d76a0f6dd6
commit e788b7675f
9 changed files with 433 additions and 436 deletions

View File

@@ -4,7 +4,9 @@ linters:
enable-all: true enable-all: true
disable: disable:
- cyclop - cyclop
- deadcode
- errname - errname
- exhaustruct
- exhaustivestruct - exhaustivestruct
- forbidigo - forbidigo
- forcetypeassert - forcetypeassert
@@ -22,12 +24,16 @@ linters:
- lll - lll
- maligned - maligned
- nlreturn - nlreturn
- nonamedreturns
- nosnakecase
- paralleltest - paralleltest
- prealloc - prealloc
- scopelint - scopelint
- structcheck
- tagliatelle - tagliatelle
- testpackage - testpackage
- unparam - unparam
- varcheck
- varnamelen - varnamelen
- wrapcheck - wrapcheck
- wsl - wsl

View File

@@ -11,7 +11,6 @@ import (
"fmt" "fmt"
"go/format" "go/format"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
@@ -107,7 +106,7 @@ func DownloadGoSourceFile(outpath, v, srcpath string) (err error) {
return err return err
} }
if err := ioutil.WriteFile(outpath, buf.Bytes(), 0o644); err != nil { if err := os.WriteFile(outpath, buf.Bytes(), 0o644); err != nil {
return err return err
} }
@@ -169,7 +168,7 @@ func Parse(r io.Reader) ([]Flag, error) {
// ParseFile parses text flags header file. // ParseFile parses text flags header file.
func ParseFile(filename string) ([]Flag, error) { func ParseFile(filename string) ([]Flag, error) {
b, err := ioutil.ReadFile(filename) b, err := os.ReadFile(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -7,9 +7,9 @@
// //
// Any terms provided in the filename can be thought of as an implicit extra // Any terms provided in the filename can be thought of as an implicit extra
// constraint comment line. Collectively, these are referred to as // constraint comment line. Collectively, these are referred to as
// ``constraints''. Each line is a ``constraint''. Within each constraint the // constraints. Each line is a constraint. Within each constraint the
// space-separated terms are ``options'', and within that the comma-separated // space-separated terms are options, and within that the comma-separated
// items are ``terms'' which may be negated with at most one exclaimation mark. // items are terms which may be negated with at most one exclaimation mark.
// //
// These represent a boolean formulae. The constraints are evaluated as the AND // These represent a boolean formulae. The constraints are evaluated as the AND
// of constraint lines; a constraint is evaluated as the OR of its options and // of constraint lines; a constraint is evaluated as the OR of its options and

View File

@@ -99,7 +99,6 @@ func (c *component) Dereference(r reg.Register) Component {
// Len int // Len int
// Cap int // Cap int
// } // }
//
var slicehdroffsets = Sizes.Offsetsof([]*types.Var{ var slicehdroffsets = Sizes.Offsetsof([]*types.Var{
types.NewField(token.NoPos, nil, "Data", types.Typ[types.Uintptr], false), types.NewField(token.NoPos, nil, "Data", types.Typ[types.Uintptr], false),
types.NewField(token.NoPos, nil, "Len", types.Typ[types.Int], false), types.NewField(token.NoPos, nil, "Len", types.Typ[types.Int], false),

View File

@@ -8,7 +8,6 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"math" "math"
"net/url" "net/url"
@@ -84,7 +83,7 @@ func mainerr() (err error) {
// Output. // Output.
if *output != "" { if *output != "" {
err = ioutil.WriteFile(*output, body, 0o640) err = os.WriteFile(*output, body, 0o640)
} else { } else {
_, err = os.Stdout.Write(body) _, err = os.Stdout.Write(body)
} }
@@ -103,7 +102,7 @@ var templates embed.FS
func load() (string, error) { func load() (string, error) {
// Prefer explicit filename, if provided. // Prefer explicit filename, if provided.
if *tmpl != "" { if *tmpl != "" {
b, err := ioutil.ReadFile(*tmpl) b, err := os.ReadFile(*tmpl)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -125,7 +124,7 @@ func load() (string, error) {
// include template function. // include template function.
func include(filename string) (string, error) { func include(filename string) (string, error) {
b, err := ioutil.ReadFile(filename) b, err := os.ReadFile(filename)
if err != nil { if err != nil {
return "", err return "", err
} }

View File

@@ -1,7 +1,7 @@
package inst_test package inst_test
import ( import (
"io/ioutil" "os"
"reflect" "reflect"
"sort" "sort"
"strings" "strings"
@@ -187,7 +187,7 @@ func TestInstructionArities(t *testing.T) {
} }
func TestStdLibOpcodes(t *testing.T) { func TestStdLibOpcodes(t *testing.T) {
b, err := ioutil.ReadFile("testdata/stdlibopcodes.txt") b, err := os.ReadFile("testdata/stdlibopcodes.txt")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -46,7 +46,6 @@ type InstructionSet struct {
// :ivar summary: a summary description of the instruction name. // :ivar summary: a summary description of the instruction name.
// :ivar forms: a list of :class:`InstructionForm` objects representing the instruction forms. // :ivar forms: a list of :class:`InstructionForm` objects representing the instruction forms.
// """ // """
//
type Instruction struct { type Instruction struct {
Name string `xml:"name,attr"` Name string `xml:"name,attr"`
Summary string `xml:"summary,attr"` Summary string `xml:"summary,attr"`
@@ -114,7 +113,6 @@ type Instruction struct {
// the instruction. // the instruction.
// :ivar encodings: a list of :class:`Encoding` objects representing the possible encodings for this instruction. // :ivar encodings: a list of :class:`Encoding` objects representing the possible encodings for this instruction.
// """ // """
//
type Form struct { type Form struct {
GASName string `xml:"gas-name,attr"` GASName string `xml:"gas-name,attr"`
GoName string `xml:"go-name,attr"` GoName string `xml:"go-name,attr"`
@@ -356,7 +354,6 @@ type Form struct {
// encode values in the [-128, 127] range. But if it is extended to 4 bytes, it can also encode values in \ // encode values in the [-128, 127] range. But if it is extended to 4 bytes, it can also encode values in \
// [2**32 - 128, 2**32 - 1] range. // [2**32 - 128, 2**32 - 1] range.
// """ // """
//
type Operand struct { type Operand struct {
Type string `xml:"type,attr"` Type string `xml:"type,attr"`
Input bool `xml:"input,attr"` Input bool `xml:"input,attr"`
@@ -432,7 +429,6 @@ type ImplicitOperand struct {
// - "AES" := `AES` instruction set. // - "AES" := `AES` instruction set.
// - "SHA" := `SHA` instruction set. // - "SHA" := `SHA` instruction set.
// """ // """
//
type ISA struct { type ISA struct {
ID string `xml:"id,attr"` ID string `xml:"id,attr"`
} }
@@ -482,7 +478,6 @@ type Encoding struct {
// If X is a reference to an instruction operand, the operand is of memory type and the REX.X bit specifies the \ // If X is a reference to an instruction operand, the operand is of memory type and the REX.X bit specifies the \
// high bit (bit 3) of the index register number, and the B instance variable refers to the same operand. // high bit (bit 3) of the index register number, and the B instance variable refers to the same operand.
// """ // """
//
type REX struct { type REX struct {
Mandatory bool `xml:"mandatory,attr"` Mandatory bool `xml:"mandatory,attr"`
W uint `xml:"W,attr"` W uint `xml:"W,attr"`
@@ -581,7 +576,6 @@ type REX struct {
// If vvvv is a reference to an instruction operand, the operand is of register type and VEX.vvvv field specifies \ // If vvvv is a reference to an instruction operand, the operand is of register type and VEX.vvvv field specifies \
// its number. // its number.
// """ // """
//
type VEX struct { type VEX struct {
Type string `xml:"type,attr"` Type string `xml:"type,attr"`
W *uint `xml:"W,attr"` W *uint `xml:"W,attr"`
@@ -713,7 +707,6 @@ type VEX struct {
// //
// None indicates that this instruction form does not use displacement (the form has no memory operands). // None indicates that this instruction form does not use displacement (the form has no memory operands).
// """ // """
//
type EVEX struct { type EVEX struct {
M2 string `xml:"mm,attr"` M2 string `xml:"mm,attr"`
PP string `xml:"pp,attr"` PP string `xml:"pp,attr"`

View File

@@ -4,7 +4,6 @@ package test
import ( import (
"flag" "flag"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@@ -32,7 +31,7 @@ func Assembles(t *testing.T, asm []byte) {
defer clean() defer clean()
asmfilename := filepath.Join(dir, "asm.s") asmfilename := filepath.Join(dir, "asm.s")
if err := ioutil.WriteFile(asmfilename, asm, 0o600); err != nil { if err := os.WriteFile(asmfilename, asm, 0o600); err != nil {
t.Fatal(err) t.Fatal(err)
} }
@@ -46,7 +45,7 @@ func Assembles(t *testing.T, asm []byte) {
func TempDir(t *testing.T) (string, func()) { func TempDir(t *testing.T) (string, func()) {
t.Helper() t.Helper()
dir, err := ioutil.TempDir("", "avo") dir, err := os.MkdirTemp("", "avo")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@@ -4,7 +4,9 @@
go install ./internal/cmd/asmvet go install ./internal/cmd/asmvet
# golangci-lint for linting # golangci-lint for linting
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.3-0.20220410144555-f36840520dec golangci_lint_version='v1.49.0'
golangci_install_script="https://raw.githubusercontent.com/golangci/golangci-lint/${golangci_lint_version}/install.sh"
curl -sfL "${golangci_install_script}" | sh -s -- -b "$GOPATH/bin" "${golangci_lint_version}"
# embedmd required for documentation generation # embedmd required for documentation generation
go install github.com/campoy/embedmd@v1.0.0 go install github.com/campoy/embedmd@v1.0.0