simonmittag/jabba

View on GitHub

Showing 34 of 61 total issues

Method Jwt.LoadJwks has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Confirmed

func (jwt *Jwt) LoadJwks() error {
    var err error

    //acquires the lock with true else skips
    if jwt.lock.TryAcquire(1) {
Severity: Minor
Found in jwt.go - About 3 hrs 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 Jwt.Validate has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
Confirmed

func (jwt *Jwt) Validate() error {
    var err error
    alg := *new(jwa.SignatureAlgorithm)
    err = alg.Accept(jwt.Alg)

Severity: Minor
Found in jwt.go - About 3 hrs 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 Config.validateAcmeConfig has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
Confirmed

func (config Config) validateAcmeConfig() *Config {
    acmeProvider := len(config.Connection.Downstream.Tls.Acme.Provider) > 0
    acmeDomain := len(config.Connection.Downstream.Tls.Acme.Domains) > 0 && len(config.Connection.Downstream.Tls.Acme.Domains[0]) > 0
    acmeEmail := len(config.Connection.Downstream.Tls.Acme.Email) > 0

Severity: Minor
Found in config.go - About 3 hrs 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 parseUpstreamResponse has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Confirmed

func parseUpstreamResponse(upstreamResponse *http.Response, proxy *Proxy) ([]byte, error) {
    var upstreamResponseBody []byte
    var bodyError error

    //get a reference to this before any race conditions may occur
Severity: Minor
Found in proxyhandler.go - About 3 hrs 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

Config has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

type Config struct {
    Policies            map[string]Policy
    Routes              Routes
    Jwt                 map[string]*Jwt
    Resources           map[string][]ResourceMapping
Severity: Minor
Found in config.go - About 2 hrs to fix

    Function parseUpstreamResponse has 86 lines of code (exceeds 50 allowed). Consider refactoring.
    Confirmed

    func parseUpstreamResponse(upstreamResponse *http.Response, proxy *Proxy) ([]byte, error) {
        var upstreamResponseBody []byte
        var bodyError error
    
        //get a reference to this before any race conditions may occur
    Severity: Major
    Found in proxyhandler.go - About 2 hrs to fix

      File config.go has 511 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package j8a
      
      import (
          "bytes"
          "encoding/json"
      Severity: Minor
      Found in config.go - About 2 hrs to fix

        Method Jwt.LoadJwks has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Confirmed

        func (jwt *Jwt) LoadJwks() error {
            var err error
        
            //acquires the lock with true else skips
            if jwt.lock.TryAcquire(1) {
        Severity: Minor
        Found in jwt.go - About 2 hrs to fix

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

          func (config Config) validateRoutes() *Config {
              for i, _ := range config.Routes {
                  v, e := config.Routes[i].validPath()
                  if !v {
                      config.panic(e.Error())
          Severity: Minor
          Found in config.go - About 1 hr 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.CountUpConns has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
          Open

          func (rt *Runtime) CountUpConns(proc *process.Process, cs procspy.ConnIter, ips map[string][]net.IP) int {
              d := 0
          UpConn:
              for c := cs.Next(); c != nil; c = cs.Next() {
                  if c.PID == uint(proc.Pid) {
          Severity: Minor
          Found in stats.go - About 1 hr 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 Jwt.Validate has 68 lines of code (exceeds 50 allowed). Consider refactoring.
          Confirmed

          func (jwt *Jwt) Validate() error {
              var err error
              alg := *new(jwa.SignatureAlgorithm)
              err = alg.Accept(jwt.Alg)
          
          
          Severity: Minor
          Found in jwt.go - About 1 hr to fix

            Function performUpstreamRequest has 57 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func performUpstreamRequest(proxy *Proxy) (*http.Response, error) {
                //get a reference to this before any race conditions may occur
                attemptIndex := proxy.Up.Count - 1
                req := scaffoldUpstreamRequest(proxy)
                var upstreamResponse *http.Response
            Severity: Minor
            Found in proxyhandler.go - About 1 hr to fix

              Method Proxy.parseRequestBody has 53 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (proxy *Proxy) parseRequestBody(request *http.Request) {
                  //content length 0, do not read just go back
                  if request.ContentLength == 0 {
                      infoOrTraceEv(proxy).
                          Int64(dwnElpsdMicros, time.Since(proxy.Dwn.startDate).Microseconds()).
              Severity: Minor
              Found in proxy.go - About 1 hr to fix

                Method Config.validateAcmeConfig has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (config Config) validateAcmeConfig() *Config {
                    acmeProvider := len(config.Connection.Downstream.Tls.Acme.Provider) > 0
                    acmeDomain := len(config.Connection.Downstream.Tls.Acme.Domains) > 0 && len(config.Connection.Downstream.Tls.Acme.Domains[0]) > 0
                    acmeEmail := len(config.Connection.Downstream.Tls.Acme.Email) > 0
                
                
                Severity: Minor
                Found in config.go - About 1 hr to fix

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

                  func (config Config) validateResources() *Config {
                      for name := range config.Resources {
                          resourceMappings := config.Resources[name]
                          if len(resourceMappings) == 0 {
                              config.panic(fmt.Sprintf("resource '%v' needs to have at least one url, see https://j8a.io/docs", name))
                  Severity: Minor
                  Found in config.go - About 1 hr 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 Route.validHostPattern has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (route *Route) validHostPattern() (bool, error) {
                      //first check the name is a valid idna name.
                      p := idna.New(
                          idna.ValidateLabels(true),
                          //this has to be off it disallows * for registration
                  Severity: Minor
                  Found in route.go - About 55 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 PerformJ8aTest has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Confirmed

                  func PerformJ8aTest(t *testing.T, testMethod string, wantUpstreamWaitSeconds int, wantTotalWaitSeconds int, wantStatusCode int, serverPort int, tlsMode bool) {
                  Severity: Major
                  Found in integration/test_utils.go - About 50 mins to fix

                    Method Route.validHostPattern has 8 return statements (exceeds 4 allowed).
                    Open

                    func (route *Route) validHostPattern() (bool, error) {
                        //first check the name is a valid idna name.
                        p := idna.New(
                            idna.ValidateLabels(true),
                            //this has to be off it disallows * for registration
                    Severity: Major
                    Found in route.go - About 50 mins to fix

                      Method Route.validPath has 8 return statements (exceeds 4 allowed).
                      Open

                      func (route *Route) validPath() (bool, error) {
                          const fakeHost = "http://127.0.0.1"
                          defaultError := errors.New(fmt.Sprintf("route %v not a valid URL path", route.Path))
                      
                          _, err := url.ParseRequestURI(fakeHost + route.Path)
                      Severity: Major
                      Found in route.go - About 50 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

                        Severity
                        Category
                        Status
                        Source
                        Language