oapi-codegen
oapi-codegen copied to clipboard
Lint: enable `unparam` and fix up issues
The PR enables unparam linter and addresses lint issues. The linter has identified a significant amount of unused code that can be easily deleted without affecting functionality.
The whole log of running golangci-lint:
❯ make lint
git ls-files go.mod '**/*go.mod' -z | xargs -0 -I{} bash -xc 'cd $(dirname {}) && /Users/Oleksandr_Redko/src/github.com/deepmap/oapi-codegen/bin/golangci-lint run --enable=unparam ./...'
++ dirname examples/go.mod
+ cd examples
+ /Users/Oleksandr_Redko/src/github.com/deepmap/oapi-codegen/bin/golangci-lint run --enable=unparam ./...
petstore-expanded/iris/petstore.go:19:47: `NewIrisPetServer` - `port` is unused (unparam)
func NewIrisPetServer(petStore *api.PetStore, port int) *iris.Application {
^
++ dirname go.mod
+ cd .
+ /Users/Oleksandr_Redko/src/github.com/deepmap/oapi-codegen/bin/golangci-lint run --enable=unparam ./...
pkg/securityprovider/securityprovider.go:74:18: `NewSecurityProviderApiKey$1` - `ctx` is unused (unparam)
"cookie": func(ctx context.Context, req *http.Request) error {
^
pkg/securityprovider/securityprovider.go:78:18: `NewSecurityProviderApiKey$2` - `ctx` is unused (unparam)
"header": func(ctx context.Context, req *http.Request) error {
^
pkg/securityprovider/securityprovider.go:82:17: `NewSecurityProviderApiKey$3` - `ctx` is unused (unparam)
"query": func(ctx context.Context, req *http.Request) error {
^
pkg/codegen/prune.go:24:76: walkSwagger - result 0 (error) is always nil (unparam)
func walkSwagger(swagger *openapi3.T, doFn func(RefWrapper) (bool, error)) error {
^
pkg/codegen/prune.go:43:81: walkOperation - result 0 (error) is always nil (unparam)
func walkOperation(op *openapi3.Operation, doFn func(RefWrapper) (bool, error)) error {
^
pkg/codegen/prune.go:68:91: walkComponents - result 0 (error) is always nil (unparam)
func walkComponents(components *openapi3.Components, doFn func(RefWrapper) (bool, error)) error {
^
pkg/codegen/template_helpers.go:273:33: `getConditionOfResponseName` - `statusCodeVar` always receives `"rsp.StatusCode"` (unparam)
func getConditionOfResponseName(statusCodeVar, responseName string) string {
^
++ dirname internal/test/go.mod
+ cd internal/test
+ /Users/Oleksandr_Redko/src/github.com/deepmap/oapi-codegen/bin/golangci-lint run --enable=unparam ./...
parameters/parameters_test.go:520:44: `doRequest` - `code` always receives `http.StatusOK` (`200`) (unparam)
func doRequest(t *testing.T, e *echo.Echo, code int, req *http.Request) *httptest.ResponseRecorder {
^
make: *** [Makefile:19: lint] Error 1