From 08a1f19aa74693bdeb0c21749ab4f97f77e04533 Mon Sep 17 00:00:00 2001 From: Jack Lindamood Date: Tue, 26 Jun 2018 11:05:54 -0700 Subject: [PATCH] Upgrade lints to go 1.10 Resolves #42 --- .gometalinter.json | 35 ++++++++++++++++++++++++++ .travis.yml | 5 ++-- Makefile | 9 ++++--- benchmarking/doc.go | 3 +++ closers/hystrix/example_test.go | 2 +- example/main.go | 1 + example_test.go | 2 +- metriceventstream/metriceventstream.go | 1 + 8 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .gometalinter.json create mode 100644 benchmarking/doc.go diff --git a/.gometalinter.json b/.gometalinter.json new file mode 100644 index 0000000..28afb1d --- /dev/null +++ b/.gometalinter.json @@ -0,0 +1,35 @@ +{ + "Vendor": true, + "MinConfidence": 0.3, + "DuplThreshold": 100, + "Deadline": "5m", + "LineLength": 150, + "Enable": [ + "deadcode", + "dupl", + "errcheck", + "gas", + "goconst", + "gocyclo", + "goimports", + "gofmt", + "golint", + "gotype", + "gotypex", + "ineffassign", + "interfacer", + "lll", + "maligned", + "megacheck", + "misspell", + "nakedret", + "safesql", + "structcheck", + "testify", + "unconvert", + "unparam", + "varcheck", + "vet", + "vetshadow" + ] +} diff --git a/.travis.yml b/.travis.yml index 163e2a8..d67ae46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,12 @@ language: go sudo: false env: - - DEP_VERSION="0.3.2" + - DEP_VERSION="0.4.1" # Version 1.8 messes up the lint checks for travis go: - - 1.9 + - "1.10" cache: directories: @@ -18,5 +18,6 @@ install: - make setup_ci redep script: + - make build - make test - make lint diff --git a/Makefile b/Makefile index 84d3b45..15aa6f2 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ PROFILE_RUN ?= BenchmarkCiruits/Hystrix/Minimal/failing/75 BENCH_RUN ?= . + +build: + go build ./... + # Run unit tests test: env "GORACE=halt_on_error=1" go test -v -race ./... -build: - go build -t ./... - # Format the code fix: find . -iname '*.go' -not -path '*/vendor/*' -print0 | xargs -0 gofmt -s -w @@ -36,7 +37,7 @@ profile_blocking: # Lint the code lint: - gometalinter --vendor --deadline=5m --enable-all -D lll --dupl-threshold=100 ./... + gometalinter ./... # Run the example run: diff --git a/benchmarking/doc.go b/benchmarking/doc.go new file mode 100644 index 0000000..24c2a9e --- /dev/null +++ b/benchmarking/doc.go @@ -0,0 +1,3 @@ +// Package benchmarking does not contain used code. Instead, it contains only the +// files required to run benchmarking against other circuits +package benchmarking diff --git a/closers/hystrix/example_test.go b/closers/hystrix/example_test.go index 3497d0b..5eed485 100644 --- a/closers/hystrix/example_test.go +++ b/closers/hystrix/example_test.go @@ -19,7 +19,7 @@ func ExampleFactory() { }, // Hystrix close logic is to sleep then check ConfigureCloser: hystrix.ConfigureCloser{ - // The default values match what hystrix does by default + // The default values match what hystrix does by default }, } h := circuit.Manager{ diff --git a/example/main.go b/example/main.go index 87fac3a..e0ee8c3 100644 --- a/example/main.go +++ b/example/main.go @@ -23,6 +23,7 @@ import ( "github.com/cep21/circuit/metrics/rolling" ) +// nolint:lll const exampleURL = "http://localhost:7979/hystrix-dashboard/monitor/monitor.html?streams=%5B%7B%22name%22%3A%22%22%2C%22stream%22%3A%22http%3A%2F%2Flocalhost%3A8123%2Fhystrix.stream%22%2C%22auth%22%3A%22%22%2C%22delay%22%3A%22%22%7D%5D" func main() { diff --git a/example_test.go b/example_test.go index 2b4b257..1ca19ce 100644 --- a/example_test.go +++ b/example_test.go @@ -286,7 +286,7 @@ func ExampleConfig_custommetrics() { config := circuit.Config{ Metrics: circuit.MetricsCollectors{ Run: []circuit.RunMetrics{ - // Here is where I would insert my custom metric collector + // Here is where I would insert my custom metric collector }, }, } diff --git a/metriceventstream/metriceventstream.go b/metriceventstream/metriceventstream.go index b454de9..5adc628 100644 --- a/metriceventstream/metriceventstream.go +++ b/metriceventstream/metriceventstream.go @@ -192,6 +192,7 @@ func collectCommandMetrics(cb *circuit.Circuit) *streamCmdMetric { RollingCountTimeout: builtInRollingCmdMetricCollector.ErrTimeouts.RollingSumAt(now), // Note: There is no errInterrupt field inside the dashboard, but i still want to expose these metrics there, // so I just roll them into BadRequests + // nolint: lll RollingCountBadRequests: builtInRollingCmdMetricCollector.ErrBadRequests.RollingSumAt(now) + builtInRollingCmdMetricCollector.ErrInterrupts.RollingSumAt(now), TotalCountFallbackSuccess: builtInRollingFallbackMetricCollector.Successes.TotalSum(),