-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[PROPOSAL] Switch from gometalinter to golangci-lint #7457
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previous output from linting: ``` aws/config_test.go:49:15: Error return value of `buf.ReadFrom` is not checked (errcheck) buf.ReadFrom(r.Body) ^ aws/resource_aws_budgets_budget_test.go:331:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, budgetConfig) ^ aws/resource_aws_budgets_budget_test.go:351:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, budgetConfig) ^ aws/resource_aws_budgets_budget_test.go:377:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, budgetConfig) ^ aws/resource_aws_budgets_budget_test.go:397:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, budgetConfig) ^ aws/resource_aws_budgets_budget_test.go:423:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, budgetConfig) ^ aws/resource_aws_ecs_task_definition_test.go:438:32: Error return value of `conn.DeregisterTaskDefinition` is not checked (errcheck) conn.DeregisterTaskDefinition(&ecs.DeregisterTaskDefinitionInput{ ^ aws/resource_aws_iam_access_key.go:172:9: Error return value of `h.Write` is not checked (errcheck) h.Write(message) ^ aws/resource_aws_lambda_function_test.go:472:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:917:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:929:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:973:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:985:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, updatedZipFile) ^ aws/resource_aws_lambda_function_test.go:1023:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:1036:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:1075:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:1088:31: Error return value of `testAccCreateZipFromFiles` is not checked (errcheck) testAccCreateZipFromFiles(map[string]string{"test-fixtures/lambda_func_modified.js": "lambda.js"}, zipFile) ^ aws/resource_aws_lambda_function_test.go:1488:18: Error return value of `zipFile.Truncate` is not checked (errcheck) zipFile.Truncate(0) ^ aws/resource_aws_lambda_function_test.go:1489:14: Error return value of `zipFile.Seek` is not checked (errcheck) zipFile.Seek(0, 0) ^ aws/resource_aws_s3_bucket_test.go:2085:11: Error return value of `t.Execute` is not checked (errcheck) t.Execute(&doc, struct{ GUID int }{GUID: randInt}) ^ ```
Previous output from linting: ``` aws/resource_aws_autoscaling_group.go:515:49: `Identifer` is a misspelling of `Identifier` (misspell) // Availability Zones are optional if VPC Zone Identifer(s) are specified ^ aws/resource_aws_route53_record.go:265:10: `resouce` is a misspelling of `resource` (misspell) // for resouce update here we simply fall through to ^ aws/resource_aws_db_instance_test.go:1289:56: `identifer` is a misspelling of `identifier` (misspell) // This acceptance test explicitly tests when snapshot_identifer is set, ^ aws/resource_aws_rds_cluster_test.go:1263:56: `identifer` is a misspelling of `identifier` (misspell) // This acceptance test explicitly tests when snapshot_identifer is set, ^ ```
Previous output from linting: ``` aws/resource_aws_iam_user_test.go:639:85: unnecessary conversion (unconvert) authenticationCode1, err := totp.GenerateCode(secret, time.Now().Add(time.Duration(-30*time.Second))) ^ ```
Our TravisCI implementation with [`gometalinter`](https://github.com/alecthomas/gometalinter) has been a successful experiment in utilizing the various Go community linting tools to help improve the codebase quality and prevent common pull request review items. Recently though, we have consistently been having performance and functionality issues, especially after the switch from `govendor` to Go modules. Errantly failing TravisCI runs due to the linting timeouts distracts from useful review and feedback. Certain linting issues also appear to be missing occassionally from the output. The choice of `gometalinter` at the time of the initial implementation was based purely on `gometalinter` having a well established base and [`golangci-lint`](https://github.com/golangci/golangci-lint) being new to the scene. Since then, `golangci-lint` has grown in usage and appears to reflect Go language/tooling updates in a timely manner. It seems to work out of the box with our Go modules setup outside the `GOPATH`. While the Terraform AWS Provider and the Terraform Azure* Providers have been leading the experimentation with Go linting among actively maintained HashiCorp Terraform Providers, there are no currently defined Terraform provider development standards for code quality based on specific tooling. Given this, we should feel free to swap the implementation either temporarily to workaround the current issues or more permanently should it make sense. By example, here is the performance improvement for me locally when working outside the `GOPATH` (2.8 GHz Intel Core i7): ```console # gometalinter $ time make lint ==> Checking source code against linters... make lint 412.87s user 371.90s system 476% cpu 2:44.75 total # golangci-lint $ time make lint ==> Checking source code against linters... make lint 74.04s user 7.21s system 355% cpu 22.842 total ```
bflad
added
proposal
Proposes new design or functionality.
tests
PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
provider
Pertains to the provider itself, rather than any interaction with AWS.
hashibot/ignore
labels
Feb 6, 2019
paultyng
approved these changes
Feb 6, 2019
I'm going to re-run all the failed TravisCI jobs I can find. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our TravisCI implementation with
gometalinter
has been a successful experiment in utilizing the various Go community linting tools to help improve the codebase quality and prevent common pull request review items. Recently though, we have consistently been having performance and functionality issues, especially after the switch fromgovendor
to Go modules. Errantly failing TravisCI runs due to the linting timeouts distracts from useful review and feedback. Certain linting issues also appear to be missing occassionally from the output.The choice of
gometalinter
at the time of the initial implementation was based purely ongometalinter
having a well established base andgolangci-lint
being new to the scene. Since then,golangci-lint
has grown in usage and appears to reflect Go language/tooling updates in a timely manner. It seems to work out of the box with our Go modules setup outside theGOPATH
.While the Terraform AWS Provider and the Terraform Azure* Providers have been leading the experimentation with Go linting among actively maintained HashiCorp Terraform Providers, there are no currently defined Terraform provider development standards for code quality based on specific tooling. Given this, we should feel free to swap the implementation either temporarily to workaround the current issues or more permanently should it make sense.
By example, here is the performance improvement for me locally when working outside the
GOPATH
(2.8 GHz Intel Core i7):The previous commits in this pull request fix new linting issues found from the updated linters in
golangci-lint
. They can be cherry-picked into the codebase outside the lint tooling changes as necessary.