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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task: enable thelper and errorlint #225

Merged
merged 1 commit into from Jun 24, 2021
Merged

task: enable thelper and errorlint #225

merged 1 commit into from Jun 24, 2021

Conversation

gssbzn
Copy link
Collaborator

@gssbzn gssbzn commented Jun 24, 2021

Description

Enables thelper, this linter makes sure that test helper functions call t.Helper

Enables errorlint, making sure error handling follow go1.13 error handling best practices

@gssbzn gssbzn requested a review from a team as a code owner June 24, 2021 09:53
@gssbzn gssbzn requested review from andreaangiolillo and removed request for a team June 24, 2021 09:53
@@ -169,24 +169,6 @@ type ListOptions struct {
ItemsPerPage int `url:"itemsPerPage,omitempty"`
}

// ErrorResponse reports the error caused by an API request.
type ErrorResponse struct {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved closer to the implementation of Error

@@ -222,7 +204,7 @@ func (resp *Response) CurrentPage() (int, error) {

pageNum, err := strconv.Atoi(pageNumStr)
if err != nil {
return 0, fmt.Errorf("error getting current page: %s", err)
return 0, fmt.Errorf("error getting current page: %w", err)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w is a go1.13 wrapper for errors which allows error.Is to map wrapped errors

Comment on lines +63 to +73
- bodyclose # checks whether HTTP response body is closed successfully [fast: false, auto-fix: false]
- deadcode # Finds unused code [fast: false, auto-fix: false]
- depguard # Go linter that checks if package imports are in a list of acceptable packages [fast: false, auto-fix: false]
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false]
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false]
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13. [fast: false, auto-fix: false]
- exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false]
- exportloopref # checks for pointers to enclosing loop variables [fast: false, auto-fix: false]
- gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
- gocritic # Provides many diagnostics that check for bugs, performance and style issues. [fast: false, auto-fix: false]
- gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding the description for each linter!

Copy link

@threebee threebee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gssbzn gssbzn merged commit 8086475 into master Jun 24, 2021
@gssbzn gssbzn deleted the enable-more-lint branch June 24, 2021 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants