Skip to content

Commit 800dd06

Browse files
committed
Lint source code
1 parent 02a1dcc commit 800dd06

File tree

5 files changed

+47
-20
lines changed

5 files changed

+47
-20
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ benchmark: ## Execute package benchmarks
5858

5959
deps: ## Install build dependencies
6060
go get -u
61+
go mod tidy -v
6162
go mod download
6263
go mod verify
6364

@@ -72,6 +73,12 @@ clean: ## Delete generated development environment
7273
rm -rf ${BINARY}-*-*.zip
7374
rm -rf coverage-all.out
7475

76+
# Lint
77+
78+
.PHONY: lint
79+
lint: ## Lint source code
80+
./lint.bash
81+
7582
# Docs
7683

7784
godoc-serve: ## Serve documentation (godoc format) for this package at port HTTP 9090

dag.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (d *DAG) DeleteVertex(vertex *Vertex) error {
6363
existsVertex = true
6464
}
6565
}
66-
if existsVertex == false {
66+
if !existsVertex {
6767
return fmt.Errorf("Vertex with ID %v not found", vertex.ID)
6868
}
6969

@@ -89,10 +89,10 @@ func (d *DAG) AddEdge(tailVertex *Vertex, headVertex *Vertex) error {
8989
headExists = true
9090
}
9191
}
92-
if tailExists == false {
92+
if !tailExists {
9393
return fmt.Errorf("Vertex with ID %v not found", tailVertex.ID)
9494
}
95-
if headExists == false {
95+
if !headExists {
9696
return fmt.Errorf("Vertex with ID %v not found", headVertex.ID)
9797
}
9898

@@ -170,7 +170,7 @@ func (d *DAG) Successors(vertex *Vertex) ([]*Vertex, error) {
170170
var successors []*Vertex
171171

172172
_, found := d.Vertices.Get(vertex.ID)
173-
if found != true {
173+
if !found {
174174
return successors, fmt.Errorf("vertex %s not found in the graph", vertex.ID)
175175
}
176176

@@ -186,7 +186,7 @@ func (d *DAG) Predecessors(vertex *Vertex) ([]*Vertex, error) {
186186
var predecessors []*Vertex
187187

188188
_, found := d.Vertices.Get(vertex.ID)
189-
if found != true {
189+
if !found {
190190
return predecessors, fmt.Errorf("vertex %s not found in the graph", vertex.ID)
191191
}
192192

@@ -200,13 +200,11 @@ func (d *DAG) Predecessors(vertex *Vertex) ([]*Vertex, error) {
200200
// String implements stringer interface and prints an string representation
201201
// of this instance.
202202
func (d *DAG) String() string {
203-
var result string
204-
result = fmt.Sprintf("DAG Vertices: %d - Edges: %d\n", d.Order(), d.Size())
205-
result = result + fmt.Sprintf("Vertices:\n")
203+
result := fmt.Sprintf("DAG Vertices: %d - Edges: %d\n", d.Order(), d.Size())
204+
result += fmt.Sprintf("Vertices:\n")
206205
for _, vertex := range d.Vertices.Values() {
207206
vertex = vertex.(*Vertex)
208-
209-
result = result + fmt.Sprintf("%s", vertex)
207+
result += fmt.Sprintf("%s", vertex)
210208
}
211209

212210
return result

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/goombaio/dag
22

33
require (
4-
github.com/goombaio/orderedmap v0.0.0-20180913224324-4f3ec14b67ee
5-
github.com/goombaio/orderedset v0.0.0-20180913224306-7932f51baeff
4+
github.com/goombaio/orderedmap v0.0.0-20180914055104-17aec6e5c534
5+
github.com/goombaio/orderedset v0.0.0-20180914055012-52cd141747e3
66
)

go.sum

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
github.com/goombaio/orderedmap v0.0.0-20180909122926-bcb33a330965 h1:B5j5Xc220Wek927iQU58XPVBgqffiDYJ/WbCT+xSniI=
2-
github.com/goombaio/orderedmap v0.0.0-20180909122926-bcb33a330965/go.mod h1:YKu81H3RSd1cFh0d7NhvUoTtUC9IY/vBX0WUQb1/o4Y=
31
github.com/goombaio/orderedmap v0.0.0-20180909154953-8a7ec76cbbe3/go.mod h1:YKu81H3RSd1cFh0d7NhvUoTtUC9IY/vBX0WUQb1/o4Y=
4-
github.com/goombaio/orderedmap v0.0.0-20180913224324-4f3ec14b67ee h1:kJuaDxXc3p+b8zwdo6DWLx7Rb68+6nsJ1B1kQsng9oc=
5-
github.com/goombaio/orderedmap v0.0.0-20180913224324-4f3ec14b67ee/go.mod h1:YKu81H3RSd1cFh0d7NhvUoTtUC9IY/vBX0WUQb1/o4Y=
6-
github.com/goombaio/orderedset v0.0.0-20180909125127-122dc7308614 h1:xAdni1zGwgnswG1Ffz3aLRSGVgK36cwHGxmhDtZg9vU=
7-
github.com/goombaio/orderedset v0.0.0-20180909125127-122dc7308614/go.mod h1:W4Pn44eHLAcM1jflSDi6Uef2+y9spkuhg7OnM1xjB0A=
8-
github.com/goombaio/orderedset v0.0.0-20180913224306-7932f51baeff h1:2WMDnw2xDxCvQaxt44zr9WknHoPjO9U5L3oB/AYm7x4=
9-
github.com/goombaio/orderedset v0.0.0-20180913224306-7932f51baeff/go.mod h1:R1TTMcaEzt9BEIx7zMybVI+SYaxlsOcbUKtxBKcus10=
2+
github.com/goombaio/orderedmap v0.0.0-20180914055104-17aec6e5c534 h1:900x/Rd8UHHF2J1Ca2tIspnjiqSCa4kCKIkRM502Vc4=
3+
github.com/goombaio/orderedmap v0.0.0-20180914055104-17aec6e5c534/go.mod h1:YKu81H3RSd1cFh0d7NhvUoTtUC9IY/vBX0WUQb1/o4Y=
4+
github.com/goombaio/orderedset v0.0.0-20180914055012-52cd141747e3 h1:yQVltnuJPTyUTQ6wYYN0SmMDLvds76oVQZu1KRYFMu4=
5+
github.com/goombaio/orderedset v0.0.0-20180914055012-52cd141747e3/go.mod h1:R1TTMcaEzt9BEIx7zMybVI+SYaxlsOcbUKtxBKcus10=

lint.bash

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
if [ ! $(command -v gometalinter) ]
8+
then
9+
go get github.com/alecthomas/gometalinter
10+
gometalinter --update --install
11+
fi
12+
13+
time gometalinter \
14+
--exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \
15+
--exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
16+
--exclude='/thrift/' \
17+
--exclude='/pb/' \
18+
--exclude='no args in Log call \(vet\)' \
19+
--disable=dupl \
20+
--disable=aligncheck \
21+
--disable=gotype \
22+
--cyclo-over=20 \
23+
--tests \
24+
--concurrency=2 \
25+
--deadline=300s \
26+
./...

0 commit comments

Comments
 (0)