cloudfoundry/stratos

View on GitHub
src/jetstream/passthrough.go

Summary

Maintainability
C
1 day
Test Coverage

Method portalProxy.ProxyRequest has a Cognitive Complexity of 37 (exceeds 8 allowed). Consider refactoring.
Open

func (p *portalProxy) ProxyRequest(c echo.Context, uri *url.URL) (map[string]*interfaces.CNSIRequest, error) {
    log.Debug("ProxyRequest")
    cnsiList := strings.Split(c.Request().Header.Get("x-cap-cnsi-list"), ",")
    shouldPassthrough := "true" == c.Request().Header.Get("x-cap-passthrough")
    longRunning := "true" == c.Request().Header.Get(longRunningTimeoutHeader)
Severity: Minor
Found in src/jetstream/passthrough.go - About 5 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 portalProxy.doRequest has a Cognitive Complexity of 20 (exceeds 8 allowed). Consider refactoring.
Open

func (p *portalProxy) doRequest(cnsiRequest *interfaces.CNSIRequest, done chan<- *interfaces.CNSIRequest) {
    log.Debugf("doRequest for URL: %s", cnsiRequest.URL.String())
    var body io.Reader
    var res *http.Response
    var req *http.Request
Severity: Minor
Found in src/jetstream/passthrough.go - About 2 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 portalProxy.ProxyRequest has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Wontfix

func (p *portalProxy) ProxyRequest(c echo.Context, uri *url.URL) (map[string]*interfaces.CNSIRequest, error) {
    log.Debug("ProxyRequest")
    cnsiList := strings.Split(c.Request().Header.Get("x-cap-cnsi-list"), ",")
    shouldPassthrough := "true" == c.Request().Header.Get("x-cap-passthrough")
    longRunning := "true" == c.Request().Header.Get(longRunningTimeoutHeader)
Severity: Major
Found in src/jetstream/passthrough.go - About 2 hrs to fix

    Function buildJSONResponse has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
    Open

    func buildJSONResponse(cnsiList []string, responses map[string]*interfaces.CNSIRequest) map[string]*json.RawMessage {
        log.Debug("buildJSONResponse")
        jsonResponse := make(map[string]*json.RawMessage)
        for _, guid := range cnsiList {
            var response []byte
    Severity: Minor
    Found in src/jetstream/passthrough.go - About 2 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 portalProxy.doRequest has 67 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *portalProxy) doRequest(cnsiRequest *interfaces.CNSIRequest, done chan<- *interfaces.CNSIRequest) {
        log.Debugf("doRequest for URL: %s", cnsiRequest.URL.String())
        var body io.Reader
        var res *http.Response
        var req *http.Request
    Severity: Minor
    Found in src/jetstream/passthrough.go - About 1 hr to fix

      Method portalProxy.buildCNSIRequest has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func (p *portalProxy) buildCNSIRequest(cnsiGUID string, userGUID string, method string, uri *url.URL, body []byte, header http.Header) (interfaces.CNSIRequest, error) {
      Severity: Minor
      Found in src/jetstream/passthrough.go - About 45 mins to fix

        Method portalProxy.ProxyRequest has 7 return statements (exceeds 4 allowed).
        Open

        func (p *portalProxy) ProxyRequest(c echo.Context, uri *url.URL) (map[string]*interfaces.CNSIRequest, error) {
            log.Debug("ProxyRequest")
            cnsiList := strings.Split(c.Request().Header.Get("x-cap-cnsi-list"), ",")
            shouldPassthrough := "true" == c.Request().Header.Get("x-cap-passthrough")
            longRunning := "true" == c.Request().Header.Get(longRunningTimeoutHeader)
        Severity: Major
        Found in src/jetstream/passthrough.go - About 45 mins to fix

          Method portalProxy.DoProxySingleRequestWithToken has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Wontfix

          func (p *portalProxy) DoProxySingleRequestWithToken(cnsiGUID string, token *interfaces.TokenRecord, method, requestURL string, headers http.Header, body []byte) (*interfaces.CNSIRequest, error) {
          Severity: Minor
          Found in src/jetstream/passthrough.go - About 35 mins to fix

            FIXME found
            Wontfix

                // FIXME: cnsiRequest.Status info is lost for failures, only get a status code
            Severity: Minor
            Found in src/jetstream/passthrough.go by fixme

            TODO found
            Wontfix

            // TODO: This should be used by the function above
            Severity: Minor
            Found in src/jetstream/passthrough.go by fixme

            There are no issues that match your filters.

            Category
            Status