Skip to content

Commit 101a1f4

Browse files
author
Isaac Hier
committedDec 6, 2018
Use ALL_SRC for golint and otherwise clean up code
Signed-off-by: Isaac Hier <ihier@uber.com>
1 parent f023a98 commit 101a1f4

File tree

4 files changed

+24
-48
lines changed

4 files changed

+24
-48
lines changed
 

‎Makefile

+20-47
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
11
PROJECT_ROOT=github.com/jaegertracing/jaeger
2-
# TOP_PKGS is used with 'go test'
3-
TOP_PKGS := $(shell go list ./... | \
4-
sed -E "s|${PROJECT_ROOT}/([^/]+)(/.*)?$$|./\1/...|g" | \
5-
sort | \
6-
uniq | \
7-
grep -v \
8-
-e github.com/jaegertracing/jaeger \
9-
-e ./thrift-gen \
10-
-e ./swagger-gen \
11-
-e ./proto-gen \
12-
-e ./examples \
13-
-e ./scripts \
14-
)
15-
162
STORAGE_PKGS = ./plugin/storage/integration/...
173

184
# all .go files that are not auto-generated and should be auto-formatted and linted.
19-
ALL_SRC := $(shell find . -name "*.go" | \
20-
grep -v \
21-
-e vendor \
22-
-e /thrift-gen/ \
23-
-e /swagger-gen/ \
24-
-e /proto-gen/ \
25-
-e /examples/ \
26-
-e doc.go \
27-
-e model.pb.go \
28-
-e model_test.pb.go \
29-
-e ".*/\..*" \
30-
-e ".*/_.*" \
31-
-e ".*/mocks.*" \
32-
)
5+
ALL_SRC := $(shell find . -name '*.go' \
6+
-not -name 'doc.go' \
7+
-not -name '_*' \
8+
-not -name '.*' \
9+
-not -name 'mocks*' \
10+
-not -name '*_test.go' \
11+
-not -name 'model.pb.go' \
12+
-not -name 'model_test.pb.go' \
13+
-not -path './examples/*' \
14+
-not -path './vendor/*' \
15+
-not -path '*/mocks/*' \
16+
-not -path '*/*-gen/*' \
17+
-type f | \
18+
sort)
3319

3420
# ALL_PKGS is used with 'go cover'
3521
ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))
@@ -95,7 +81,7 @@ clean:
9581

9682
.PHONY: test
9783
test: go-gen
98-
bash -c "set -e; set -o pipefail; $(GOTEST) $(TOP_PKGS) | $(COLORIZE)"
84+
bash -c "set -e; set -o pipefail; $(GOTEST) ./... | $(COLORIZE)"
9985

10086
.PHONY: integration-test
10187
integration-test: go-gen
@@ -115,7 +101,7 @@ all-srcs:
115101
cover: nocover
116102
@echo pre-compiling tests
117103
@time go test -i $(ALL_PKGS)
118-
@./scripts/cover.sh $(shell go list $(TOP_PKGS))
104+
@./scripts/cover.sh $(shell go list ./...)
119105
grep -E -v 'model.pb.*.go' cover.out > cover-nogen.out
120106
mv cover-nogen.out cover.out
121107
go tool cover -html=cover.out -o cover.html
@@ -133,33 +119,20 @@ fmt:
133119

134120
.PHONY: lint-gosec
135121
lint-gosec:
136-
$(GOSEC) $(TOP_PKGS)
122+
$(GOSEC) ./...
137123

138124
.PHONY: lint
139125
lint: lint-gosec
140-
$(GOVET) $(TOP_PKGS)
141-
$(GOSIMPLE) $(TOP_PKGS)
126+
$(GOVET) ./...
127+
$(GOSIMPLE) ./...
142128
@cat /dev/null > $(LINT_LOG)
143-
$(GOLINT) $(TOP_PKGS) | \
144-
grep -v \
145-
-e pkg/es/wrapper.go \
146-
-e /mocks/ \
147-
-e thrift-gen \
148-
-e thrift-0.9.2 \
149-
-e model.pb.go \
150-
-e model_test.pb.go \
151-
>> $(LINT_LOG) \
152-
|| true;
129+
$(GOLINT) $(ALL_SRC) >> $(LINT_LOG) || true;
153130
@[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
154131
@$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
155132
@./scripts/updateLicenses.sh >> $(FMT_LOG)
156133
@./scripts/import-order-cleanup.sh stdout > $(IMPORT_LOG)
157134
@[ ! -s "$(FMT_LOG)" -a ! -s "$(IMPORT_LOG)" ] || (echo "Go fmt, license check, or import ordering failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
158135

159-
.PHONY: install-glide
160-
install-glide:
161-
@echo "Jaeger has migrated to dep, please run 'make install-dep'" 1>&2
162-
163136
.PHONY: install-dep
164137
install-dep:
165138
@which dep > /dev/null || curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh

‎examples/hotrod/pkg/log/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func NewFactory(logger *zap.Logger) Factory {
3535

3636
// Bg creates a context-unaware logger.
3737
func (b Factory) Bg() Logger {
38-
return logger{logger: b.logger}
38+
return logger(b)
3939
}
4040

4141
// For returns a context-aware Logger. If the context

‎examples/hotrod/services/customer/database.go

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (d *database) Get(ctx context.Context, customerID string) (*Customer, error
7676
span := d.tracer.StartSpan("SQL SELECT", opentracing.ChildOf(span.Context()))
7777
tags.SpanKindRPCClient.Set(span)
7878
tags.PeerService.Set(span, "mysql")
79+
// #nosec
7980
span.SetTag("sql.query", "SELECT * FROM customer WHERE customer_id="+customerID)
8081
defer span.Finish()
8182
ctx = opentracing.ContextWithSpan(ctx, span)

‎examples/hotrod/services/driver/redis.go

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func (r *Redis) FindDriverIDs(ctx context.Context, location string) []string {
6060

6161
drivers := make([]string, 10)
6262
for i := range drivers {
63+
// #nosec
6364
drivers[i] = fmt.Sprintf("T7%05dC", rand.Int()%100000)
6465
}
6566
r.logger.For(ctx).Info("Found drivers", zap.Strings("drivers", drivers))
@@ -85,6 +86,7 @@ func (r *Redis) GetDriver(ctx context.Context, driverID string) (Driver, error)
8586
return Driver{}, err
8687
}
8788

89+
// #nosec
8890
return Driver{
8991
DriverID: driverID,
9092
Location: fmt.Sprintf("%d,%d", rand.Int()%1000, rand.Int()%1000),

0 commit comments

Comments
 (0)
Please sign in to comment.