Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Peltoche committed Oct 13, 2018
1 parent 2af348c commit 3da3190
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ linters-settings:
min-complexity: 25
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -18,6 +16,7 @@ linters:
disable:
- maligned
- lll
- dupl

issues:
exclude:
Expand Down
45 changes: 26 additions & 19 deletions analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Test_Analyzer_Analyze_with_body_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down Expand Up @@ -92,7 +92,7 @@ func Test_Analyzer_Analyze_with_invalid_body_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -119,7 +119,7 @@ func Test_Analyzer_Analyze_with_invalid_body_format(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -140,6 +140,7 @@ func Test_Analyzer_Analyze_with_query_parameters(t *testing.T) {
q.Set("status", "available")
req.URL.RawQuery = q.Encode()

// nolint: goconst
body := `[]`

res := &http.Response{
Expand All @@ -151,7 +152,7 @@ func Test_Analyzer_Analyze_with_query_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -172,6 +173,7 @@ func Test_Analyzer_Analyze_with_invalid_query_parameters(t *testing.T) {
q.Set("status", "invalid-enum-value")
req.URL.RawQuery = q.Encode()

// nolint: goconst
body := `[]`

res := &http.Response{
Expand All @@ -183,7 +185,7 @@ func Test_Analyzer_Analyze_with_invalid_query_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -210,7 +212,7 @@ func Test_Analyzer_Analyze_with_unhandled_method(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down Expand Up @@ -256,7 +258,7 @@ func Test_Analyzer_Analyze_with_path_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -283,7 +285,7 @@ func Test_Analyzer_Analyze_with_invalid_path_parameters(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -300,7 +302,8 @@ func Test_Analyzer_Analyze_with_formData_file(t *testing.T) {

var buf bytes.Buffer
mp := multipart.NewWriter(&buf)
mp.WriteField("additionalMetadata", "foobar")
err = mp.WriteField("additionalMetadata", "foobar")
require.NoError(t, err)
fileWriter, err := mp.CreateFormFile("file", "file")
require.NoError(t, err)
_, err = fileWriter.Write([]byte("some-data"))
Expand Down Expand Up @@ -329,7 +332,7 @@ func Test_Analyzer_Analyze_with_formData_file(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -345,7 +348,8 @@ func Test_Analyzer_Analyze_with_missing_formData_file(t *testing.T) {

var buf bytes.Buffer
mp := multipart.NewWriter(&buf)
mp.WriteField("additionalMetadata", "foobar")
err = mp.WriteField("additionalMetadata", "foobar")
require.NoError(t, err)

err = mp.Close()
require.NoError(t, err)
Expand All @@ -364,7 +368,7 @@ func Test_Analyzer_Analyze_with_missing_formData_file(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down Expand Up @@ -403,7 +407,7 @@ func Test_Analyzer_Analyze_with_missing_formData_field(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down Expand Up @@ -431,7 +435,7 @@ func Test_Analyzer_Analyze_with_header(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -457,7 +461,7 @@ func Test_Analyzer_Analyze_with_missing_header(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString("")),
ContentLength: int64(0),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -478,6 +482,7 @@ func Test_Analyzer_Analyze_with_unrequired_body(t *testing.T) {
}`))
require.NoError(t, err)

// nolint: goconst
body := `{}`

res := &http.Response{
Expand All @@ -489,7 +494,7 @@ func Test_Analyzer_Analyze_with_unrequired_body(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -511,6 +516,7 @@ func Test_Analyzer_Analyze_with_unknown_response_status(t *testing.T) {
q.Set("status", "available")
req.URL.RawQuery = q.Encode()

// nolint: goconst
body := `[]`

res := &http.Response{
Expand All @@ -522,7 +528,7 @@ func Test_Analyzer_Analyze_with_unknown_response_status(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down Expand Up @@ -555,7 +561,7 @@ func Test_Analyzer_Analyze_with_unmarshalable_response_body(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand All @@ -578,6 +584,7 @@ func Test_Analyzer_Analyze_with_invalid_response_body(t *testing.T) {
req.URL.RawQuery = q.Encode()

// Should be an array
// nolint: goconst
body := `{}`

res := &http.Response{
Expand All @@ -589,7 +596,7 @@ func Test_Analyzer_Analyze_with_invalid_response_body(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewBufferString(body)),
ContentLength: int64(len(body)),
Request: req,
Header: make(http.Header, 0),
Header: make(http.Header),
}

err = analyzer.Analyze(req, res)
Expand Down

0 comments on commit 3da3190

Please sign in to comment.