Skip to content

Commit

Permalink
Merge pull request #6362 from ipfs/ci/really-enable-lint
Browse files Browse the repository at this point in the history
ci: actually enable golangci-lint
  • Loading branch information
Stebalien authored May 21, 2019
2 parents cf3b6c4 + c39ad0b commit 480780e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ workflows:
test:
jobs:
- gobuild
- golint
- gotest
- sharness
16 changes: 8 additions & 8 deletions core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,15 @@ Different key types can specify other 'best' rules.
pfm := pfuncMap{
notif.Value: func(obj *notif.QueryEvent, out io.Writer, verbose bool) error {
if verbose {
fmt.Fprintf(out, "got value: '%s'\n", obj.Extra)
} else {
res, err := base64.StdEncoding.DecodeString(obj.Extra)
if err != nil {
return err
}
out.Write(res)
_, err := fmt.Fprintf(out, "got value: '%s'\n", obj.Extra)
return err
}
return nil
res, err := base64.StdEncoding.DecodeString(obj.Extra)
if err != nil {
return err
}
_, err = out.Write(res)
return err
},
}

Expand Down
19 changes: 10 additions & 9 deletions core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
peer "github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
swarm "github.com/libp2p/go-libp2p-swarm"
mafilter "github.com/libp2p/go-maddr-filter"
ma "github.com/multiformats/go-multiaddr"
madns "github.com/multiformats/go-multiaddr-dns"
mafilter "github.com/whyrusleeping/multiaddr-filter"
mamask "github.com/whyrusleeping/multiaddr-filter"
)

const (
Expand Down Expand Up @@ -599,8 +600,8 @@ Filters default to those specified under the "Swarm.AddrFilters" config key.
}

var output []string
for _, f := range swrm.Filters.Filters() {
s, err := mafilter.ConvertIPNet(f)
for _, f := range swrm.Filters.FiltersForAction(mafilter.ActionDeny) {
s, err := mamask.ConvertIPNet(&f)
if err != nil {
return err
}
Expand Down Expand Up @@ -657,12 +658,12 @@ add your filters to the ipfs config file.
}

for _, arg := range req.Arguments {
mask, err := mafilter.NewMask(arg)
mask, err := mamask.NewMask(arg)
if err != nil {
return err
}

swrm.Filters.AddDialFilter(mask)
swrm.Filters.AddFilter(*mask, mafilter.ActionDeny)
}

added, err := filtersAdd(r, cfg, req.Arguments)
Expand Down Expand Up @@ -716,9 +717,9 @@ remove your filters from the ipfs config file.
}

if req.Arguments[0] == "all" || req.Arguments[0] == "*" {
fs := swrm.Filters.Filters()
fs := swrm.Filters.FiltersForAction(mafilter.ActionDeny)
for _, f := range fs {
swrm.Filters.Remove(f)
swrm.Filters.RemoveLiteral(f)
}

removed, err := filtersRemoveAll(r, cfg)
Expand All @@ -730,12 +731,12 @@ remove your filters from the ipfs config file.
}

for _, arg := range req.Arguments {
mask, err := mafilter.NewMask(arg)
mask, err := mamask.NewMask(arg)
if err != nil {
return err
}

swrm.Filters.Remove(mask)
swrm.Filters.RemoveLiteral(*mask)
}

removed, err := filtersRemove(r, cfg, req.Arguments)
Expand Down
2 changes: 1 addition & 1 deletion core/node/libp2p/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func makeAddrsFactory(announce []string, noAnnounce []string) (p2pbhost.AddrsFac
for _, addr := range noAnnounce {
f, err := mamask.NewMask(addr)
if err == nil {
filters.AddDialFilter(f)
filters.AddFilter(*f, mafilter.ActionDeny)
continue
}
maddr, err := ma.NewMultiaddr(addr)
Expand Down
12 changes: 6 additions & 6 deletions namesys/resolve/pathresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ func TestResolveNoComponents(t *testing.T) {
}

_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipns/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipns/).", err)
if err.Error() != "invalid path \"/ipns/\": ipns path missing IPNS ID" {
t.Error("Should error with no components (/ipns/).", err)
}

_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/ipfs/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipfs/).", err)
if err.Error() != "invalid path \"/ipfs/\": not enough path components" {
t.Error("Should error with no components (/ipfs/).", err)
}

_, err = resolve.Resolve(n.Context(), n.Namesys, n.Resolver, path.Path("/../.."))
if err != path.ErrBadPath {
t.Fatal("Should error with invalid path.", err)
if err.Error() != "invalid path \"/../..\": unknown namespace \"..\"" {
t.Error("Should error with invalid path.", err)
}
}
2 changes: 1 addition & 1 deletion plugin/plugins/gen_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
$shortpkg "$pkg"
)
var Plugins = $shortpkg.Plugins
var Plugins = $shortpkg.Plugins //nolint
func main() {
panic("this is a plugin, build it as a plugin, this is here as for go#20312")
Expand Down

0 comments on commit 480780e

Please sign in to comment.