mirror of
https://github.com/LBRYFoundation/reflector.go.git
synced 2025-08-23 09:17:24 +00:00
remove outdated linter
remove redundant imports remove deprecated and implicit rand seed init adjust test
This commit is contained in:
parent
14fbd2ae27
commit
de736b068d
6 changed files with 9 additions and 15 deletions
|
@ -28,8 +28,8 @@ before_script:
|
||||||
- go install github.com/fzipp/gocyclo/cmd/gocyclo@latest # Check against high complexity
|
- 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/mdempsky/unconvert@latest # Identifies unnecessary type conversions
|
||||||
- go install github.com/kisielk/errcheck@latest # Checks for unhandled errors
|
- 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 gitlab.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/structcheck@latest # Checks for unused fields in structs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
5
db/db.go
5
db/db.go
|
@ -15,7 +15,6 @@ import (
|
||||||
"github.com/lbryio/lbry.go/v2/stream"
|
"github.com/lbryio/lbry.go/v2/stream"
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
"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"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/volatiletech/null/v8"
|
"github.com/volatiletech/null/v8"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
@ -98,7 +97,7 @@ func (s *SQL) AddBlob(hash string, length int, isStored bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//AddBlobs adds blobs to the database.
|
// AddBlobs adds blobs to the database.
|
||||||
func (s *SQL) AddBlobs(hash []string) error {
|
func (s *SQL) AddBlobs(hash []string) error {
|
||||||
if s.conn == nil {
|
if s.conn == nil {
|
||||||
return errors.Err("not connected")
|
return errors.Err("not connected")
|
||||||
|
@ -419,7 +418,7 @@ func (s *SQL) Delete(hash string) error {
|
||||||
return errors.Err(err)
|
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) {
|
func (s *SQL) LeastRecentlyAccessedHashes(maxBlobs int) ([]string, error) {
|
||||||
if s.conn == nil {
|
if s.conn == nil {
|
||||||
return nil, errors.Err("not connected")
|
return nil, errors.Err("not connected")
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
qt "github.com/lbryio/lbry.go/v2/extras/query"
|
qt "github.com/lbryio/lbry.go/v2/extras/query"
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
"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"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/volatiletech/null/v8"
|
"github.com/volatiletech/null/v8"
|
||||||
)
|
)
|
||||||
|
|
4
main.go
4
main.go
|
@ -1,9 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/lbryio/reflector.go/cmd"
|
"github.com/lbryio/reflector.go/cmd"
|
||||||
|
|
||||||
"github.com/google/gops/agent"
|
"github.com/google/gops/agent"
|
||||||
|
@ -14,6 +11,5 @@ func main() {
|
||||||
if err := agent.Listen(agent.Options{}); err != nil {
|
if err := agent.Listen(agent.Options{}); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
cmd.Execute()
|
cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/jgautheron/gocyclo@latest # Check against high complexity
|
||||||
go install github.com/mdempsky/unconvert@latest # Identifies unnecessary type conversions
|
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/kisielk/errcheck@latest # Checks for unhandled errors
|
||||||
go install github.com/opennota/check/cmd/varcheck@latest # Checks for unused vars
|
go install honnef.co/go/tools/cmd/staticcheck@latest # all sorts of static analysis
|
||||||
go install github.com/opennota/check/cmd/structcheck@latest # Checks for unused fields in structs
|
|
||||||
)
|
)
|
||||||
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
|
# go vet is the official Go static analyzer
|
||||||
echo "Running go vet..." && go vet $(go list ./...)
|
echo "Running go vet..." && go vet $(go list ./...)
|
||||||
# checks for unhandled errors
|
# checks for unhandled errors
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/lbryio/reflector.go/shared"
|
"github.com/lbryio/reflector.go/shared"
|
||||||
|
|
||||||
"github.com/lbryio/lbry.go/v2/stream"
|
"github.com/lbryio/lbry.go/v2/stream"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCachingStore_Put(t *testing.T) {
|
func TestCachingStore_Put(t *testing.T) {
|
||||||
|
@ -99,7 +100,7 @@ func TestCachingStore_ThunderingHerd(t *testing.T) {
|
||||||
getNoErr := func() {
|
getNoErr := func() {
|
||||||
res, _, err := s.Get(hash)
|
res, _, err := s.Get(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(b, res) {
|
if !bytes.Equal(b, res) {
|
||||||
t.Errorf("expected Get() to return %s, got %s", string(b), string(res))
|
t.Errorf("expected Get() to return %s, got %s", string(b), string(res))
|
||||||
|
|
Loading…
Add table
Reference in a new issue