From de736b068d75b4241d35026d770c446990337ea0 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Tue, 9 Apr 2024 20:00:46 +0200 Subject: [PATCH] remove outdated linter remove redundant imports remove deprecated and implicit rand seed init adjust test --- .travis.yml | 4 ++-- db/db.go | 5 ++--- lite_db/db.go | 1 - main.go | 4 ---- scripts/lint.sh | 7 +++---- store/caching_test.go | 3 ++- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8b7a67f..6a71add 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,8 @@ before_script: - go install github.com/fzipp/gocyclo/cmd/gocyclo@latest # Check against high complexity - go install github.com/mdempsky/unconvert@latest # Identifies unnecessary type conversions - go install github.com/kisielk/errcheck@latest # Checks for unhandled errors - - go install github.com/opennota/check/cmd/varcheck@latest # Checks for unused vars - - go install github.com/opennota/check/cmd/structcheck@latest # Checks for unused fields in structs + - go install gitlab.com/opennota/check/cmd/varcheck@latest # Checks for unused vars + - go install gitlab.com/opennota/check/cmd/structcheck@latest # Checks for unused fields in structs diff --git a/db/db.go b/db/db.go index c7dd2da..c2f5019 100644 --- a/db/db.go +++ b/db/db.go @@ -15,7 +15,6 @@ import ( "github.com/lbryio/lbry.go/v2/stream" "github.com/go-sql-driver/mysql" - _ "github.com/go-sql-driver/mysql" // blank import for db driver ensures its imported even if its not used log "github.com/sirupsen/logrus" "github.com/volatiletech/null/v8" "go.uber.org/atomic" @@ -98,7 +97,7 @@ func (s *SQL) AddBlob(hash string, length int, isStored bool) error { return err } -//AddBlobs adds blobs to the database. +// AddBlobs adds blobs to the database. func (s *SQL) AddBlobs(hash []string) error { if s.conn == nil { return errors.Err("not connected") @@ -419,7 +418,7 @@ func (s *SQL) Delete(hash string) error { return errors.Err(err) } -//LeastRecentlyAccessedHashes gets the least recently accessed blobs +// LeastRecentlyAccessedHashes gets the least recently accessed blobs func (s *SQL) LeastRecentlyAccessedHashes(maxBlobs int) ([]string, error) { if s.conn == nil { return nil, errors.Err("not connected") diff --git a/lite_db/db.go b/lite_db/db.go index 128f52c..ea9ba5d 100644 --- a/lite_db/db.go +++ b/lite_db/db.go @@ -8,7 +8,6 @@ import ( qt "github.com/lbryio/lbry.go/v2/extras/query" "github.com/go-sql-driver/mysql" - _ "github.com/go-sql-driver/mysql" // blank import for db driver ensures its imported even if its not used log "github.com/sirupsen/logrus" "github.com/volatiletech/null/v8" ) diff --git a/main.go b/main.go index 7b76efe..eca3cb9 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,6 @@ package main import ( - "math/rand" - "time" - "github.com/lbryio/reflector.go/cmd" "github.com/google/gops/agent" @@ -14,6 +11,5 @@ func main() { if err := agent.Listen(agent.Options{}); err != nil { log.Fatal(err) } - rand.Seed(time.Now().UnixNano()) cmd.Execute() } diff --git a/scripts/lint.sh b/scripts/lint.sh index 5f923cb..a1bcb08 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -10,11 +10,10 @@ GO_FILES=$(find . -iname '*.go' -type f) go install github.com/jgautheron/gocyclo@latest # Check against high complexity go install github.com/mdempsky/unconvert@latest # Identifies unnecessary type conversions go install github.com/kisielk/errcheck@latest # Checks for unhandled errors - go install github.com/opennota/check/cmd/varcheck@latest # Checks for unused vars - go install github.com/opennota/check/cmd/structcheck@latest # Checks for unused fields in structs + go install honnef.co/go/tools/cmd/staticcheck@latest # all sorts of static analysis ) -echo "Running varcheck..." && varcheck $(go list ./...) -echo "Running structcheck..." && structcheck $(go list ./...) + +# echo "Running unused..." && staticcheck $(go list ./...) # go vet is the official Go static analyzer echo "Running go vet..." && go vet $(go list ./...) # checks for unhandled errors diff --git a/store/caching_test.go b/store/caching_test.go index 6fd5544..a7cf103 100644 --- a/store/caching_test.go +++ b/store/caching_test.go @@ -9,6 +9,7 @@ import ( "github.com/lbryio/reflector.go/shared" "github.com/lbryio/lbry.go/v2/stream" + "github.com/sirupsen/logrus" ) func TestCachingStore_Put(t *testing.T) { @@ -99,7 +100,7 @@ func TestCachingStore_ThunderingHerd(t *testing.T) { getNoErr := func() { res, _, err := s.Get(hash) if err != nil { - t.Fatal(err) + logrus.Fatal(err) } if !bytes.Equal(b, res) { t.Errorf("expected Get() to return %s, got %s", string(b), string(res))