Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/provider: Fix and Enable errorlint Linter #15891

Open
bflad opened this issue Oct 28, 2020 · 2 comments
Open

tests/provider: Fix and Enable errorlint Linter #15891

bflad opened this issue Oct 28, 2020 · 2 comments
Assignees
Labels
linter Pertains to changes to or issues with the various linters. stale Old or inactive issues managed by automation, if no further action taken these will get closed. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Comments

@bflad
Copy link
Member

bflad commented Oct 28, 2020

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

golangci-lint version 1.32.0 introduced the errorlint linter, which by its own description:

go-errorlint is a source code linter for Go software that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.

It is a little more focused than the goerr113 linter, which is also in golangci-lint but is problematic from our perspective due to:

Also, any call of errors.New() and fmt.Errorf() methods are reported except the calls used to initialise package-level variables and the fmt.Errorf() calls wrapping the other errors.

We do this regularly as this project is not intended to be used as a library.

The errorlint linter can be temporarily enabled with golangci-lint run --enable errorlint ./aws.

Example Reports

aws/configservice.go:119:175: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
				return status, aws.StringValue(status.OrganizationRuleStatus), fmt.Errorf("unable to get Organization Config Rule detailed status for showing member account errors: %s", err)
				                                                                                                                                                                          ^
aws/data_source_aws_acm_certificate.go:94:55: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("Error listing certificates: %q", err)
		                                                    ^
aws/data_source_aws_acm_certificate.go:122:62: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
			return fmt.Errorf("Error describing ACM certificate: %q", err)
			                                                          ^
aws/data_source_aws_acm_certificate.go:177:80: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error listing tags for ACM Certificate (%s): %s", d.Id(), err)
		                                                                             ^
aws/data_source_aws_acm_certificate.go:181:47: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error setting tags: %s", err)
		                                            ^
aws/data_source_aws_acmpca_certificate_authority.go:109:71: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error reading ACMPCA Certificate Authority: %s", err)
		                                                                    ^
aws/data_source_aws_acmpca_certificate_authority.go:122:47: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error setting tags: %s", err)
		                                            ^
aws/data_source_aws_acmpca_certificate_authority.go:140:84: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
			return fmt.Errorf("error reading ACMPCA Certificate Authority Certificate: %s", err)
			                                                                                ^
aws/data_source_aws_acmpca_certificate_authority.go:159:99: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error reading ACMPCA Certificate Authority Certificate Signing Request: %s", err)
		                                                                                                ^
aws/data_source_aws_acmpca_certificate_authority.go:170:110: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error listing tags for ACMPCA Certificate Authority (%s): %s", certificateAuthorityArn, err)
		                                                                                                           ^
aws/data_source_aws_acmpca_certificate_authority.go:174:47: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error setting tags: %s", err)
		                                            ^
aws/data_source_aws_ami.go:301:47: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
		return fmt.Errorf("error setting tags: %s", err)
		                                            ^

Affected Resources

TBD

Definition of Done

  • Reports via golangci-lint run --enable errorlint ./aws are addressed
  • errorlint added to .golangci.yml
  • CI testing passes with linter enabled
@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. technical-debt Addresses areas of the codebase that need refactoring or redesign. linter Pertains to changes to or issues with the various linters. labels Oct 28, 2020
@gdavison gdavison self-assigned this Feb 6, 2021
@ewbankkit
Copy link
Contributor

We may want to wait until after #15090 is complete before tackling this one as CRUD handler functions will then return diag.Diagnostics, not error.

Copy link

github-actions bot commented May 5, 2024

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter Pertains to changes to or issues with the various linters. stale Old or inactive issues managed by automation, if no further action taken these will get closed. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

No branches or pull requests

3 participants