From 76d873554b44c15fe28b6b37d1c886d05d5e80d6 Mon Sep 17 00:00:00 2001 From: Keenan Nemetz Date: Wed, 6 Mar 2024 10:50:42 -0800 Subject: [PATCH] tools(i): Enable nilness linter (#2383) ## Relevant issue(s) Resolves #2382 ## Description This PR enables the `nilness` linter and fixes a few issues caught by it. ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? `make lint` Specify the platform(s) on which this was tested: - MacOS --- http/handler_lens.go | 4 ---- request/graphql/parser/request.go | 2 +- tools/configs/golangci.yaml | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/http/handler_lens.go b/http/handler_lens.go index cb69a691fe..532eaacefc 100644 --- a/http/handler_lens.go +++ b/http/handler_lens.go @@ -88,10 +88,6 @@ func (s *lensHandler) MigrateDown(rw http.ResponseWriter, req *http.Request) { responseJSON(rw, http.StatusBadRequest, errorResponse{err}) return } - if err != nil { - responseJSON(rw, http.StatusBadRequest, errorResponse{err}) - return - } var value []map[string]any err = enumerable.ForEach(result, func(item map[string]any) { value = append(value, item) diff --git a/request/graphql/parser/request.go b/request/graphql/parser/request.go index fca63bcac5..69d275de03 100644 --- a/request/graphql/parser/request.go +++ b/request/graphql/parser/request.go @@ -48,7 +48,7 @@ func ParseRequest(schema gql.Schema, doc *ast.Document) (*request.Request, []err } parsedDirectives, err := parseDirectives(astOpDef.Directives) - if errs != nil { + if err != nil { return nil, []error{err} } parsedQueryOpDef.Directives = parsedDirectives diff --git a/tools/configs/golangci.yaml b/tools/configs/golangci.yaml index 1b6b76aa37..e8fe63a1fc 100644 --- a/tools/configs/golangci.yaml +++ b/tools/configs/golangci.yaml @@ -287,6 +287,7 @@ linters-settings: # run `go tool vet help` to see all analyzers enable: - atomicalign + - nilness enable-all: false