Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

fix go vet issues, add go vet to CI #360

Merged
merged 4 commits into from
Apr 26, 2017
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ script:
- export PATH=$GIT_DIST_PATH:$PATH
- git version
- make test-coverage
- go vet ./...

after_success:
- bash <(curl -s https://codecov.io/bash)
4 changes: 2 additions & 2 deletions plumbing/format/packfile/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ func (d *Decoder) DecodeObjectAt(offset int64) (plumbing.EncodedObject, error) {
return nil, ErrNonSeekable
}

beforeJump, err := d.s.Seek(offset)
beforeJump, err := d.s.SeekFromStart(offset)
if err != nil {
return nil, err
}

defer func() {
_, seekErr := d.s.Seek(beforeJump)
_, seekErr := d.s.SeekFromStart(beforeJump)
if err == nil {
err = seekErr
}
Expand Down
5 changes: 3 additions & 2 deletions plumbing/format/packfile/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,9 @@ func (s *Scanner) copyObject(w io.Writer) (int64, error) {
return io.Copy(w, s.zr)
}

// Seek sets a new offset from start, returns the old position before the change
func (s *Scanner) Seek(offset int64) (previous int64, err error) {
// SeekFromStart sets a new offset from start, returns the old position before
// the change.
func (s *Scanner) SeekFromStart(offset int64) (previous int64, err error) {
// if seeking we assume that you are not interested on the header
if s.version == 0 {
s.version = VersionSupported
Expand Down
5 changes: 3 additions & 2 deletions plumbing/format/packfile/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"bytes"
"io"

. "gopkg.in/check.v1"
"github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing"

"github.com/src-d/go-git-fixtures"
. "gopkg.in/check.v1"
)

type ScannerSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion plumbing/format/pktline/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func ExampleScanner() {
for s.Scan() {
payload := s.Bytes()
if len(payload) == 0 { // zero sized payloads correspond to flush-pkts.
fmt.Println("FLUSH-PKT DETECTED\n")
fmt.Println("FLUSH-PKT DETECTED")
} else { // otherwise, you will be able to access the full payload.
fmt.Printf("PAYLOAD = %q\n", string(payload))
}
Expand Down
9 changes: 5 additions & 4 deletions plumbing/object/change_adaptor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package object

import (
"errors"
"fmt"

"gopkg.in/src-d/go-git.v4/utils/merkletrie"
Expand All @@ -15,11 +16,11 @@ func newChange(c merkletrie.Change) (*Change, error) {

var err error
if ret.From, err = newChangeEntry(c.From); err != nil {
return nil, fmt.Errorf("From field: ", err)
return nil, fmt.Errorf("From field: %s", err)
}

if ret.To, err = newChangeEntry(c.To); err != nil {
return nil, fmt.Errorf("To field: ", err)
return nil, fmt.Errorf("To field: %s", err)
}

return ret, nil
Expand All @@ -32,7 +33,7 @@ func newChangeEntry(p noder.Path) (ChangeEntry, error) {

asTreeNoder, ok := p.Last().(*treeNoder)
if !ok {
return ChangeEntry{}, fmt.Errorf("cannot transform non-TreeNoders")
return ChangeEntry{}, errors.New("cannot transform non-TreeNoders")
}

return ChangeEntry{
Expand All @@ -52,7 +53,7 @@ func newChanges(src merkletrie.Changes) (Changes, error) {
for i, e := range src {
ret[i], err = newChange(e)
if err != nil {
return nil, fmt.Errorf("change #%d: %s", err)
return nil, fmt.Errorf("change #%d: %s", i, err)
}
}

Expand Down
5 changes: 1 addition & 4 deletions plumbing/object/change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ func (s *ChangeSuite) TestNoFileFilemodes(c *C) {
c.Assert(err, IsNil)
for _, change := range changes {
_, _, err := change.Files()
if err != nil {
panic(err)
c.Assert(err, IsNil)
}
c.Assert(err, IsNil)
}

prev = commit
Expand Down
2 changes: 1 addition & 1 deletion remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *Remote) String() string {
fetch := r.c.URL
push := r.c.URL

return fmt.Sprintf("%s\t%s (fetch)\n%[1]s\t%s (push)", r.c.Name, fetch, push)
return fmt.Sprintf("%s\t%s (fetch)\n%[1]s\t%[3]s (push)", r.c.Name, fetch, push)
}

// Fetch fetches references from the remote to the local repository.
Expand Down
2 changes: 1 addition & 1 deletion utils/merkletrie/difftree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func newChanges(original merkletrie.Changes) (changes, error) {
path: c.From.String(),
}
default:
panic(fmt.Sprintf("unsupported action %d", c.Action))
panic(fmt.Sprintf("unsupported action %d", action))
}
}

Expand Down
2 changes: 1 addition & 1 deletion utils/merkletrie/internal/fsnoder/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func decodeDir(data []byte, isRoot bool) (*dir, error) {
var name string
switch end := bytes.IndexRune(data, dirStartMark); end {
case -1:
return nil, fmt.Errorf("%c not found")
return nil, fmt.Errorf("%c not found", dirStartMark)
case 0:
if isRoot {
name = ""
Expand Down
6 changes: 3 additions & 3 deletions utils/merkletrie/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (t test) run(c *C, iter *merkletrie.Iter,

var obtained noder.Path
var err error
for i := range t.operations {
for i, b := range t.operations {
comment := Commentf("\ntree: %q\ntest #%d (%q)\noperation #%d (%q)",
treeDescription, testNumber, t.operations, i, t.operations[i])

Expand All @@ -81,8 +81,8 @@ func (t test) run(c *C, iter *merkletrie.Iter,
c.Assert(err, IsNil)
}
default:
c.Fatalf("unknown operation at test %d, operation %d (%s)\n",
testNumber, i, t.operations[i])
c.Fatalf("unknown operation at test %d, operation %d (%c)\n",
testNumber, i, b)
}
if i >= len(expectedChunks) {
c.Assert(err, Equals, io.EOF, comment)
Expand Down