Skip to content
This repository was archived by the owner on Jul 30, 2019. It is now read-only.

Commit 27ef409

Browse files
author
Francisco Souza
committed
Make the linter more sensitive
"sensitive" is a nice word for annoying.
1 parent f85273a commit 27ef409

File tree

8 files changed

+25
-7
lines changed

8 files changed

+25
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ checkfmt: testdeps
88

99
lint: testdeps
1010
go get github.com/golangci/golangci-lint/cmd/golangci-lint
11-
golangci-lint run -D errcheck -E golint -E staticcheck -E misspell -E gofmt ./...
11+
golangci-lint run --enable-all -D lll -D errcheck -D dupl -D gochecknoglobals --deadline 5m ./...
1212

1313
coverage: lint
1414
go test -coverprofile=coverage.txt -covermode=atomic ./...

elementalconductor/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package elementalconductor // import "github.com/NYTimes/encoding-wrapper/elementalconductor"
66

77
import (
8+
// #nosec
89
"crypto/md5"
910
"encoding/hex"
1011
"encoding/json"
@@ -102,14 +103,16 @@ func (c *Client) do(method string, path string, body interface{}, out interface{
102103
return nil
103104
}
104105

105-
func (c *Client) createAuthKey(URL string, expire time.Time) string {
106+
func (c *Client) createAuthKey(url string, expire time.Time) string {
106107
expireString := getUnixTimestamp(expire)
108+
// #nosec
107109
hasher := md5.New()
108-
hasher.Write([]byte(URL))
110+
hasher.Write([]byte(url))
109111
hasher.Write([]byte(c.UserLogin))
110112
hasher.Write([]byte(c.APIKey))
111113
hasher.Write([]byte(expireString))
112114
innerKey := hex.EncodeToString(hasher.Sum(nil))
115+
// #nosec
113116
hasher = md5.New()
114117
hasher.Write([]byte(c.APIKey))
115118
hasher.Write([]byte(innerKey))

elementalconductor/client_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package elementalconductor
22

33
import (
4+
// #nosec
45
"crypto/md5"
56
"encoding/hex"
67
"encoding/xml"
@@ -35,8 +36,10 @@ func TestCreateAuthKey(t *testing.T) {
3536
APIKey := "api-key"
3637
expire := time.Unix(1, 0)
3738
expireTimestamp := getUnixTimestamp(expire)
39+
// #nosec
3840
innerKeyMD5 := md5.Sum([]byte(path + userID + APIKey + expireTimestamp))
3941
innerKey2 := hex.EncodeToString(innerKeyMD5[:])
42+
// #nosec
4043
value := md5.Sum([]byte(APIKey + innerKey2))
4144
expected := hex.EncodeToString(value[:])
4245
client := NewClient("https://mycluster.cloud.elementaltechnologies.com", userID, APIKey, 45, "aws-access-key", "aws-secret-key", "destination")

elementalconductor/job_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func TestJobGetID(t *testing.T) {
342342
},
343343
}
344344
for _, test := range tests {
345+
test := test
345346
t.Run(test.href, func(t *testing.T) {
346347
j := Job{Href: test.href}
347348
id := j.GetID()
@@ -522,6 +523,7 @@ func TestVideoInfoDimensions(t *testing.T) {
522523
},
523524
}
524525
for _, test := range tests {
526+
test := test
525527
t.Run("", func(t *testing.T) {
526528
job := VideoInputInfo{Width: test.inputWidth, Height: test.inputHeight}
527529
width := job.GetWidth()
@@ -546,6 +548,7 @@ func TestVideoDescriptionWidth(t *testing.T) {
546548
{"whatever", 0},
547549
}
548550
for _, test := range tests {
551+
test := test
549552
t.Run(test.input, func(t *testing.T) {
550553
desc := StreamVideoDescription{Width: test.input}
551554
got := desc.GetWidth()
@@ -566,6 +569,7 @@ func TestVideoDescriptionHeight(t *testing.T) {
566569
{"whatever", 0},
567570
}
568571
for _, test := range tests {
572+
test := test
569573
t.Run(test.input, func(t *testing.T) {
570574
desc := StreamVideoDescription{Height: test.input}
571575
got := desc.GetHeight()

elementalconductor/time_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func TestDateTimeMarshalXML(t *testing.T) {
2323
},
2424
}
2525
for _, test := range tests {
26+
test := test
2627
t.Run(test.input.String(), func(t *testing.T) {
2728
var data struct {
2829
XMLName xml.Name `xml:"item"`
@@ -63,6 +64,7 @@ func TestDateTimeUnmarshalXML(t *testing.T) {
6364
},
6465
}
6566
for _, test := range tests {
67+
test := test
6668
t.Run(test.input, func(t *testing.T) {
6769
var output struct {
6870
XMLName xml.Name `xml:"item"`
@@ -107,6 +109,7 @@ func TestJobErrorDateTimeMarshalXML(t *testing.T) {
107109
},
108110
}
109111
for _, test := range tests {
112+
test := test
110113
t.Run(test.input.String(), func(t *testing.T) {
111114
var data struct {
112115
XMLName xml.Name `xml:"item"`
@@ -147,6 +150,7 @@ func TestJobErrorDateTimeUnmarshalXML(t *testing.T) {
147150
},
148151
}
149152
for _, test := range tests {
153+
test := test
150154
t.Run(test.input, func(t *testing.T) {
151155
var output struct {
152156
XMLName xml.Name `xml:"item"`

encodingcom/api_status_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
func TestAPIStatus(t *testing.T) {
11-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
11+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
1212
w.Write([]byte(`{"status":"Encoding Queue Processing Delays","status_code":"queue_slow","incident":"Our encoding queue is processing slower than normal. Check back for updates."}`))
1313
}))
1414
defer server.Close()
@@ -34,7 +34,7 @@ func TestAPIStatusFailToConnect(t *testing.T) {
3434
}
3535

3636
func TestAPIStatusInvalidResponse(t *testing.T) {
37-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
37+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
3838
w.Write([]byte(`{not a valid json}`))
3939
}))
4040
defer server.Close()
@@ -56,6 +56,7 @@ func TestAPIStatusOK(t *testing.T) {
5656
{"pc_queue_slow", false},
5757
}
5858
for _, test := range tests {
59+
test := test
5960
t.Run(test.input, func(t *testing.T) {
6061
status := APIStatusResponse{StatusCode: test.input}
6162
got := status.OK()

encodingcom/client_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestYesNoBooleanMarshal(t *testing.T) {
4141
},
4242
}
4343
for _, test := range tests {
44+
test := test
4445
t.Run(test.name, func(t *testing.T) {
4546
input := YesNoBoolean(test.input)
4647
data, err := json.Marshal(input)
@@ -100,6 +101,7 @@ func TestZeroOneBooleanMarshal(t *testing.T) {
100101
},
101102
}
102103
for _, test := range tests {
104+
test := test
103105
t.Run(test.name, func(t *testing.T) {
104106
input := ZeroOneBoolean(test.input)
105107
data, err := json.Marshal(input)
@@ -178,7 +180,7 @@ func TestDoMediaActionFailure(t *testing.T) {
178180
}
179181

180182
func TestDoMissingRequiredParameters(t *testing.T) {
181-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
183+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
182184
byteResponse, _ := json.Marshal(mockMediaResponseObject("", "Wrong user id or key!"))
183185
w.Write(byteResponse)
184186
}))
@@ -204,7 +206,7 @@ func TestDoMissingRequiredParameters(t *testing.T) {
204206

205207
func TestDoMediaResponse(t *testing.T) {
206208
const msg = "it worked!"
207-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
209+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
208210
byteResponse, _ := json.Marshal(mockMediaResponseObject(msg, ""))
209211
w.Write(byteResponse)
210212
}))

encodingcom/preset_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ func TestPresetFormatStream(t *testing.T) {
355355
},
356356
}
357357
for _, test := range tests {
358+
test := test
358359
t.Run(test.testCase, func(t *testing.T) {
359360
p := PresetFormat{StreamRawMap: test.streamRaw}
360361
streams := p.Stream()

0 commit comments

Comments
 (0)