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

ci: actually enable golangci-lint #6362

Merged
merged 2 commits into from
May 21, 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
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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving away from deprecated APIs.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't lint because this is "unused".


func main() {
panic("this is a plugin, build it as a plugin, this is here as for go#20312")
Expand Down