-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
apply the megacheck code vetting tool for idiomatic go #3949
Conversation
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
the failure on codeclimate is a false positive (calling |
cmd/ipfs/main.go
Outdated
errApiVersionMismatch = errors.New("api version mismatch") | ||
errRequestCanceled = errors.New("request canceled") | ||
// errUnexpectedApiOutput = errors.New("api returned unexpected output") | ||
// errApiVersionMismatch = errors.New("api version mismatch") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if its actually not being used, should probably just remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roger.
@@ -99,7 +100,7 @@ func run(ipfsPath, watchPath string) error { | |||
} | |||
|
|||
interrupts := make(chan os.Signal) | |||
signal.Notify(interrupts, os.Interrupt, os.Kill) | |||
signal.Notify(interrupts, os.Interrupt, syscall.SIGTERM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is os.Kill
deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error message is: os.Kill cannot be trapped (did you mean syscall.SIGTERM?) (SA1016)
where SA1016 -> Trapping a signal that cannot be trapped
@@ -45,7 +45,7 @@ func TestClientFindProviders(t *testing.T) { | |||
providersFromClient := client.FindProvidersAsync(context.Background(), k, max) | |||
isInClient := false | |||
for pi := range providersFromClient { | |||
if pi.ID == pi.ID { | |||
if pi.ID == pi.ID { // <-- typo? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is so old and unused... We can probably just remove routing/mock and the supernode routing stuff in general (as a separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks!
Could you go ahead and just delete the things you commented out in a separate commit (so i don't have to re-read the entire diff again)
|
sounds good, will address. What value is the codeclimate integration providing over and above implementing this TODO ? IMO the integration should be dropped in favour of implementing that as part of |
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
Rules.mk
Outdated
@go get honnef.co/go/tools/cmd/megacheck | ||
@for pkg in ${PACKAGES_NOVENDOR}; do megacheck "$$pkg"; done | ||
|
||
.PHONY: megacheck |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this target to mk/golang.mk
instead and add comment about it to help print section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
unixfs/hamt/hamt_stress_test.go
Outdated
@@ -189,104 +186,3 @@ func genOpSet(seed int64, keep, temp []string) []testOp { | |||
} | |||
} | |||
} | |||
|
|||
// executes the given op set with a repl to allow easier debugging | |||
func debugExecuteOpSet(ds dag.DAGService, width int, ops []testOp) (*HamtShard, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be removed. It could be useful hot-plug debugging tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reinstated it but commented it out
because context.TODO() is a legit function License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
circle will probably pass after re-triggered. I've notice some non-determinism with the tests (e.g., jenkins failed randomly on a commit where the only change was to |
Test are deterministic just build machines of free service providers sometimes hang on our network tests. |
core/commands/files/files.go
Outdated
@@ -664,11 +664,6 @@ stat' on the file or any of its ancestors. | |||
return | |||
} | |||
|
|||
var r io.Reader = input | |||
if countfound { | |||
r = io.LimitReader(r, int64(count)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm... Maybe you discovered a bug here. I think the copy below was supposed to be from 'r' instead of 'input'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. The tests are happy with the fix.
License: MIT Signed-off-by: Zach Ramsay <zach.ramsay@gmail.com>
@zramsay Thanks a bunch! This is really useful :) If there are more, feel free to file more PRs |
no problem! There a couple dozen ~more complex fixes that I'll tackle as part of #3953 |
megacheck
applies each of theunused
,gosimple
, andstaticcheck
tools to the code base in order to enforce idiomatic golang. See here for more information.Main Changes
if err != nil { return err }; return nil
was simplified toreturn err
if pin == false
is the same asif !pin
os.SEEK_*
withio.Seek*
make()
was dropped if set to the same as its length.time.Now().Sub
withtime.Since()
append(a, b...)
, were