Skip to content

Commit ab71f42

Browse files
authored
all: run staticcheck (#41)
* all: run staticcheck * ci: fix install step
1 parent f29bce1 commit ab71f42

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
sudo: false
22
language: go
33
go:
4-
- 1.4.x
5-
- 1.5.x
6-
- 1.6.x
74
- 1.7.x
85
- 1.8.x
96
- 1.9.x
@@ -12,6 +9,7 @@ go:
129
- 1.12.x
1310
- 1.13.x
1411

12+
install: go get -v ./...
1513
script:
1614
- go get golang.org/x/tools/cmd/cover
1715
- go get github.com/smartystreets/goconvey

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: vet test bench coverage
2+
3+
vet:
4+
go vet
5+
6+
test:
7+
go test -v -cover -race
8+
9+
bench:
10+
go test -v -cover -race -test.bench=. -test.benchmem
11+
12+
coverage:
13+
go test -coverprofile=c.out && go tool cover -html=c.out && rm c.out

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Package git-module is a Go module for Git access through shell commands.
66

77
## Limitations
88

9-
- Go version must be at least **1.4**.
9+
- Go version must be at least **1.7**.
1010
- Git version must be no less than **1.8.3**.
1111
- For Windows users, try use as new a version as possible.
1212

commit.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (c *Commit) ParentCount() int {
6767

6868
func isImageFile(data []byte) (string, bool) {
6969
contentType := http.DetectContentType(data)
70-
if strings.Index(contentType, "image/") != -1 {
70+
if strings.Contains(contentType, "image/") {
7171
return contentType, true
7272
}
7373
return contentType, false
@@ -137,8 +137,7 @@ func CommitChanges(repoPath string, opts CommitChangesOptions) error {
137137
}
138138

139139
func commitsCount(repoPath, revision, relpath string) (int64, error) {
140-
var cmd *Command
141-
cmd = NewCommand("rev-list", "--count").AddArguments(revision)
140+
cmd := NewCommand("rev-list", "--count").AddArguments(revision)
142141
if len(relpath) > 0 {
143142
cmd.AddArguments("--", relpath)
144143
}

repo.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ func IsRepoURLAccessible(opts NetworkOptions) bool {
5757
opts.Timeout = -1
5858
}
5959
_, err := cmd.RunTimeout(opts.Timeout)
60-
if err != nil {
61-
return false
62-
}
63-
return true
60+
return err == nil
6461
}
6562

6663
// InitRepository initializes a new Git repository.

sha1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func MustID(b []byte) sha1 {
6767
// NewID creates a new sha1 from a [20]byte array.
6868
func NewID(b []byte) (sha1, error) {
6969
if len(b) != 20 {
70-
return sha1{}, fmt.Errorf("Length must be 20: %v", b)
70+
return sha1{}, fmt.Errorf("length must be 20: %v", b)
7171
}
7272
return MustID(b), nil
7373
}
@@ -83,7 +83,7 @@ func NewIDFromString(s string) (sha1, error) {
8383
var id sha1
8484
s = strings.TrimSpace(s)
8585
if len(s) != 40 {
86-
return id, fmt.Errorf("Length must be 40: %s", s)
86+
return id, fmt.Errorf("length must be 40: %s", s)
8787
}
8888
b, err := hex.DecodeString(s)
8989
if err != nil {

tree.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ var (
3939

4040
// UnescapeChars reverses escaped characters.
4141
func UnescapeChars(in []byte) []byte {
42-
// LEGACY [Go 1.7]: use more expressive bytes.ContainsAny
43-
if bytes.IndexAny(in, "\\\t") == -1 {
42+
if bytes.ContainsAny(in, "\\\t") {
4443
return in
4544
}
4645

tree_entry.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ type TreeEntry struct {
3535

3636
ptree *Tree
3737

38-
commited bool
39-
4038
size int64
4139
sized bool
4240
}

0 commit comments

Comments
 (0)