ci: replace golangci-lint with staticcheck

This commit is contained in:
Dan Kortschak
2022-05-10 22:36:00 +09:30
parent 84fd2bc2bb
commit a2c6f817bf
31 changed files with 68 additions and 62 deletions

View File

@@ -1,16 +0,0 @@
name: golangci-lint
on:
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.44.2
only-new-issues: true
args: --timeout=5m

18
.github/workflows/staticcheck.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Staticcheck
on:
pull_request:
branches: [master]
jobs:
ci:
name: lint
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: dominikh/staticcheck-action@v1.2.0
with:
version: "2022.1"

View File

@@ -292,14 +292,14 @@ type errFile struct {
err error
}
func (f errFile) Write(b []byte) {
func (f *errFile) Write(b []byte) {
if f.err != nil {
return
}
_, f.err = f.file.Write(b)
}
func (f errFile) WriteString(s string) {
func (f *errFile) WriteString(s string) {
if f.err != nil {
return
}

View File

@@ -1,6 +1,6 @@
//line check.rl:1
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -1,4 +1,4 @@
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -1,6 +1,6 @@
//line extract.rl:1
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -1,4 +1,4 @@
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -282,11 +282,11 @@ func hashBNodes(statements []*Statement, h hash.Hash, zero []byte, hash0 map[str
}
case isIRI(t):
h.Reset()
h.Write([]byte(t[1 : len(t)-1])) //nolint:errcheck
h.Write([]byte(t[1 : len(t)-1]))
curr.set(t, h.Sum(nil))
default:
h.Reset()
h.Write([]byte(t)) //nolint:errcheck
h.Write([]byte(t))
curr.set(t, h.Sum(nil))
}
}
@@ -515,7 +515,7 @@ func (b lexical) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
func hashTuple(h hash.Hash, t ...[]byte) []byte {
h.Reset()
for _, b := range t {
h.Write(b) //nolint:errcheck
h.Write(b)
}
return h.Sum(nil)
}

View File

@@ -312,7 +312,7 @@ func hashBlanks(s []*Statement, h hash.Hash) ([]*Statement, map[string]string) {
continue
}
h.Reset()
h.Write([]byte(t)) //nolint:errcheck
h.Write([]byte(t))
terms[t] = fmt.Sprintf("_:%0*x", 2*h.Size(), h.Sum(nil))
}
}
@@ -334,7 +334,7 @@ func mangleFirstIL(s []*Statement, h hash.Hash) ([]*Statement, map[string]string
continue
}
h.Reset()
h.Write([]byte(t)) //nolint:errcheck
h.Write([]byte(t))
terms[t] = fmt.Sprintf(`"%0*x"`, 2*h.Size(), h.Sum(nil))
return relabelStatements(s, terms), terms
}

View File

@@ -1,6 +1,6 @@
//line parse.rl:1
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -1,4 +1,4 @@
// Go code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Code generated by go generate gonum.org/v1/gonum/graph/formats/rdf; DO NOT EDIT.
// Copyright ©2020 The Gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@@ -368,7 +368,7 @@ func (u *urna) hashNDegreeQuads(b string, names *issuer) ([]byte, *issuer) {
// 5.5
final = append(final, chosenPath...)
u.hash.Reset()
u.hash.Write(final) //nolint:errcheck
u.hash.Write(final)
names = chosenIssuer // 5.6
}
@@ -468,23 +468,23 @@ func (u *urna) hashRelatedBlank(term string, s *Statement, names *issuer, pos by
// 2.
u.hash.Reset()
u.hash.Write([]byte{pos}) //nolint:errcheck
u.hash.Write([]byte{pos})
if pos != 'g' { // 3.
if u.label == "" {
// URDNA2015: Term.Value retained the angle quotes
// so we don't need to add them.
u.hash.Write([]byte(s.Predicate.Value)) //nolint:errcheck
u.hash.Write([]byte(s.Predicate.Value))
} else {
// URGNA2012 does not delimit predicate by < and >.
// https://json-ld.github.io/rdf-dataset-canonicalization/spec/index.html#urgna2012
// with reference to 4.7.
u.hash.Write([]byte(unquoteIRI(s.Predicate.Value))) //nolint:errcheck
u.hash.Write([]byte(unquoteIRI(s.Predicate.Value)))
}
}
// 4. and 5.
u.hash.Write([]byte(b)) //nolint:errcheck
u.hash.Write([]byte(b))
return hex(u.hash.Sum(nil))
}

