oauth2-proxy/oauth2-proxy

View on GitHub
oauthproxy.go

Summary

Maintainability
F
3 days
Test Coverage
C
76%

File oauthproxy.go has 992 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "context"
    "embed"
Severity: Major
Found in oauthproxy.go - About 1 day to fix

    OAuthProxy has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type OAuthProxy struct {
        CookieOptions *options.Cookie
        Validator     func(string) bool
    
        SignInPath string
    Severity: Minor
    Found in oauthproxy.go - About 3 hrs to fix

      Function NewOAuthProxy has 116 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
          sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
          if err != nil {
              return nil, fmt.Errorf("error initialising session store: %v", err)
          }
      Severity: Major
      Found in oauthproxy.go - About 3 hrs to fix

        Method OAuthProxy.OAuthCallback has 70 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
            remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
        
            // finish the oauth cycle
            err := req.ParseForm()
        Severity: Minor
        Found in oauthproxy.go - About 1 hr to fix

          Function NewOAuthProxy has 12 return statements (exceeds 4 allowed).
          Open

          func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
              sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
              if err != nil {
                  return nil, fmt.Errorf("error initialising session store: %v", err)
              }
          Severity: Major
          Found in oauthproxy.go - About 1 hr to fix

            Method OAuthProxy.OAuthCallback has 9 return statements (exceeds 4 allowed).
            Open

            func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
                remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
            
                // finish the oauth cycle
                err := req.ParseForm()
            Severity: Major
            Found in oauthproxy.go - About 55 mins to fix

              Method OAuthProxy.ErrorPage has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (p *OAuthProxy) ErrorPage(rw http.ResponseWriter, req *http.Request, code int, appError string, messages ...interface{}) {
              Severity: Minor
              Found in oauthproxy.go - About 35 mins to fix

                Function NewOAuthProxy has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                Open

                func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
                    sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
                    if err != nil {
                        return nil, fmt.Errorf("error initialising session store: %v", err)
                    }
                Severity: Minor
                Found in oauthproxy.go - About 35 mins to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Method OAuthProxy.doOAuthStart has 5 return statements (exceeds 4 allowed).
                Open

                func (p *OAuthProxy) doOAuthStart(rw http.ResponseWriter, req *http.Request, overrides url.Values) {
                    extraParams := p.provider.Data().LoginURLParams(overrides)
                    prepareNoCache(rw)
                
                    var (
                Severity: Major
                Found in oauthproxy.go - About 35 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status