ci: Fix linter complaint (backport #9645) (#9647)

* ci: Fix linter complaint (#9645)

Fixes a very silly linter complaint that makes absolutely no sense and is blocking the merging of several PRs.

---

#### PR checklist

- [x] Tests written/updated, or no tests needed
- [x] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [x] Updated relevant documentation (`docs/`) and code comments, or no
      documentation updates needed

(cherry picked from commit 83b7f4ad5b)

# Conflicts:
#	.github/workflows/lint.yml
#	.golangci.yml
#	cmd/tendermint/commands/debug/util.go

* Resolve conflicts

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* ci: Sync golangci-lint config with main

Minus the spelling configuration that restricts spelling to US English
only.

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* make format

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove usage of deprecated io/ioutil package

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Remove unused mockBlockStore

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* blockchain/v2: Remove unused method

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Bulk fix lints

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* lint: Ignore auto-generated query PEG

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
mergify[bot]
2022-10-29 08:58:18 -04:00
committed by GitHub
parent a6dd0d270a
commit e914fe40ec
93 changed files with 425 additions and 476 deletions

View File

@@ -1,12 +1,13 @@
package v0_test
import (
"io/ioutil"
"io"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
mempoolv0 "github.com/tendermint/tendermint/test/fuzz/mempool/v0"
)
@@ -25,7 +26,7 @@ func TestMempoolTestdataCases(t *testing.T) {
}()
f, err := os.Open(filepath.Join(testdataCasesDir, entry.Name()))
require.NoError(t, err)
input, err := ioutil.ReadAll(f)
input, err := io.ReadAll(f)
require.NoError(t, err)
mempoolv0.Fuzz(input)
})

View File

@@ -1,12 +1,13 @@
package v1_test
import (
"io/ioutil"
"io"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
mempoolv1 "github.com/tendermint/tendermint/test/fuzz/mempool/v1"
)
@@ -25,7 +26,7 @@ func TestMempoolTestdataCases(t *testing.T) {
}()
f, err := os.Open(filepath.Join(testdataCasesDir, entry.Name()))
require.NoError(t, err)
input, err := ioutil.ReadAll(f)
input, err := io.ReadAll(f)
require.NoError(t, err)
mempoolv1.Fuzz(input)
})

View File

@@ -1,4 +1,3 @@
//nolint: gosec
package addr
import (
@@ -25,6 +24,7 @@ func Fuzz(data []byte) int {
}
// Also, make sure PickAddress always returns a non-nil address.
//nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
bias := rand.Intn(100)
if p := addrBook.PickAddress(bias); p == nil {
panic(fmt.Sprintf("picked a nil address (bias: %d, addrBook size: %v)",

View File

@@ -1,11 +1,9 @@
//nolint: gosec
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"os"
@@ -27,7 +25,7 @@ func initCorpus(baseDir string) {
// create "corpus" directory
corpusDir := filepath.Join(baseDir, "corpus")
if err := os.MkdirAll(corpusDir, 0755); err != nil {
if err := os.MkdirAll(corpusDir, 0o755); err != nil {
log.Fatalf("Creating %q err: %v", corpusDir, err)
}
@@ -49,7 +47,8 @@ func initCorpus(baseDir string) {
log.Fatalf("can't marshal %v: %v", addr, err)
}
if err := ioutil.WriteFile(filename, bz, 0644); err != nil {
//nolint:gosec // G306: Expect WriteFile permissions to be 0600 or less
if err := os.WriteFile(filename, bz, 0o644); err != nil {
log.Fatalf("can't write %v to %q: %v", addr, filename, err)
}

View File

@@ -1,10 +1,8 @@
//nolint: gosec
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"math/rand"
"os"
@@ -22,11 +20,12 @@ func main() {
initCorpus(*baseDir)
}
//nolint:gosec
func initCorpus(rootDir string) {
log.SetFlags(0)
corpusDir := filepath.Join(rootDir, "corpus")
if err := os.MkdirAll(corpusDir, 0755); err != nil {
if err := os.MkdirAll(corpusDir, 0o755); err != nil {
log.Fatalf("Creating %q err: %v", corpusDir, err)
}
sizes := []int{0, 1, 2, 17, 5, 31}
@@ -73,7 +72,7 @@ func initCorpus(rootDir string) {
filename := filepath.Join(rootDir, "corpus", fmt.Sprintf("%d", n))
if err := ioutil.WriteFile(filename, bz, 0644); err != nil {
if err := os.WriteFile(filename, bz, 0o644); err != nil {
log.Fatalf("can't write %X to %q: %v", bz, filename, err)
}

View File

@@ -1,10 +1,8 @@
//nolint: gosec
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -21,7 +19,7 @@ func initCorpus(baseDir string) {
log.SetFlags(0)
corpusDir := filepath.Join(baseDir, "corpus")
if err := os.MkdirAll(corpusDir, 0755); err != nil {
if err := os.MkdirAll(corpusDir, 0o755); err != nil {
log.Fatal(err)
}
@@ -39,7 +37,8 @@ func initCorpus(baseDir string) {
for i, datum := range data {
filename := filepath.Join(corpusDir, fmt.Sprintf("%d", i))
if err := ioutil.WriteFile(filename, []byte(datum), 0644); err != nil {
//nolint:gosec // G306: Expect WriteFile permissions to be 0600 or less
if err := os.WriteFile(filename, []byte(datum), 0o644); err != nil {
log.Fatalf("can't write %v to %q: %v", datum, filename, err)
}

View File

@@ -3,7 +3,7 @@ package handler
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
@@ -29,7 +29,7 @@ func Fuzz(data []byte) int {
rec := httptest.NewRecorder()
mux.ServeHTTP(rec, req)
res := rec.Result()
blob, err := ioutil.ReadAll(res.Body)
blob, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}