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)
- Read upRead up
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
- Read upRead up
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)
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
- Read upRead up
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
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) {
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)
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) {
FIXME found Wontfix
// FIXME: cnsiRequest.Status info is lost for failures, only get a status code
- Exclude checks
TODO found Wontfix
// TODO: This should be used by the function above
- Exclude checks