Skip to content

Commit

Permalink
remove outdated linter
Browse files Browse the repository at this point in the history
remove redundant imports
remove deprecated and implicit rand seed init
adjust test
  • Loading branch information
nikooo777 committed Apr 9, 2024
1 parent 14fbd2a commit de736b0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
5 changes: 2 additions & 3 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion lite_db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 0 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package main

import (
"math/rand"
"time"

"github.com/lbryio/reflector.go/cmd"

"github.com/google/gops/agent"
Expand All @@ -14,6 +11,5 @@ func main() {
if err := agent.Listen(agent.Options{}); err != nil {
log.Fatal(err)
}
rand.Seed(time.Now().UnixNano())
cmd.Execute()
}
7 changes: 3 additions & 4 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion store/caching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit de736b0

Please sign in to comment.