ory-am/hydra

View on GitHub
internal/httpclient/client.go

Summary

Maintainability
F
3 days
Test Coverage

Method APIClient.prepareRequest has a Cognitive Complexity of 66 (exceeds 20 allowed). Consider refactoring.
Open

func (c *APIClient) prepareRequest(
    ctx context.Context,
    path string, method string,
    postBody interface{},
    headerParams map[string]string,
Severity: Minor
Found in internal/httpclient/client.go - About 7 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 APIClient.prepareRequest has 112 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (c *APIClient) prepareRequest(
    ctx context.Context,
    path string, method string,
    postBody interface{},
    headerParams map[string]string,
Severity: Major
Found in internal/httpclient/client.go - About 3 hrs to fix

    File client.go has 546 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    /*
    Ory Hydra API
    
    Documentation for all of Ory Hydra's APIs.
    
    
    Severity: Minor
    Found in internal/httpclient/client.go - About 3 hrs to fix

      Function parameterAddToHeaderOrQuery has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
      Open

      func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
          var v = reflect.ValueOf(obj)
          var value = ""
          if v == reflect.ValueOf(nil) {
              value = "null"
      Severity: Minor
      Found in internal/httpclient/client.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 parameterAddToHeaderOrQuery has 77 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
          var v = reflect.ValueOf(obj)
          var value = ""
          if v == reflect.ValueOf(nil) {
              value = "null"
      Severity: Major
      Found in internal/httpclient/client.go - About 2 hrs to fix

        Method APIClient.decode has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
        Open

        func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
            if len(b) == 0 {
                return nil
            }
            if s, ok := v.(*string); ok {
        Severity: Minor
        Found in internal/httpclient/client.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 APIClient.decode has 15 return statements (exceeds 4 allowed).
        Open

        func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
            if len(b) == 0 {
                return nil
            }
            if s, ok := v.(*string); ok {
        Severity: Major
        Found in internal/httpclient/client.go - About 1 hr to fix

          Method APIClient.prepareRequest has 11 return statements (exceeds 4 allowed).
          Open

          func (c *APIClient) prepareRequest(
              ctx context.Context,
              path string, method string,
              postBody interface{},
              headerParams map[string]string,
          Severity: Major
          Found in internal/httpclient/client.go - About 1 hr to fix

            Method APIClient.decode has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) {
                if len(b) == 0 {
                    return nil
                }
                if s, ok := v.(*string); ok {
            Severity: Minor
            Found in internal/httpclient/client.go - About 1 hr to fix

              Method APIClient.prepareRequest has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  ctx context.Context,
                  path string, method string,
                  postBody interface{},
                  headerParams map[string]string,
                  queryParams url.Values,
              Severity: Major
              Found in internal/httpclient/client.go - About 1 hr to fix

                Function parameterAddToHeaderOrQuery has 8 return statements (exceeds 4 allowed).
                Open

                func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
                    var v = reflect.ValueOf(obj)
                    var value = ""
                    if v == reflect.ValueOf(nil) {
                        value = "null"
                Severity: Major
                Found in internal/httpclient/client.go - About 50 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                      } else if s, ok := body.(*string); ok {
                          _, err = bodyBuf.WriteString(*s)
                      } else if JsonCheck.MatchString(contentType) {
                          err = json.NewEncoder(bodyBuf).Encode(body)
                      } else if XmlCheck.MatchString(contentType) {
                  Severity: Major
                  Found in internal/httpclient/client.go - About 45 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status