From c7fd9620aabd511c0d3a78eb6c2af74205e43aff Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar <mark.sagikazar@gmail.com> Date: Thu, 9 Jan 2025 15:29:22 +0100 Subject: [PATCH] chore: fix linter config and violations Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com> --- .golangci.yml | 23 +++++++++++++---------- connector/saml/saml.go | 2 +- server/introspectionhandler.go | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7d631ed2..d54dcb18 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,28 +1,27 @@ run: timeout: 4m - skip-dirs: - - storage/ent/db # generated ent code linters-settings: depguard: - rules: - deprecated: - deny: - - pkg: "io/ioutil" - desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead." + rules: + deprecated: + deny: + - pkg: "io/ioutil" + desc: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead." gci: - local-prefixes: github.com/dexidp/dex + sections: + - standard + - default + - prefix(github.com/dexidp/dex) goimports: local-prefixes: github.com/dexidp/dex - linters: disable-all: true enable: - depguard - dogsled - exhaustive - - exportloopref - gci - gochecknoinits - gocritic @@ -92,3 +91,7 @@ linters: # - nestif # - testpackage # - wsl + +issues: + exclude-dirs: + - storage/ent/db # generated ent code diff --git a/connector/saml/saml.go b/connector/saml/saml.go index bc8ef726..3e44b477 100644 --- a/connector/saml/saml.go +++ b/connector/saml/saml.go @@ -467,7 +467,7 @@ func (p *provider) validateStatus(status *status) error { if statusMessage != nil && statusMessage.Value != "" { errorMessage += " -> " + statusMessage.Value } - return fmt.Errorf(errorMessage) + return errors.New(errorMessage) } return nil } diff --git a/server/introspectionhandler.go b/server/introspectionhandler.go index ffcbb136..802e29b6 100644 --- a/server/introspectionhandler.go +++ b/server/introspectionhandler.go @@ -170,7 +170,7 @@ func (s *Server) getTokenFromRequest(r *http.Request) (string, TokenTypeEnum, er return "", 0, newIntrospectBadRequestError(fmt.Sprintf("HTTP method is \"%s\", expected \"POST\".", r.Method)) } else if err := r.ParseForm(); err != nil { return "", 0, newIntrospectBadRequestError("Unable to parse HTTP body, make sure to send a properly formatted form request body.") - } else if r.PostForm == nil || len(r.PostForm) == 0 { + } else if len(r.PostForm) == 0 { return "", 0, newIntrospectBadRequestError("The POST body can not be empty.") } else if !r.PostForm.Has("token") { return "", 0, newIntrospectBadRequestError("The POST body doesn't contain 'token' parameter.") -- GitLab