-
Notifications
You must be signed in to change notification settings - Fork 38
Enable additional golangci-lint linters and fix reports #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously:
```
$ make lint
awsauth_test.go:127:32: Using the variable on range scope `testCase` in function literal (scopelint)
awsTs := awsMetadataApiMock(testCase.EC2MetadataEndpoints)
^
awsauth_test.go:130:60: Using the variable on range scope `testCase` in function literal (scopelint)
closeIam, iamSess, err := GetMockedAwsApiSession("IAM", testCase.IAMEndpoints)
^
awsauth_test.go:136:60: Using the variable on range scope `testCase` in function literal (scopelint)
closeSts, stsSess, err := GetMockedAwsApiSession("STS", testCase.STSEndpoints)
^
awsauth_test.go:145:76: Using the variable on range scope `testCase` in function literal (scopelint)
accountID, partition, err := GetAccountIDAndPartition(iamConn, stsConn, testCase.AuthProviderName)
^
awsauth_test.go:146:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err != nil && testCase.ErrCount == 0 {
^
awsauth_test.go:149:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err == nil && testCase.ErrCount > 0 {
^
awsauth_test.go:150:53: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Expected %d error(s), received none", testCase.ErrCount)
^
awsauth_test.go:152:20: Using the variable on range scope `testCase` in function literal (scopelint)
if accountID != testCase.ExpectedAccountID {
^
awsauth_test.go:153:85: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed account ID doesn't match with expected (%q != %q)", accountID, testCase.ExpectedAccountID)
^
awsauth_test.go:155:20: Using the variable on range scope `testCase` in function literal (scopelint)
if partition != testCase.ExpectedPartition {
^
awsauth_test.go:156:84: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed partition doesn't match with expected (%q != %q)", partition, testCase.ExpectedPartition)
^
awsauth_test.go:227:60: Using the variable on range scope `testCase` in function literal (scopelint)
closeIam, iamSess, err := GetMockedAwsApiSession("IAM", testCase.MockEndpoints)
^
awsauth_test.go:236:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err != nil && testCase.ErrCount == 0 {
^
awsauth_test.go:239:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err == nil && testCase.ErrCount > 0 {
^
awsauth_test.go:240:53: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Expected %d error(s), received none", testCase.ErrCount)
^
awsauth_test.go:242:20: Using the variable on range scope `testCase` in function literal (scopelint)
if accountID != testCase.ExpectedAccountID {
^
awsauth_test.go:243:85: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed account ID doesn't match with expected (%q != %q)", accountID, testCase.ExpectedAccountID)
^
awsauth_test.go:245:20: Using the variable on range scope `testCase` in function literal (scopelint)
if partition != testCase.ExpectedPartition {
^
awsauth_test.go:246:84: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed partition doesn't match with expected (%q != %q)", partition, testCase.ExpectedPartition)
^
awsauth_test.go:285:60: Using the variable on range scope `testCase` in function literal (scopelint)
closeIam, iamSess, err := GetMockedAwsApiSession("IAM", testCase.MockEndpoints)
^
awsauth_test.go:294:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err != nil && testCase.ErrCount == 0 {
^
awsauth_test.go:297:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err == nil && testCase.ErrCount > 0 {
^
awsauth_test.go:298:53: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Expected %d error(s), received none", testCase.ErrCount)
^
awsauth_test.go:300:20: Using the variable on range scope `testCase` in function literal (scopelint)
if accountID != testCase.ExpectedAccountID {
^
awsauth_test.go:301:85: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed account ID doesn't match with expected (%q != %q)", accountID, testCase.ExpectedAccountID)
^
awsauth_test.go:303:20: Using the variable on range scope `testCase` in function literal (scopelint)
if partition != testCase.ExpectedPartition {
^
awsauth_test.go:304:84: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed partition doesn't match with expected (%q != %q)", partition, testCase.ExpectedPartition)
^
awsauth_test.go:343:60: Using the variable on range scope `testCase` in function literal (scopelint)
closeSts, stsSess, err := GetMockedAwsApiSession("STS", testCase.MockEndpoints)
^
awsauth_test.go:352:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err != nil && testCase.ErrCount == 0 {
^
awsauth_test.go:355:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err == nil && testCase.ErrCount > 0 {
^
awsauth_test.go:356:53: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Expected %d error(s), received none", testCase.ErrCount)
^
awsauth_test.go:358:20: Using the variable on range scope `testCase` in function literal (scopelint)
if accountID != testCase.ExpectedAccountID {
^
awsauth_test.go:359:85: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed account ID doesn't match with expected (%q != %q)", accountID, testCase.ExpectedAccountID)
^
awsauth_test.go:361:20: Using the variable on range scope `testCase` in function literal (scopelint)
if partition != testCase.ExpectedPartition {
^
awsauth_test.go:362:84: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed partition doesn't match with expected (%q != %q)", partition, testCase.ExpectedPartition)
^
awsauth_test.go:403:67: Using the variable on range scope `testCase` in function literal (scopelint)
accountID, partition, err := parseAccountIDAndPartitionFromARN(testCase.InputARN)
^
awsauth_test.go:404:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err != nil && testCase.ErrCount == 0 {
^
awsauth_test.go:407:21: Using the variable on range scope `testCase` in function literal (scopelint)
if err == nil && testCase.ErrCount > 0 {
^
awsauth_test.go:408:70: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Expected %d error(s) when parsing ARN, received none", testCase.ErrCount)
^
awsauth_test.go:410:20: Using the variable on range scope `testCase` in function literal (scopelint)
if accountID != testCase.ExpectedAccountID {
^
awsauth_test.go:411:85: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed account ID doesn't match with expected (%q != %q)", accountID, testCase.ExpectedAccountID)
^
awsauth_test.go:413:20: Using the variable on range scope `testCase` in function literal (scopelint)
if partition != testCase.ExpectedPartition {
^
awsauth_test.go:414:84: Using the variable on range scope `testCase` in function literal (scopelint)
t.Fatalf("Parsed partition doesn't match with expected (%q != %q)", partition, testCase.ExpectedPartition)
^
awserr_test.go:107:20: Using the variable on range scope `testCase` in function literal (scopelint)
got := IsAWSErr(testCase.Err, testCase.Code, testCase.Message)
^
awserr_test.go:109:14: Using the variable on range scope `testCase` in function literal (scopelint)
if got != testCase.Expected {
^
awserr_test.go:110:42: Using the variable on range scope `testCase` in function literal (scopelint)
t.Errorf("got %t, expected %t", got, testCase.Expected)
^
awserr_test.go:333:28: Using the variable on range scope `testCase` in function literal (scopelint)
got := IsAWSErrExtended(testCase.Err, testCase.Code, testCase.Message, testCase.ExtendedMessage)
^
awserr_test.go:335:14: Using the variable on range scope `testCase` in function literal (scopelint)
if got != testCase.Expected {
^
awserr_test.go:336:42: Using the variable on range scope `testCase` in function literal (scopelint)
t.Errorf("got %t, expected %t", got, testCase.Expected)
^
session_test.go:34:35: Using the variable on range scope `tc` in function literal (scopelint)
opts, err := GetSessionOptions(tc.config)
^
awsauth_test.go:735:20: `invalidAwsEnv` - `t` is unused (unparam)
func invalidAwsEnv(t *testing.T) func() {
^
mock.go:22:18: mnd: Magic number: 500, in <argument> detected (gomnd)
w.WriteHeader(500)
^
mock.go:46:17: mnd: Magic number: 400, in <argument> detected (gomnd)
w.WriteHeader(400)
^
mock.go:83:17: mnd: Magic number: 400, in <argument> detected (gomnd)
w.WriteHeader(400)
^
session.go:87:21: mnd: Magic number: 9, in <condition> detected (gomnd)
if r.RetryCount < 9 {
^
awsauth.go:241:19: mnd: Magic number: 100, in <operation> detected (gomnd)
client.Timeout = 100 * time.Millisecond
^
make: *** [lint] Error 1
```
anGie44
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (though can't say I'm tooo familiar with the list of added linters 😅 ) and linter/tests are passing as expected 👍
| func invalidAwsEnv(t *testing.T) func() { | ||
| func invalidAwsEnv() func() { | ||
| ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| w.WriteHeader(400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a general linter q: noticed this line wasn't caught by the linter like in mock.go, is this expected? thought maybe it was b/c it's embedded within another function or in general test cases are ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like https://github.com/tommy-muehle/go-mnd ignores test files by default. 👍 I'm not sure if there's a way to enable that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh i see makes sense, the config object is hardcoded
Community Note
Previously: