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

Lint: enable unparam and fix up issues #1481

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Mar 4, 2024

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

@alexandear alexandear force-pushed the fix-unparam-lint branch 5 times, most recently from d17ec28 to db94e43 Compare March 4, 2024 11:33
@alexandear alexandear force-pushed the fix-unparam-lint branch 2 times, most recently from 8e25127 to b284c7b Compare March 13, 2024 13:51
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

1 participant