View File

@@ -46,10 +46,6 @@ func TestSameInt64s(t *testing.T) {
func TestAddInt64s(t *testing.T) {
s := make(Int64s)
if s == nil {
t.Fatal("Set cannot be created successfully")
}
if s.Count() != 0 {
t.Error("Set somehow contains new elements upon creation")
}
@@ -183,10 +179,6 @@ func TestSameInts(t *testing.T) {
func TestAddInts(t *testing.T) {
s := make(Ints)
if s == nil {
t.Fatal("Set cannot be created successfully")
}
if s.Count() != 0 {
t.Error("Set somehow contains new elements upon creation")
}

View File

@@ -31,6 +31,7 @@ type emptyInterface struct {
// Having a clone here allows us to embed a map iterator
// inside type mapIter so that mapIters can be re-used
// without doing any allocations.
//lint:ignore U1000 This is a verbatim copy of the runtime type.
type hiter struct {
key unsafe.Pointer
elem unsafe.Pointer

View File

@@ -245,7 +245,7 @@ func TestAxpyIncTo(t *testing.T) {
if inc.x*inc.y < 0 {
want = test.wantRev
}
var iW, incW int = 0, 1
iW, incW := 0, 1
if inc.y*inc.dst < 0 {
iW, incW = len(want)-1, -1
}

View File

@@ -453,7 +453,7 @@ func TestDivTo(t *testing.T) {
}
func TestL1Dist(t *testing.T) {
var t_gd, s_gd float64 = -inf, inf
t_gd, s_gd := -inf, inf
for j, v := range []struct {
s, t []float64
expect float64

View File

@@ -0,0 +1 @@
checks = ["inherit", "-U1000"]

View File

@@ -17,6 +17,7 @@ import (
// The higher-precision values in vc26 were used to derive the
// input arguments vc (see also comment below). For reference
// only (do not delete).
//lint:ignore U1000 See comment above.
var vc26 = []complex64{
(4.97901192488367350108546816 + 7.73887247457810456552351752i),
(7.73887247457810456552351752 - 0.27688005719200159404635997i),

View File

@@ -13,9 +13,8 @@ import (
"gonum.org/v1/gonum/lapack"
)
var resultGeneral blas64.General
func DgeevBenchmark(b *testing.B, impl Dgeever) {
var resultGeneral blas64.General
rnd := rand.New(rand.NewSource(1))
benchmarks := []struct {
name string
@@ -59,4 +58,7 @@ func DgeevBenchmark(b *testing.B, impl Dgeever) {
resultGeneral = a
})
}
if resultGeneral.Data == nil {
b.Error("unexpected nil data")
}
}

View File

@@ -6,6 +6,7 @@ package testlapack
import (
"fmt"
"math"
"testing"
"golang.org/x/exp/rand"
@@ -14,6 +15,7 @@ import (
)
func DlangbBenchmark(b *testing.B, impl Dlangber) {
var result float64
rnd := rand.New(rand.NewSource(1))
for _, bm := range []struct {
n, k int
@@ -83,4 +85,7 @@ func DlangbBenchmark(b *testing.B, impl Dlangber) {
})
}
}
if math.IsNaN(result) {
b.Error("unexpected NaN result")
}
}

View File

@@ -6,6 +6,7 @@ package testlapack
import (
"fmt"
"math"
"testing"
"golang.org/x/exp/rand"
@@ -14,9 +15,8 @@ import (
"gonum.org/v1/gonum/lapack"
)
var result float64
func DlantbBenchmark(b *testing.B, impl Dlantber) {
var result float64
rnd := rand.New(rand.NewSource(1))
for _, bm := range []struct {
n, k int
@@ -51,4 +51,7 @@ func DlantbBenchmark(b *testing.B, impl Dlantber) {
}
}
}
if math.IsNaN(result) {
b.Error("unexpected NaN result")
}
}

View File

@@ -11,9 +11,11 @@ import (
// This file implements types for helping to convert to Fortran testing capabilities.
//lint:file-ignore U1000 A number of functions are here that may be used in future.
// fortran64 is a float64 type that prints as a double precision constant in
// Fortran format.
type fortran64 float64 //nolint:unused
type fortran64 float64
func (f fortran64) String() string {
// Replace exponent with D
@@ -24,7 +26,6 @@ func (f fortran64) String() string {
// printFortranArray prints a Go slice as an array that can be copied into a
// fortran script.
//nolint:deadcode,unused
func printFortranArray(z []float64, name string) {
fmt.Printf("%s(1:%d) = (/%v, &\n", name, len(z), fortran64(z[0]))
for i := 1; i < len(z)-1; i++ {

View File

@@ -917,7 +917,7 @@ func constructQPBidiagonal(vect lapack.ApplyOrtho, m, n, nb int, a []float64, ld
// printRowise prints the matrix with one row per line. This is useful for debugging.
// If beyond is true, it prints beyond the final column to lda. If false, only
// the columns are printed.
//nolint:deadcode,unused
//lint:ignore U1000 This is useful for debugging.
func printRowise(a []float64, m, n, lda int, beyond bool) {
for i := 0; i < m; i++ {
end := n
@@ -1113,6 +1113,7 @@ func isSchurCanonicalGeneral(t blas64.General) bool {
// schurBlockEigenvalues returns the two eigenvalues of the 2×2 matrix [a b; c d]
// that must be in Schur canonical form.
//lint:ignore U1000 This is useful for debugging.
func schurBlockEigenvalues(a, b, c, d float64) (ev1, ev2 complex128) {
if !isSchurCanonical(a, b, c, d) {
panic("block not in Schur canonical form")

View File

@@ -460,7 +460,7 @@ func TestCholeskySymRankOne(t *testing.T) {
0, 0, 6, 10,
0, 0, 0, 20,
}),
alpha: -1 / 2,
alpha: -0.5,
x: []float64{0, 0, 0, 1},
wantOk: true,
},

View File

@@ -319,15 +319,6 @@ func (t *TriBandDense) SetTriBand(i, j int, v float64) {
t.mat.Data[i*t.mat.Stride+pj] = v
}
func (t *TriBandDense) setTriBand(i, j int, v float64) {
var kl int
if !t.isUpper() {
kl = t.mat.K
}
pj := j + kl - i
t.mat.Data[i*t.mat.Stride+pj] = v
}
// At returns the element at row i, column j.
func (d *DiagDense) At(i, j int) float64 {
if uint(i) >= uint(d.mat.N) {

View File

@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//nolint:deadcode,unused
//lint:file-ignore U1000 A number of functions are here that may be used in future.
package mat
import (

View File

@@ -207,6 +207,7 @@ func (s *SymBandDense) checkOverlap(a blas64.General) bool {
return checkOverlap(generalFromSymmetricBand(s.RawSymBand()), a)
}
//lint:ignore U1000 This will be used when we do shadow checks for banded matrices.
func (s *SymBandDense) checkOverlapMatrix(a Matrix) bool {
if s == a {
return false

View File

@@ -324,6 +324,7 @@ func (t *TriBandDense) reuseAsZeroed(n, k int, kind TriKind) {
// with the given bandwidth and orientation. If the receiver is not empty,
// reuseAsZeroed checks that the receiver has the correct size, bandwidth and
// orientation.
//lint:ignore U1000 This will be used later.
func (t *TriBandDense) reuseAsNonZeroed(n, k int, kind TriKind) {
// reuseAsNonZeroed must be kept in sync with reuseAsZeroed.
if n == 0 {

View File

@@ -0,0 +1 @@
checks = []

View File

@@ -0,0 +1 @@
checks = []

1
staticcheck.conf Normal file
View File

@@ -0,0 +1 @@
checks = ["inherit", "-ST1012"]