Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add golangci-lint #6321

Merged
merged 3 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ jobs:
environment:
TEST_NO_FUSE: 1
- *store_gomod
golint:
<<: *defaults
steps:
- checkout
- *make_out_dirs
- *restore_gomod
- run: |
make -O test_go_lint
- *store_gomod
gotest:
<<: *defaults
steps:
Expand Down
2 changes: 1 addition & 1 deletion Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ help:
@echo ' test_go_test - Run all go tests'
@echo ' test_go_expensive - Run all go tests and compile on all platforms'
@echo ' test_go_race - Run go tests with the race detector enabled'
@echo ' test_go_megacheck - Run the `megacheck` vetting tool'
@echo ' test_go_lint - Run the `golangci-lint` vetting tool'
@echo ' test_sharness_short - Run short sharness tests'
@echo ' test_sharness_expensive - Run all sharness tests'
@echo ' coverage - Collects coverage info from unit tests and sharness'
Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfs/util/ulimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestManageInvalidNFds(t *testing.T) {

if changed, new, err := ManageFdLimit(); err == nil {
t.Errorf("ManageFdLimit should return an error: changed %t, new: %d", changed, new)
} else if err != nil {
} else {
flag := strings.Contains(err.Error(),
"failed to raise ulimit to IPFS_FD_MAX")
if !flag {
Expand Down
5 changes: 4 additions & 1 deletion core/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
// Note that some services use contexts to signal shutting down, which is
// very suboptimal. This needs to be here until that's addressed somehow
<-ctx.Done()
app.Stop(context.Background())
err := app.Stop(context.Background())
if err != nil {
log.Error("failure on stop: ", err)
}
}()

n.IsOnline = cfg.Online
Expand Down
3 changes: 3 additions & 0 deletions core/commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ It takes a list of base58 encoded multihashes to remove.
// TODO: use batching coreapi when done
for _, b := range req.Arguments {
rp, err := api.ResolvePath(req.Context, path.New(b))
if err != nil {
return err
}

err = api.Block().Rm(req.Context, rp, options.Block.Force(force))
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil {
c.SetAllowedMethods(acam...)
}
if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil {
for _, v := range acac {
c.SetAllowCredentials(strings.ToLower(v) == "true")
}
for _, v := range nc.API.HTTPHeaders[cmdsHttp.ACACredentials] {
c.SetAllowCredentials(strings.ToLower(v) == "true")
}

c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1)
Expand Down
2 changes: 1 addition & 1 deletion core/coreunix/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestAddMultipleGCLive(t *testing.T) {

go func() {
defer close(out)
adder.AddAllAndPin(slf)
_, _ = adder.AddAllAndPin(slf)
// Ignore errors for clarity - the real bug would be gc'ing files while adding them, not this resultant error
}()

Expand Down
3 changes: 0 additions & 3 deletions core/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ import (
ds "github.com/ipfs/go-datastore"
dsync "github.com/ipfs/go-datastore/sync"
cfg "github.com/ipfs/go-ipfs-config"
logging "github.com/ipfs/go-log"
ci "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
)

var log = logging.Logger("node")

type BuildCfg struct {
// If online is set, the node will have networking enabled
Online bool
Expand Down
2 changes: 1 addition & 1 deletion core/node/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func GcBlockstoreCtor(bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockst

// GcBlockstoreCtor wraps GcBlockstore and adds Filestore support
func FilestoreBlockstoreCtor(repo repo.Repo, bb BaseBlocks) (gclocker blockstore.GCLocker, gcbs blockstore.GCBlockstore, bs blockstore.Blockstore, fstore *filestore.Filestore) {
gclocker, gcbs, bs = GcBlockstoreCtor(bb)
gclocker = blockstore.NewGCLocker()

// hash security
fstore = filestore.NewFilestore(bb, repo.FileManager())
Expand Down
2 changes: 1 addition & 1 deletion filestore/fsrefstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (f *FileManager) putTo(b *posinfo.FilestoreNode, to putter) error {
if !f.AllowFiles {
return ErrFilestoreNotEnabled
}
if !filepath.HasPrefix(b.PosInfo.FullPath, f.root) {
if !filepath.HasPrefix(b.PosInfo.FullPath, f.root) { //nolint:staticcheck
return fmt.Errorf("cannot add filestore references outside ipfs root (%s)", f.root)
}

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/fatih/color v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.4.7
github.com/gogo/protobuf v1.2.1
github.com/golangci/golangci-lint v1.16.0
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/golang-lru v0.5.1
github.com/hsanjuan/go-libp2p-http v0.0.2
Expand Down Expand Up @@ -120,9 +121,9 @@ require (
go.uber.org/goleak v0.10.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/sys v0.0.0-20190426135247-a129542de9ae
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20190425222832-ad9eeb80039a // indirect
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373 // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28
gotest.tools/gotestsum v0.3.4
Expand Down
Loading