Repository: beatlabs/patron
Pull request #312 (2020-12-11 07:03:10)

Fix Linting Issues
<!--
Thanks for taking precious time for making a PR.

Before creating a pull request, please make sure:
- Your PR solves one problem for which a issue exist and a solution has been discussed
- You have read the guide for contributing
  - See https://github.com/beatlabs/patron/blob/master/README.md#how-to-contribute
- You signed all your commits (otherwise we won't be able to merge the PR)
  - See https://github.com/beatlabs/patron/blob/master/SIGNYOURWORK.md
- You added unit tests for the new functionality
- You mention in the PR description which issue it is addressing, e.g. "Resolves #123"
-->

## Which problem is this PR solving?

<!-- REQUIRED -->

## Short description of the changes

<!-- REQUIRED -->


codecov[bot]: # [Codecov](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=h1) Report
> Merging [#312](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=desc) (b0bbe44) into [master](https://codecov.io/gh/beatlabs/patron/commit/eb9d5b4c0362bc70cdbef5aff6b75112a0e0e624?el=desc) (eb9d5b4) will **decrease** coverage by `0.06%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/beatlabs/patron/pull/312/graphs/tree.svg?width=650&height=150&src=pr&token=sxY15rXW1X)](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #312      +/-   ##
==========================================
- Coverage   72.68%   72.62%   -0.07%     
==========================================
  Files          61       61              
  Lines        3332     3332              
==========================================
- Hits         2422     2420       -2     
- Misses        817      819       +2     
  Partials       93       93              
```


| [Impacted Files](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [component/async/sqs/sqs.go](https://codecov.io/gh/beatlabs/patron/pull/312/diff?src=pr&el=tree#diff-Y29tcG9uZW50L2FzeW5jL3Nxcy9zcXMuZ28=) | `77.83% <0.00%> (-1.04%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=footer). Last update [eb9d5b4...2925e09](https://codecov.io/gh/beatlabs/patron/pull/312?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/client/kafka/builder.go b/client/kafka/builder.go
index bbce59b33..6c6a6cb56 100644
--- a/client/kafka/builder.go
+++ b/client/kafka/builder.go
@@ -47,7 +47,7 @@ func NewBuilder(brokers []string) *Builder {
 	cfg := sarama.NewConfig()
 	cfg.Version = sarama.V0_11_0_0
 
-	errs := []error{}
+	var errs []error
 	if validation.IsStringSliceEmpty(brokers) {
 		errs = append(errs, errors.New("brokers are empty or have an empty value"))
 	}
diff --git a/client/redis/redis.go b/client/redis/redis.go
index 5fe980a50..67a5c9672 100644
--- a/client/redis/redis.go
+++ b/client/redis/redis.go
@@ -12,10 +12,8 @@ import (
 )
 
 const (
-	// RedisComponent definition
-	RedisComponent = "redis"
-	// RedisDBType description
-	RedisDBType = "In-memory"
+	component = "redis"
+	dbType    = "In-memory"
 )
 
 // Options wraps redis.Options for easier usage.
@@ -31,8 +29,8 @@ type Client struct {
 
 func (c *Client) startSpan(ctx context.Context, opName, stmt string, tags ...opentracing.Tag) (opentracing.Span, context.Context) {
 	sp, ctx := opentracing.StartSpanFromContext(ctx, opName)
-	ext.Component.Set(sp, RedisComponent)
-	ext.DBType.Set(sp, RedisDBType)
+	ext.Component.Set(sp, component)
+	ext.DBType.Set(sp, dbType)
 	ext.DBInstance.Set(sp, c.Options().Addr)
 	ext.DBStatement.Set(sp, stmt)
 	for _, t := range tags {
@@ -56,7 +54,7 @@ func (c *Client) Do(ctx context.Context, args ...interface{}) *redis.Cmd {
 }
 
 // Close closes the connection to the underlying Redis client.
-func (c *Client) Close(ctx context.Context, args ...interface{}) error {
+func (c *Client) Close(ctx context.Context, _ ...interface{}) error {
 	sp, _ := c.startSpan(ctx, "redis.Close", "")
 	err := c.Client.Close()
 	trace.SpanComplete(sp, err)
diff --git a/component/grpc/observability.go b/component/grpc/observability.go
index 531575f3d..c5a635dc1 100644
--- a/component/grpc/observability.go
+++ b/component/grpc/observability.go
@@ -106,13 +106,13 @@ func (o *observer) log(err error) {
 }
 
 func (o *observer) messageHandled(err error) {
-	status, _ := status.FromError(err)
-	rpcHandledMetric.WithLabelValues(o.typ, o.service, o.method, status.Code().String()).Inc()
+	st, _ := status.FromError(err)
+	rpcHandledMetric.WithLabelValues(o.typ, o.service, o.method, st.Code().String()).Inc()
 }
 
 func (o *observer) messageLatency(dur time.Duration, err error) {
-	status, _ := status.FromError(err)
-	rpcLatencyMetric.WithLabelValues(o.typ, o.service, o.method, status.Code().String()).Observe(dur.Seconds())
+	st, _ := status.FromError(err)
+	rpcLatencyMetric.WithLabelValues(o.typ, o.service, o.method, st.Code().String()).Observe(dur.Seconds())
 }
 
 func observableUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
diff --git a/component/http/handler.go b/component/http/handler.go
index fcffe67f9..c99827f95 100644
--- a/component/http/handler.go
+++ b/component/http/handler.go
@@ -14,9 +14,7 @@ import (
 )
 
 func handler(hnd ProcessorFunc) http.HandlerFunc {
-
 	return func(w http.ResponseWriter, r *http.Request) {
-
 		ct, dec, enc, err := determineEncoding(r.Header)
 		if err != nil {
 			http.Error(w, http.StatusText(http.StatusUnsupportedMediaType), http.StatusUnsupportedMediaType)
@@ -104,7 +102,6 @@ func determineEncoding(h http.Header) (string, encoding.DecodeFunc, encoding.Enc
 }
 
 func getSingleHeaderEncoding(header string) (string, encoding.DecodeFunc, encoding.EncodeFunc, error) {
-
 	var enc encoding.EncodeFunc
 	var dec encoding.DecodeFunc
 	var ct string
@@ -132,7 +129,7 @@ func getMultiValueHeaders(header string) []string {
 
 	splitHeaders := strings.Split(header, ",")
 
-	trimmedHeaders := []string{}
+	trimmedHeaders := make([]string, 0, len(splitHeaders))
 	for _, v := range splitHeaders {
 		trimmedHeaders = append(trimmedHeaders, strings.TrimSpace(v))
 	}
diff --git a/docs/components/async/AMQP.md b/docs/components/async/AMQP.md
index 41ecace1c..784645967 100644
--- a/docs/components/async/AMQP.md
+++ b/docs/components/async/AMQP.md
@@ -6,6 +6,6 @@ The supported [exchange types](https://www.rabbitmq.com/tutorials/amqp-concepts.
 
 Users can configure the incoming messages buffer size, the connection timeout, whether rejected message should be requeued, as well as provide custom exchange-queue [bindings](https://www.rabbitmq.com/tutorials/amqp-concepts.html#bindings).
 
-The AMQP consumer component is powered by the battle-tested [`streadway/amqp`](https://www.rabbitmq.com/tutorials/amqp-concepts.html#bindings) package. In the [examples](/examples/amqp/amqp.go) folder you can see the component in action.
+The AMQP consumer component is powered by the battle-tested [`streadway/amqp`](https://www.rabbitmq.com/tutorials/amqp-concepts.html#bindings) package. In the [examples](/examples/amqp/main.go) folder you can see the component in action.
 
 As with all Patron components, tracing capabilities are included out of the box.
diff --git a/docs/other/CLI.md b/docs/other/CLI.md
index eaa1abe56..43b2c8026 100644
--- a/docs/other/CLI.md
+++ b/docs/other/CLI.md
@@ -9,12 +9,12 @@ The framework supplies a CLI in order to simplify repository generation with the
 
 The latest version can be installed with
 
-```go
+```bash
 go get github.com/beatlabs/patron/cmd/patron
 ```
 
 Below is an example of a service created with the cli that has a module name `github.com/beatlabs/test` and will be created in the test folder in the current directory.
 
-```go
+```bash
 patron -m "github.com/beatlabs/test" -p "test"
 ```
\ No newline at end of file
diff --git a/examples/amqp/main.go b/examples/amqp/main.go
index 85577a823..74ee131dc 100644
--- a/examples/amqp/main.go
+++ b/examples/amqp/main.go
@@ -146,6 +146,9 @@ func createSQSQueue(api sqsiface.SQSAPI) (string, error) {
 	out, err := api.CreateQueue(&sqs.CreateQueueInput{
 		QueueName: aws.String(awsSQSQueue),
 	})
+	if err != nil {
+		return "", err
+	}
 	if out.QueueUrl == nil {
 		return "", errors.New("could not create the queue")
 	}
@@ -248,6 +251,10 @@ func (ac *amqpComponent) Process(msg async.Message) error {
 		Body(string(payload)).
 		QueueURL(ac.sqsQueueURL).
 		Build()
+	if err != nil {
+		return err
+	}
+
 	_, err = ac.sqsPub.Publish(msg.Context(), *sqsMsg)
 	if err != nil {
 		return fmt.Errorf("failed to publish message to SQS: %v", err)
diff --git a/examples/client-decompression/main.go b/examples/client-decompression/main.go
index 61680be5c..3f5a361ac 100644
--- a/examples/client-decompression/main.go
+++ b/examples/client-decompression/main.go
@@ -33,7 +33,14 @@ func main() {
 	ctx := context.Background()
 
 	service, err := patron.New(name, version)
-	service.Run(ctx)
+	if err != nil {
+		fmt.Printf("failed to set up service: %v", err)
+		os.Exit(1)
+	}
+	err = service.Run(ctx)
+	if err != nil {
+		log.Fatalf("failed to create and run service %v", err)
+	}
 
 	cl, err := clienthttp.New(clienthttp.Timeout(1 * time.Second))
 
@@ -44,6 +51,9 @@ func main() {
 	handle(err)
 
 	gzipReq, err := http.NewRequest("GET", "http://localhost:50000/hello", nil)
+	if err != nil {
+		log.Fatalf("failed to create gzip request: %v", err)
+	}
 	gzipReq.Header.Add(encoding.AcceptEncodingHeader, "gzip")
 	rsp2, err := cl.Do(ctx, gzipReq)
 	handle(err)
@@ -51,6 +61,9 @@ func main() {
 	handle(err)
 
 	deflateReq, err := http.NewRequest("GET", "http://localhost:50000/hello", nil)
+	if err != nil {
+		log.Fatalf("failed to create deflate request: %v", err)
+	}
 	deflateReq.Header.Add(encoding.AcceptEncodingHeader, "deflate")
 	rsp3, err := cl.Do(ctx, deflateReq)
 	handle(err)
@@ -60,7 +73,6 @@ func main() {
 	fmt.Printf("Response without compression : %v\n", string(bdy1))
 	fmt.Printf("Response with GZIP compression : %v\n", string(bdy2))
 	fmt.Printf("Response with Deflate compression : %v\n", string(bdy3))
-
 }
 
 func handle(err error) {
diff --git a/examples/sqs/main.go b/examples/sqs/main.go
index 64f6fe0ab..9ec1068dc 100644
--- a/examples/sqs/main.go
+++ b/examples/sqs/main.go
@@ -66,7 +66,7 @@ func main() {
 		_ = cc.Close()
 	}()
 
-	greeter := greeter.NewGreeterClient(cc)
+	greeterClient := greeter.NewGreeterClient(cc)
 
 	// Initialise SQS
 	sqsAPI := sqs.New(
@@ -80,7 +80,7 @@ func main() {
 			),
 		),
 	)
-	sqsCmp, err := createSQSComponent(sqsAPI, greeter)
+	sqsCmp, err := createSQSComponent(sqsAPI, greeterClient)
 	if err != nil {
 		log.Fatalf("failed to create sqs component: %v", err)
 	}


Test patch:
diff --git a/client/http/http_test.go b/client/http/http_test.go
index ac34e85e8..16ff90f8f 100644
--- a/client/http/http_test.go
+++ b/client/http/http_test.go
@@ -25,7 +25,7 @@ func TestTracedClient_Do(t *testing.T) {
 		assert.Equal(t, "true", r.Header.Get("Mockpfx-Ids-Sampled"))
 		assert.NotEmpty(t, r.Header.Get("Mockpfx-Ids-Spanid"))
 		assert.NotEmpty(t, r.Header.Get("Mockpfx-Ids-Traceid"))
-		fmt.Fprintln(w, "Hello, client")
+		_, _ = fmt.Fprintln(w, "Hello, client")
 	}))
 	defer ts.Close()
 	mtr := mocktracer.New()
@@ -133,10 +133,9 @@ func TestHTTPStartFinishSpan(t *testing.T) {
 }
 
 func TestDecompress(t *testing.T) {
-
 	const msg = "hello, client!"
 	ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		fmt.Fprint(w, msg)
+		_, _ = fmt.Fprint(w, msg)
 	}))
 	defer ts1.Close()
 
diff --git a/client/redis/redis_test.go b/client/redis/redis_test.go
index 1c426d550..503faff6f 100644
--- a/client/redis/redis_test.go
+++ b/client/redis/redis_test.go
@@ -25,10 +25,10 @@ func TestSpan(t *testing.T) {
 	trace.SpanSuccess(sp)
 	rawSpan := mtr.FinishedSpans()[0]
 	assert.Equal(t, map[string]interface{}{
-		"component":    RedisComponent,
+		"component":    component,
 		"db.instance":  "localhost",
 		"db.statement": "flushdb",
-		"db.type":      RedisDBType,
+		"db.type":      dbType,
 		"error":        false,
 		"key":          "value",
 	}, rawSpan.Tags())
diff --git a/client/sns/message_test.go b/client/sns/message_test.go
index a78659500..0d242a0f8 100644
--- a/client/sns/message_test.go
+++ b/client/sns/message_test.go
@@ -66,11 +66,11 @@ func Test_MessageBuilder_InvalidStringArrayAttribute(t *testing.T) {
 
 func Test_MessageBuilder_Build_With_Error(t *testing.T) {
 	b := NewMessageBuilder()
-	err := errors.New("an err")
-	b.err = err
+	errMsg := "an err"
+	b.err = errors.New(errMsg)
 	m, foundErr := b.Build()
 	assert.Nil(t, m)
-	assert.EqualError(t, err, foundErr.Error())
+	assert.EqualError(t, foundErr, errMsg)
 }
 
 func Test_MessageBuilder_Build_With_Invalid_attribute(t *testing.T) {
@@ -91,14 +91,14 @@ func Test_MessageBuilder_formatStringArrayAttributeValues(t *testing.T) {
 		{
 			desc: "Valid data types - (u)ints",
 			values: []interface{}{
-				42, int(42), int8(42), int16(42), int32(42), int64(42),
+				42, 42, int8(42), int16(42), int32(42), int64(42),
 				uint(42), uint8(42), uint16(42), uint32(42), uint64(42),
 			},
 			expectedOutput: `[42,42,42,42,42,42,42,42,42,42,42]`,
 		},
 		{
 			desc:           "Valid data types - floats",
-			values:         []interface{}{float32(13.37), float64(13.37), 13.37},
+			values:         []interface{}{float32(13.37), 13.37, 13.37},
 			expectedOutput: `[13.37,13.37,13.37]`,
 		},
 		{
diff --git a/client/sns/publisher_test.go b/client/sns/publisher_test.go
index 320031594..df7d506ee 100644
--- a/client/sns/publisher_test.go
+++ b/client/sns/publisher_test.go
@@ -42,6 +42,7 @@ func Test_NewPublisher(t *testing.T) {
 				assert.Nil(t, p)
 				assert.EqualError(t, err, tC.expectedErr.Error())
 			} else {
+				assert.NotNil(t, p)
 				assert.Equal(t, tC.api, p.api)
 				assert.Equal(t, p.component, publisherComponent)
 				assert.Equal(t, p.tag, ext.SpanKindProducer)
@@ -129,7 +130,7 @@ func newStubSNSAPI(expectedOutput *sns.PublishOutput, expectedErr error) *stubSN
 	return &stubSNSAPI{output: expectedOutput, err: expectedErr}
 }
 
-func (s *stubSNSAPI) PublishWithContext(ctx context.Context, input *sns.PublishInput, options ...request.Option) (*sns.PublishOutput, error) {
+func (s *stubSNSAPI) PublishWithContext(_ context.Context, _ *sns.PublishInput, _ ...request.Option) (*sns.PublishOutput, error) {
 	return s.output, s.err
 }
 
diff --git a/client/sqs/message_test.go b/client/sqs/message_test.go
index 9ecbfe63e..45d405688 100644
--- a/client/sqs/message_test.go
+++ b/client/sqs/message_test.go
@@ -74,11 +74,11 @@ func Test_Message_injectHeaders(t *testing.T) {
 
 func Test_MessageBuilder_Build_With_Error(t *testing.T) {
 	b := NewMessageBuilder()
-	err := errors.New("an err")
-	b.err = err
+	errMsg := "an err"
+	b.err = errors.New(errMsg)
 	m, foundErr := b.Build()
 	assert.Nil(t, m)
-	assert.EqualError(t, err, foundErr.Error())
+	assert.EqualError(t, foundErr, errMsg)
 
 	testCases := map[string]struct {
 		msgBuilder  *MessageBuilder
diff --git a/client/sqs/publisher_test.go b/client/sqs/publisher_test.go
index 47a7c7132..a11d90d75 100644
--- a/client/sqs/publisher_test.go
+++ b/client/sqs/publisher_test.go
@@ -42,6 +42,7 @@ func Test_NewPublisher(t *testing.T) {
 				assert.Nil(t, p)
 				assert.EqualError(t, err, tC.expectedErr.Error())
 			} else {
+				assert.NotNil(t, p)
 				assert.Equal(t, tC.api, p.api)
 				assert.Equal(t, p.component, publisherComponent)
 				assert.Equal(t, p.tag, ext.SpanKindProducer)
@@ -129,7 +130,7 @@ func newStubSQSAPI(expectedOutput *sqs.SendMessageOutput, expectedErr error) *st
 	return &stubSQSAPI{output: expectedOutput, err: expectedErr}
 }
 
-func (s *stubSQSAPI) SendMessageWithContext(ctx context.Context, input *sqs.SendMessageInput, options ...request.Option) (*sqs.SendMessageOutput, error) {
+func (s *stubSQSAPI) SendMessageWithContext(_ context.Context, _ *sqs.SendMessageInput, _ ...request.Option) (*sqs.SendMessageOutput, error) {
 	return s.output, s.err
 }
 
diff --git a/component/async/kafka/kafka_test.go b/component/async/kafka/kafka_test.go
index c4fc7c3a3..83041681e 100644
--- a/component/async/kafka/kafka_test.go
+++ b/component/async/kafka/kafka_test.go
@@ -15,7 +15,7 @@ import (
 	"github.com/beatlabs/patron/component/async"
 	"github.com/beatlabs/patron/correlation"
 	"github.com/beatlabs/patron/encoding"
-	patron_json "github.com/beatlabs/patron/encoding/json"
+	patronjson "github.com/beatlabs/patron/encoding/json"
 	"github.com/opentracing/opentracing-go"
 	"github.com/opentracing/opentracing-go/mocktracer"
 	"github.com/stretchr/testify/assert"
@@ -72,7 +72,7 @@ func Test_message(t *testing.T) {
 	msg := message{
 		sess: nil,
 		ctx:  ctx,
-		dec:  patron_json.DecodeRaw,
+		dec:  patronjson.DecodeRaw,
 		span: sp,
 		msg:  cm,
 	}
@@ -101,7 +101,7 @@ func TestMapHeader(t *testing.T) {
 func Test_getCorrelationID(t *testing.T) {
 	withID := []*sarama.RecordHeader{{Key: []byte(correlation.HeaderID), Value: []byte("123")}}
 	withoutID := []*sarama.RecordHeader{{Key: []byte(correlation.HeaderID), Value: []byte("")}}
-	missingHeader := []*sarama.RecordHeader{}
+	var missingHeader []*sarama.RecordHeader
 	type args struct {
 		hh []*sarama.RecordHeader
 	}
@@ -135,7 +135,6 @@ type eventCounter struct {
 }
 
 func TestWrongContentTypeError(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			claimErr: 1,
@@ -150,7 +149,6 @@ func TestWrongContentTypeError(t *testing.T) {
 }
 
 func TestDecodingError(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			decodingErr: 1,
@@ -165,7 +163,6 @@ func TestDecodingError(t *testing.T) {
 }
 
 func TestIncompatibleDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			decodingErr: 1,
@@ -180,7 +177,6 @@ func TestIncompatibleDecoder(t *testing.T) {
 }
 
 func TestJsonDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			messageCount: 1,
@@ -196,7 +192,6 @@ func TestJsonDecoder(t *testing.T) {
 }
 
 func TestNoDecoderNoContentType(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			claimErr: 1,
@@ -211,7 +206,6 @@ func TestNoDecoderNoContentType(t *testing.T) {
 }
 
 func TestMultipleMessagesJsonDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			decodingErr:  1,
@@ -230,7 +224,6 @@ func TestMultipleMessagesJsonDecoder(t *testing.T) {
 }
 
 func TestDefaultDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			messageCount: 1,
@@ -238,7 +231,7 @@ func TestDefaultDecoder(t *testing.T) {
 		msgs: []*sarama.ConsumerMessage{
 			saramaConsumerMessage("[\"value\",\"key\"]", &sarama.RecordHeader{
 				Key:   []byte(encoding.ContentTypeHeader),
-				Value: []byte(patron_json.Type),
+				Value: []byte(patronjson.Type),
 			}),
 		},
 		dmsgs: [][]string{{"value", "key"}},
@@ -248,7 +241,6 @@ func TestDefaultDecoder(t *testing.T) {
 }
 
 func TestStringDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			messageCount: 1,
@@ -264,7 +256,6 @@ func TestStringDecoder(t *testing.T) {
 }
 
 func TestExoticDecoder(t *testing.T) {
-
 	testData := decodingTestData{
 		counter: eventCounter{
 			messageCount: 3,
@@ -297,18 +288,17 @@ func saramaConsumerMessage(value string, header *sarama.RecordHeader) *sarama.Co
 }
 
 func versionedConsumerMessage(value string, header *sarama.RecordHeader, version uint8) *sarama.ConsumerMessage {
-
-	bytes := []byte(value)
+	b := []byte(value)
 
 	if version > 0 {
-		bytes = append([]byte{version}, bytes...)
+		b = append([]byte{version}, b...)
 	}
 
 	return &sarama.ConsumerMessage{
 		Topic:          "TEST_TOPIC",
 		Partition:      0,
 		Key:            []byte("key"),
-		Value:          bytes,
+		Value:          b,
 		Offset:         0,
 		Timestamp:      time.Now(),
 		BlockTimestamp: time.Now(),
@@ -317,7 +307,6 @@ func versionedConsumerMessage(value string, header *sarama.RecordHeader, version
 }
 
 func testMessageClaim(t *testing.T, data decodingTestData) {
-
 	ctx := context.Background()
 
 	counter := eventCounter{}
@@ -327,11 +316,9 @@ func testMessageClaim(t *testing.T, data decodingTestData) {
 
 		if data.combinedDecoderVersion != 0 {
 			km.Value = append([]byte{byte(data.combinedDecoderVersion)}, km.Value...)
-
 		}
 
 		msg, err := ClaimMessage(ctx, km, data.decoder, nil)
-
 		if err != nil {
 			counter.claimErr++
 			continue
@@ -344,16 +331,15 @@ func testMessageClaim(t *testing.T, data decodingTestData) {
 	}
 
 	assert.Equal(t, data.counter, counter)
-
 }
 
 // some naive decoder implementations for testing
 
-func erroringDecoder(data []byte, v interface{}) error {
-	return fmt.Errorf("Predefined Decoder Error for message %s", string(data))
+func erroringDecoder(data []byte, _ interface{}) error {
+	return fmt.Errorf("predefined decoder error for message %s", string(data))
 }
 
-func voidDecoder(data []byte, v interface{}) error {
+func voidDecoder(_ []byte, _ interface{}) error {
 	return nil
 }
 
@@ -361,13 +347,12 @@ func stringToSliceDecoder(data []byte, v interface{}) error {
 	if arr, ok := v.(*[]string); ok {
 		*arr = append(*arr, strings.Split(string(data), " ")...)
 	} else {
-		return fmt.Errorf("Provided object is not valid for splitting data into a slice '%v'", v)
+		return fmt.Errorf("provided object is not valid for splitting data into a slice '%v'", v)
 	}
 	return nil
 }
 
 func combinedDecoder(data []byte, v interface{}) error {
-
 	version, _ := binary.ReadUvarint(bytes.NewBuffer(data[:1]))
 
 	switch version {
@@ -385,15 +370,15 @@ func combinedDecoder(data []byte, v interface{}) error {
 var process = func(counter *eventCounter, data *decodingTestData) func(message async.Message) error {
 	return func(message async.Message) error {
 		// we always assume we will decode to a slice of strings
-		values := []string{}
+		values := make([]string, 0)
 		// we assume based on our transform function, that we will be able to decode as a rule
 		if err := message.Decode(&values); err != nil {
 			counter.decodingErr++
-			return fmt.Errorf("Error encountered while decoding message from source [%v] : %v", message, err)
+			return fmt.Errorf("error encountered while decoding message from source [%v] : %v", message, err)
 		}
 		if !reflect.DeepEqual(data.dmsgs[counter.messageCount], values) {
 			counter.resultErr++
-			return fmt.Errorf("Could not verify equality for '%v' and '%v' at index '%d'", values, data.dmsgs[counter.messageCount], counter.messageCount)
+			return fmt.Errorf("could not verify equality for '%v' and '%v' at index '%d'", values, data.dmsgs[counter.messageCount], counter.messageCount)
 		}
 		counter.messageCount++
 		return nil
diff --git a/component/grpc/component_test.go b/component/grpc/component_test.go
index f4f027d21..070c83e5e 100644
--- a/component/grpc/component_test.go
+++ b/component/grpc/component_test.go
@@ -42,7 +42,7 @@ type server struct {
 	greeter.UnimplementedGreeterServer
 }
 
-func (s *server) SayHello(ctx context.Context, in *greeter.HelloRequest) (*greeter.HelloReply, error) {
+func (s *server) SayHello(_ context.Context, in *greeter.HelloRequest) (*greeter.HelloReply, error) {
 	if in.GetFirstname() == "ERROR" {
 		return nil, errors.New("ERROR")
 	}
diff --git a/component/http/auth/apikey/apikey_test.go b/component/http/auth/apikey/apikey_test.go
index e607fb5f8..7127f6c65 100644
--- a/component/http/auth/apikey/apikey_test.go
+++ b/component/http/auth/apikey/apikey_test.go
@@ -13,7 +13,7 @@ type MockValidator struct {
 	success bool
 }
 
-func (mv MockValidator) Validate(key string) (bool, error) {
+func (mv MockValidator) Validate(_ string) (bool, error) {
 	if mv.err != nil {
 		return false, mv.err
 	}
diff --git a/component/http/cache/cache_test.go b/component/http/cache/cache_test.go
index 8f8d59489..2ad5b5bee 100644
--- a/component/http/cache/cache_test.go
+++ b/component/http/cache/cache_test.go
@@ -1819,7 +1819,7 @@ func (m *testMetrics) err(path string) {
 	m.values[path].errors++
 }
 
-func (m *testMetrics) evict(path string, context validationContext, age int64) {
+func (m *testMetrics) evict(path string, _ validationContext, _ int64) {
 	m.init(path)
 	m.values[path].evictions++
 }
diff --git a/component/http/component_test.go b/component/http/component_test.go
index f13ee1664..8748d54a1 100644
--- a/component/http/component_test.go
+++ b/component/http/component_test.go
@@ -97,9 +97,8 @@ func TestBuilder_WithShutdownGracePeriod(t *testing.T) {
 }
 
 func Test_createHTTPServerUsingBuilder(t *testing.T) {
-
-	var httpBuilderNoErrors = []error{}
-	var httpBuilderAllErrors = []error{
+	var httpBuilderNoErrors []error
+	httpBuilderAllErrors := []error{
 		errors.New("nil AliveCheckFunc was provided"),
 		errors.New("nil ReadyCheckFunc provided"),
 		errors.New("invalid HTTP Port provided"),
diff --git a/component/http/handler_test.go b/component/http/handler_test.go
index 0580fa238..70a4ed083 100644
--- a/component/http/handler_test.go
+++ b/component/http/handler_test.go
@@ -28,6 +28,7 @@ func Test_extractFields(t *testing.T) {
 
 func Test_extractHeaders(t *testing.T) {
 	r, err := http.NewRequest("GET", "/test", nil)
+	require.NoError(t, err)
 	r.Header.Set("X-HEADER-1", "all capsssss")
 	r.Header.Set("X-HEADER-1", "all caps")
 	r.Header.Set("x-Header-2", "all lower")
@@ -174,13 +175,11 @@ func Test_handleSuccess(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-
 			rsp := httptest.NewRecorder()
 
 			err := handleSuccess(rsp, tt.args.req, tt.args.rsp, tt.args.enc)
 			if tt.wantErr {
 				assert.Error(t, err)
-
 			} else {
 				assert.NoError(t, err)
 				assert.Equal(t, tt.expectedStatus, rsp.Code)
@@ -205,7 +204,7 @@ func Test_handleError(t *testing.T) {
 		{"not found error", args{err: NewNotFoundError(), enc: json.Encode}, http.StatusNotFound},
 		{"service unavailable error", args{err: NewServiceUnavailableError(), enc: json.Encode}, http.StatusServiceUnavailable},
 		{"internal server error", args{err: NewError(), enc: json.Encode}, http.StatusInternalServerError},
-		{"default error", args{err: errors.New("Test"), enc: json.Encode}, http.StatusInternalServerError},
+		{"default error", args{err: errors.New("test"), enc: json.Encode}, http.StatusInternalServerError},
 		{"Payload encoding error", args{err: NewErrorWithCodeAndPayload(http.StatusBadRequest, make(chan int)), enc: json.Encode}, http.StatusInternalServerError},
 	}
 	for _, tt := range tests {
@@ -222,7 +221,7 @@ type testHandler struct {
 	resp interface{}
 }
 
-func (th testHandler) Process(ctx context.Context, req *Request) (*Response, error) {
+func (th testHandler) Process(_ context.Context, _ *Request) (*Response, error) {
 	if th.err {
 		return nil, errors.New("TEST")
 	}
@@ -230,13 +229,13 @@ func (th testHandler) Process(ctx context.Context, req *Request) (*Response, err
 }
 
 func Test_handler(t *testing.T) {
-	require := require.New(t)
 	errReq, err := http.NewRequest(http.MethodGet, "/", nil)
+	require.NoError(t, err)
 	errReq.Header.Set(encoding.ContentTypeHeader, "xml")
-	require.NoError(err)
+	require.NoError(t, err)
 
 	req, err := http.NewRequest(http.MethodGet, "/", nil)
-	require.NoError(err)
+	require.NoError(t, err)
 
 	req.Header.Set(encoding.ContentTypeHeader, json.Type)
 	req.Header.Set(encoding.AcceptHeader, json.Type)
@@ -327,5 +326,4 @@ func Test_extractParamsRawRoute(t *testing.T) {
 
 	assert.Equal(t, "42", fields["id"])
 	assert.Equal(t, "online", fields["status"])
-
 }
diff --git a/component/http/route_cache_test.go b/component/http/route_cache_test.go
index 91426568a..9d5b041f9 100644
--- a/component/http/route_cache_test.go
+++ b/component/http/route_cache_test.go
@@ -3,7 +3,6 @@ package http
 import (
 	"context"
 	"fmt"
-	"github.com/beatlabs/patron/encoding"
 	"net/http"
 	"net/http/httptest"
 	"sync"
@@ -11,6 +10,10 @@ import (
 	"testing"
 	"time"
 
+	"github.com/stretchr/testify/require"
+
+	"github.com/beatlabs/patron/encoding"
+
 	"github.com/beatlabs/patron/cache"
 	httpclient "github.com/beatlabs/patron/client/http"
 	httpcache "github.com/beatlabs/patron/component/http/cache"
@@ -33,7 +36,6 @@ type arg struct {
 }
 
 func TestCachingMiddleware(t *testing.T) {
-
 	getRequest, err := http.NewRequest("GET", "/test", nil)
 	assert.NoError(t, err)
 
@@ -48,7 +50,7 @@ func TestCachingMiddleware(t *testing.T) {
 	testingCache := newTestingCache()
 	testingCache.instant = httpcache.NowSeconds
 
-	cache, errs := httpcache.NewRouteCache(testingCache, httpcache.Age{Max: 1 * time.Second})
+	routeCache, errs := httpcache.NewRouteCache(testingCache, httpcache.Age{Max: 1 * time.Second})
 	assert.Empty(t, errs)
 
 	tests := []struct {
@@ -59,24 +61,32 @@ func TestCachingMiddleware(t *testing.T) {
 		expectedBody string
 		cacheState   cacheState
 	}{
-		{"caching middleware with POST request", args{next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-			w.WriteHeader(202)
-			i, err := w.Write([]byte{1, 2, 3, 4})
-			assert.NoError(t, err)
-			assert.Equal(t, 4, i)
-		}), mws: []MiddlewareFunc{NewCachingMiddleware(cache)}},
-			postRequest, 202, "\x01\x02\x03\x04", cacheState{}},
-		{"caching middleware with GET request", args{next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-			w.WriteHeader(200)
-			i, err := w.Write([]byte{1, 2, 3, 4})
-			assert.NoError(t, err)
-			assert.Equal(t, 4, i)
-		}), mws: []MiddlewareFunc{NewCachingMiddleware(cache)}},
-			getRequest, 200, "\x01\x02\x03\x04", cacheState{
+		{
+			"caching middleware with POST request",
+			args{next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+				w.WriteHeader(202)
+				i, err := w.Write([]byte{1, 2, 3, 4})
+				assert.NoError(t, err)
+				assert.Equal(t, 4, i)
+			}), mws: []MiddlewareFunc{NewCachingMiddleware(routeCache)}},
+			postRequest, 202, "\x01\x02\x03\x04",
+			cacheState{},
+		},
+		{
+			"caching middleware with GET request",
+			args{next: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+				w.WriteHeader(200)
+				i, err := w.Write([]byte{1, 2, 3, 4})
+				assert.NoError(t, err)
+				assert.Equal(t, 4, i)
+			}), mws: []MiddlewareFunc{NewCachingMiddleware(routeCache)}},
+			getRequest, 200, "\x01\x02\x03\x04",
+			cacheState{
 				setOps: 1,
 				getOps: 1,
 				size:   1,
-			}},
+			},
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -89,11 +99,9 @@ func TestCachingMiddleware(t *testing.T) {
 			assertCacheState(t, *testingCache, tt.cacheState)
 		})
 	}
-
 }
 
 func TestNewRouteBuilder_WithCache(t *testing.T) {
-
 	args := []arg{
 		{
 			bop: func(routeBuilder *RouteBuilder) *RouteBuilder {
@@ -138,7 +146,6 @@ func TestNewRouteBuilder_WithCache(t *testing.T) {
 }
 
 func assertRouteBuilder(t *testing.T, arg arg, routeBuilder *RouteBuilder, cache cache.TTLCache) {
-
 	routeBuilder.WithRouteCache(cache, arg.age)
 
 	if arg.bop != nil {
@@ -358,7 +365,8 @@ func TestRawRouteCacheImplementation_WithSingleRequest(t *testing.T) {
 				"Content-Length":             {"6"},
 				"Post-Middleware-Header":     {"post"},
 				"Pre-Middleware-Header":      {"pre"},
-				"Internal-Handler-Header":    {"header"}},
+				"Internal-Handler-Header":    {"header"},
+			},
 			Body: &bodyReader{body: "\"body\""},
 		},
 		{
@@ -368,7 +376,8 @@ func TestRawRouteCacheImplementation_WithSingleRequest(t *testing.T) {
 				"Content-Length":             {"6"},
 				"Post-Middleware-Header":     {"post"},
 				"Pre-Middleware-Header":      {"pre"},
-				"Internal-Handler-Header":    {"header"}},
+				"Internal-Handler-Header":    {"header"},
+			},
 			Body: &bodyReader{body: "\"body\""},
 		},
 	}, port)
@@ -441,10 +450,10 @@ func runRoute(ctx context.Context, t *testing.T, routeBuilder *RouteBuilder, ce
 }
 
 func assertResponse(ctx context.Context, t *testing.T, expected []http.Response, port int) {
-
 	cl, err := httpclient.New()
 	assert.NoError(t, err)
 	req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:%d/path", port), nil)
+	require.NoError(t, err)
 	req.Header.Set(encoding.AcceptEncodingHeader, "*") // bypass default HTTP client GZIP-ing our response
 	assert.NoError(t, err)
 
@@ -469,7 +478,6 @@ func assertResponse(ctx context.Context, t *testing.T, expected []http.Response,
 		assert.Equal(t, i, j)
 		assert.Equal(t, expectedPayload, responsePayload)
 	}
-
 }
 
 func assertCacheState(t *testing.T, cache testingCache, cacheState cacheState) {
diff --git a/component/http/route_test.go b/component/http/route_test.go
index 6bcd353c7..f5318e749 100644
--- a/component/http/route_test.go
+++ b/component/http/route_test.go
@@ -19,7 +19,7 @@ type MockAuthenticator struct {
 	err     error
 }
 
-func (mo MockAuthenticator) Authenticate(req *http.Request) (bool, error) {
+func (mo MockAuthenticator) Authenticate(_ *http.Request) (bool, error) {
 	if mo.err != nil {
 		return false, mo.err
 	}
@@ -163,13 +163,11 @@ func TestRouteBuilder_WithAuth(t *testing.T) {
 }
 
 func TestRouteBuilder_WithRouteCacheNil(t *testing.T) {
-
 	rb := NewRawRouteBuilder("/", func(writer http.ResponseWriter, request *http.Request) {}).
 		WithRouteCache(nil, cache.Age{Max: 1})
 
 	assert.Len(t, rb.errors, 1)
 	assert.EqualError(t, rb.errors[0], "route cache is nil")
-
 }
 
 func TestRouteBuilder_Build(t *testing.T) {
@@ -272,30 +270,37 @@ func TestNewHeadRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodHead, NewHeadRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewPostRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodPost, NewPostRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewPutGetRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodPut, NewPutRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewPatchRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodPatch, NewPatchRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewDeleteRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodDelete, NewDeleteRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewConnectRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodConnect, NewConnectRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewOptionsRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodOptions, NewOptionsRouteBuilder("/", mockProcessor).method)
 }
+
 func TestNewTraceRouteBuilder(t *testing.T) {
 	mockProcessor := func(context.Context, *Request) (*Response, error) { return nil, nil }
 	assert.Equal(t, http.MethodTrace, NewTraceRouteBuilder("/", mockProcessor).method)
diff --git a/encoding/protobuf/protobuf_test.go b/encoding/protobuf/protobuf_test.go
index 99eae013f..ba3f9208d 100644
--- a/encoding/protobuf/protobuf_test.go
+++ b/encoding/protobuf/protobuf_test.go
@@ -66,6 +66,6 @@ func TestProtobuf(t *testing.T) {
 
 type errReader int
 
-func (errReader) Read(p []byte) (n int, err error) {
+func (errReader) Read(_ []byte) (n int, err error) {
 	return 0, errors.New("test error")
 }
diff --git a/errors/aggregate_test.go b/errors/aggregate_test.go
index b7fb8e94e..d3855dd63 100644
--- a/errors/aggregate_test.go
+++ b/errors/aggregate_test.go
@@ -8,9 +8,9 @@ import (
 )
 
 func TestAggregate(t *testing.T) {
-	a := Aggregate(errors.New("Error 1"), errors.New("Error 2"), nil, errors.New("Error 3"))
+	a := Aggregate(errors.New("error 1"), errors.New("error 2"), nil, errors.New("error 3"))
 	assert.Len(t, a, 3)
-	assert.Equal(t, "Error 1\nError 2\nError 3\n", a.Error())
+	assert.Equal(t, "error 1\nerror 2\nerror 3\n", a.Error())
 }
 
 func TestAggregate_ReturnsNil(t *testing.T) {
diff --git a/reliability/circuitbreaker/breaker_test.go b/reliability/circuitbreaker/breaker_test.go
index f7a9dc79a..9d3f7979a 100644
--- a/reliability/circuitbreaker/breaker_test.go
+++ b/reliability/circuitbreaker/breaker_test.go
@@ -129,7 +129,7 @@ func TestCircuitBreaker_Close_Open_HalfOpen_Open_HalfOpen_Close(t *testing.T) {
 	assert.Equal(t, tsFuture, cb.nextRetry)
 	// will transition to open
 	_, err = cb.Execute(testFailureAction)
-	assert.EqualError(t, err, "Test error")
+	assert.EqualError(t, err, "test error")
 	assert.Equal(t, uint(0), cb.failures)
 	assert.Equal(t, uint(0), cb.executions)
 	assert.Equal(t, uint(0), cb.retries)
@@ -146,7 +146,7 @@ func TestCircuitBreaker_Close_Open_HalfOpen_Open_HalfOpen_Close(t *testing.T) {
 	// should be half open now and will stay in there
 	time.Sleep(waitRetryTimeout)
 	_, err = cb.Execute(testFailureAction)
-	assert.EqualError(t, err, "Test error")
+	assert.EqualError(t, err, "test error")
 	assert.Equal(t, uint(1), cb.failures)
 	assert.Equal(t, uint(1), cb.executions)
 	assert.Equal(t, uint(0), cb.retries)
@@ -154,7 +154,7 @@ func TestCircuitBreaker_Close_Open_HalfOpen_Open_HalfOpen_Close(t *testing.T) {
 	assert.True(t, cb.nextRetry < tsFuture)
 	// should be half open now and will transition to open
 	_, err = cb.Execute(testFailureAction)
-	assert.EqualError(t, err, "Test error")
+	assert.EqualError(t, err, "test error")
 	assert.Equal(t, uint(0), cb.failures)
 	assert.Equal(t, uint(0), cb.executions)
 	assert.Equal(t, uint(0), cb.retries)
@@ -197,5 +197,5 @@ func testSuccessAction() (interface{}, error) {
 }
 
 func testFailureAction() (interface{}, error) {
-	return "", errors.New("Test error")
+	return "", errors.New("test error")
 }