simonmittag/jabba

View on GitHub

Showing 34 of 61 total issues

Avoid deeply nested control flow statements.
Confirmed

                    switch alg {
                    case jwa.RS256, jwa.RS384, jwa.RS512, jwa.PS256, jwa.PS384, jwa.PS512:
                        k := KidPair{
                            Kid: key.KeyID(),
                            Key: &rsa.PublicKey{
Severity: Major
Found in jwt.go - About 45 mins to fix

    Method Config.reApplyResourceURLDefaults has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
    Open

    func (config Config) reApplyResourceURLDefaults() *Config {
        const http = "http"
        const https = "https"
        const p80S = "80"
        const p443S = "443"
    Severity: Minor
    Found in config.go - About 45 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 Runtime.loadAcmeCertAndKeyFromCache has 7 return statements (exceeds 4 allowed).
    Confirmed

    func (runtime *Runtime) loadAcmeCertAndKeyFromCache(provider string) error {
        var e error
    
        if !runtime.cacheDirIsActive() {
            return errors.New("cache directory not active, cannot load TLS from cache")
    Severity: Major
    Found in acmehandler.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if len(atmpt.ContentEncoding) > 0 {
                      //only set this if it was present upstream, otherwise assume nothing and leave empty.
                      proxy.Dwn.Resp.ContentEncoding = atmpt.ContentEncoding
                  } else {
                      proxy.Dwn.Resp.ContentEncoding = EncIdentity
      Severity: Major
      Found in proxy.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if w[0] == STAR {
                        less = false
                    } else {
                        less = true
                    }
        Severity: Major
        Found in route.go - About 45 mins to fix

          Function upgradeWebsocket has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
          Confirmed

          func upgradeWebsocket(proxy *Proxy) {
              var status = make(chan WebsocketStatus)
              var tx *WebsocketTx = &WebsocketTx{}
          
              //dialer uses TLSInsecureSkipVerify to accept any certificate or host name.
          Severity: Minor
          Found in websockethandler.go - About 45 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

          Function validHostName has 7 return statements (exceeds 4 allowed).
          Open

          func validHostName(r ResourceMapping) error {
              invalidErr := errors.New(fmt.Sprintf("resource host needs a valid DNS name: %v", r.URL.Host))
              p := idna.New(
                  idna.ValidateLabels(true),
                  //this has to be off it disallows * for registration
          Severity: Major
          Found in config.go - About 45 mins to fix

            Method Jwt.UnmarshalJSON has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

            func (j *Jwt) UnmarshalJSON(data []byte) error {
                var value interface{}
                if err := json.Unmarshal(data, &value); err != nil {
                    return err
                }
            Severity: Minor
            Found in jwt.go - About 45 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

            Avoid deeply nested control flow statements.
            Open

                        } else if proxy.hasUpstreamAttemptAborted() {
                            sendStatusCodeAsJSON(proxy.respondWith(504, gatewayTimeoutTriggeredByUpstreamEvent))
                        } else {
                            sendStatusCodeAsJSON(proxy.respondWith(502, badGatewayTriggeredUnableToProcessUpstreamResponse))
                        }
            Severity: Major
            Found in proxyhandler.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                  } else if star == r.RequestURI && options == strings.ToUpper(r.Method) {
                      globalOptionsHandler(w, r)
                  } else {
                      httpHandler(w, r)
                  }
              Severity: Major
              Found in server.go - About 45 mins to fix

                Method Runtime.fetchAcmeCertAndKey has 6 return statements (exceeds 4 allowed).
                Confirmed

                func (runtime *Runtime) fetchAcmeCertAndKey(url string) error {
                    var e error
                
                    defer func() {
                        if r := recover(); r != nil {
                Severity: Major
                Found in acmehandler.go - About 40 mins to fix

                  Function checkFullCertChain has 6 return statements (exceeds 4 allowed).
                  Confirmed

                  func checkFullCertChain(chain *tls.Certificate) ([]TlsLink, error) {
                      if len(chain.Certificate) == 0 {
                          return nil, errors.New("no certificate data found")
                      }
                  
                  
                  Severity: Major
                  Found in tls.go - About 40 mins to fix

                    Method ContentEncoding.matches has 5 return statements (exceeds 4 allowed).
                    Open

                    func (c ContentEncoding) matches(encoding ContentEncoding) bool {
                        if len(c) == 0 && encoding == EncIdentity {
                            return true
                        } else if len(string(encoding)) == 0 {
                            return false
                    Severity: Major
                    Found in proxy.go - About 35 mins to fix

                      Method Runtime.cacheAcmeCertAndKey has 5 return statements (exceeds 4 allowed).
                      Confirmed

                      func (runtime *Runtime) cacheAcmeCertAndKey(provider string) error {
                          var e error
                      
                          if !runtime.cacheDirIsActive() {
                              return errors.New("cache directory not active, cannot cache keys")
                      Severity: Major
                      Found in acmehandler.go - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language