MitocGroup/deep-framework

View on GitHub
src/deep-resource/lib/Resource/Request.js

Summary

Maintainability
F
3 days
Test Coverage

File Request.js has 618 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Created by AlexanderC on 6/10/15.
 */

'use strict';
Severity: Major
Found in src/deep-resource/lib/Resource/Request.js - About 1 day to fix

    Request has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Request {
      /**
       * @param {Action} action
       * @param {Object} payload
       * @param {String} method
    Severity: Major
    Found in src/deep-resource/lib/Resource/Request.js - About 1 day to fix

      Function _createAws4SignedRequest has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _createAws4SignedRequest(url, httpMethod, payload, headers, callback) {
          let parsedUrl = urlParse(url, qs);
          let apiHost = parsedUrl.hostname;
          let apiPath = parsedUrl.pathname ? parsedUrl.pathname : '/';
      
      
      Severity: Major
      Found in src/deep-resource/lib/Resource/Request.js - About 2 hrs to fix

        Function _send has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _send(callback = () => {}) {
            let logService = this.action.resource.log;
            let requestEvent = {
              service: 'deep-resource',
              resourceType: 'Browser',
        Severity: Major
        Found in src/deep-resource/lib/Resource/Request.js - About 2 hrs to fix

          Function _send has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            _send(callback = () => {}) {
              let logService = this.action.resource.log;
              let requestEvent = {
                service: 'deep-resource',
                resourceType: 'Browser',
          Severity: Minor
          Found in src/deep-resource/lib/Resource/Request.js - 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

          Function _sendThroughApi has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _sendThroughApi(callback = () => {}) {
              let endpoint = this.action.source.api;
              let headers = {};
          
              let sendRequestFunc = (request) => {
          Severity: Minor
          Found in src/deep-resource/lib/Resource/Request.js - About 1 hr to fix

            Function _loadResponseFromCache has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _loadResponseFromCache(driver, key, callback) {
                driver.has(key, (err, has) => {
                  if(err) {
                    callback(new CachedRequestException(`Error to check if has in cache key ${key}`));
                    return;
            Severity: Minor
            Found in src/deep-resource/lib/Resource/Request.js - About 1 hr to fix

              Function _createAws4SignedRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                _createAws4SignedRequest(url, httpMethod, payload, headers, callback) {
                  let parsedUrl = urlParse(url, qs);
                  let apiHost = parsedUrl.hostname;
                  let apiPath = parsedUrl.pathname ? parsedUrl.pathname : '/';
              
              
              Severity: Minor
              Found in src/deep-resource/lib/Resource/Request.js - 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

              Function _saveResponseToCache has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _saveResponseToCache(response, callback = () => {}) {
                  if (!this.isCached || this.async || (this.cacheTtl === Request.TTL_INVALIDATE) || response.isError) {
                    callback(null, response);
                    return;
                  }
              Severity: Minor
              Found in src/deep-resource/lib/Resource/Request.js - About 1 hr to fix

                Function _loadSecurityCredentials has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  _loadSecurityCredentials(callback) {
                    let securityService = this._action.resource.security;
                
                    if (!securityService) {
                      callback(new MissingSecurityServiceException(), null);
                Severity: Minor
                Found in src/deep-resource/lib/Resource/Request.js - About 25 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

                There are no issues that match your filters.

                Category
                Status