Unverified Commit ec19d4c5 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #6321 from ipfs/ci/golangci-lint

Add golangci-lint
parents 373a49f4 9beddcd1
......@@ -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:
......
......@@ -141,7 +141,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'
......
......@@ -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 {
......
......@@ -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
......
......@@ -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 {
......
......@@ -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)
......
......@@ -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
}()
......
......@@ -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
......
......@@ -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())
......
......@@ -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)
}
......
......@@ -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
......@@ -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
......
This diff is collapsed.
......@@ -65,10 +65,9 @@ test_go_fmt:
.PHONY: test_go_fmt
TEST_GO += test_go_fmt
test_go_megacheck:
@$(GOCC) get honnef.co/go/tools/cmd/megacheck
@for pkg in $(go-pkgs); do megacheck "$$pkg"; done
.PHONY: megacheck
test_go_lint: test/bin/golangci-lint
golangci-lint run ./...
.PHONY: test_go_lint
test_go: $(TEST_GO)
......
......@@ -54,6 +54,9 @@ $(d)/gocovmerge:
$(call go-build,github.com/Kubuxu/gocovmerge)
TGTS_$(d) += $(d)/gocovmerge
$(d)/golangci-lint:
$(call go-build,github.com/golangci/golangci-lint/cmd/golangci-lint)
TGTS_$(d) += $(d)/golangci-lint
$(TGTS_$(d)): $$(DEPS_GO)
......
......@@ -4,6 +4,7 @@ package tools
import (
_ "github.com/Kubuxu/gocovmerge"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/ipfs/go-cidutil/cid-fmt"
_ "github.com/ipfs/hang-fds"
_ "github.com/jbenet/go-random-files/random-files"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment