oapi-codegen
oapi-codegen copied to clipboard
ci: enable more linters and fix issues
Enable more linters for golangci-lint and fix the issues that the additional linters highlight.
This addresses:
- Missing error checks.
- Duplicate code.
- Direct error comparison instead of
errors.Asorerrors.Is. - Missing error wrapping.
- Test helpers.
- Document comments.
- Missing http
Request.Body.Close() - Switches instead of complex ifs.
- Use
strings.ReplaceAllinstead ofstrings.Replacewith -1. - Unnecessary blank lines.
- Duplicate literal strings.
- Unneeded casts.
- Removed inits.
- Preallocate slices.
- Unused parameters and vars.
- Invalid error return when using time fallback case.
Also:
- Merge ci steps into one so it runs quicker.
- Add go 1.19 (latest) to validation.
@53jk1 do you want me to rebase to resolve conflicts?
@stevenh I think rebase would be good
@53jk1 done
Thanks and sorry we didn't get around to accepting this. We've added some of the changes. If there are any linter rules that you think are worthwhile, please raise an issue and we can work out how best to decide when we want to add them (https://github.com/deepmap/oapi-codegen/issues/1587)