lyfeyaj/poplar

View on GitHub

Showing 45 of 53 total issues

Function buildArgs has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

HttpContext.prototype.buildArgs = function(method) {
  var args = {};
  var ctx = this;
  var accepts = method.accepts;

Severity: Minor
Found in lib/contexts/http.js - 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

File api_method.js has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * Expose `ApiMethod`.
 */
module.exports = ApiMethod;

Severity: Minor
Found in lib/api_method.js - About 5 hrs to fix

    File http.js has 343 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * Expose `HttpContext`.
     */
    module.exports = HttpContext;
    
    
    Severity: Minor
    Found in lib/contexts/http.js - About 4 hrs to fix

      Function Validate has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      function Validate(params, accepts) {
      
        var validationError = new ValidationError();
        params = params || {};
        accepts = accepts || [];
      Severity: Minor
      Found in lib/validation.js - 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 invoke has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      ApiMethod.prototype.invoke = function(ctx, cb) {
        var args = ctx.args;
        var options = util._extend({}, ctx.options);
      
        var returns = this.returns;
      Severity: Minor
      Found in lib/api_method.js - 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 invoke has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ApiMethod.prototype.invoke = function(ctx, cb) {
        var args = ctx.args;
        var options = util._extend({}, ctx.options);
      
        var returns = this.returns;
      Severity: Major
      Found in lib/api_method.js - About 3 hrs to fix

        Function buildArgs has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        HttpContext.prototype.buildArgs = function(method) {
          var args = {};
          var ctx = this;
          var accepts = method.accepts;
        
        
        Severity: Major
        Found in lib/contexts/http.js - About 3 hrs to fix

          Function done has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          HttpContext.prototype.done = function() {
            // if response is already returned, then do nothing
            if (this._done) return;
          
          
          
          Severity: Minor
          Found in lib/contexts/http.js - 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 getArgByName has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          HttpContext.prototype.getArgByName = function(name, options) {
            var req = this.req;
            var args = req.params && req.params.args !== undefined ? req.params.args :
                       req.body && req.body.args !== undefined ? req.body.args :
                       req.query && req.query.args !== undefined ? req.query.args :
          Severity: Minor
          Found in lib/contexts/http.js - 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

          Function toResult has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          ApiMethod.toResult = function(raw, presenter, presenterSource, options) {
            if (Entity.isEntity(presenter)) {
              var result = presenter.parse(_eval(raw, presenterSource), options, _convert);
              return _eval(raw, presenterSource, result);
            } else {
          Severity: Minor
          Found in lib/api_method.js - 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

          Function add has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Entity.prototype.add = function() {
            // ...names, options, fn
          
            var message = '\'%s\' is not a valid string';
            var self = this;
          Severity: Major
          Found in lib/entity.js - About 2 hrs to fix

            Function parse has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Entity.prototype.parse = function(input, options, converter) {
              debug('parsing %j with options %j and converter', input, options);
              var originalObj;
              var result = {};
              var self = this;
            Severity: Major
            Found in lib/entity.js - About 2 hrs to fix

              Function errorHandler has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              RestAdapter.errorHandler = function(options) {
                options = options || {};
                return function restErrorHandler(err, req, res, next) {
                  if (typeof options.errorHandler === 'function') {
                    try {
              Severity: Minor
              Found in lib/adapters/rest.js - 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

              Function createHandler has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              RestAdapter.prototype.createHandler =  function() {
                var router = express.Router(this.options);
                var adapter = this;
                var methods = this.api.allMethods();
              
              
              Severity: Major
              Found in lib/adapters/rest.js - About 2 hrs to fix

                Function toResult has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ApiMethod.toResult = function(raw, presenter, presenterSource, options) {
                  if (Entity.isEntity(presenter)) {
                    var result = presenter.parse(_eval(raw, presenterSource), options, _convert);
                    return _eval(raw, presenterSource, result);
                  } else {
                Severity: Major
                Found in lib/api_method.js - About 2 hrs to fix

                  Function applyDelegates has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  HttpContext.prototype.applyDelegates = function(method) {
                    var proto = this;
                    /**
                   * Response delegation.
                   */
                  Severity: Major
                  Found in lib/contexts/http.js - About 2 hrs to fix

                    Function Validate has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function Validate(params, accepts) {
                    
                      var validationError = new ValidationError();
                      params = params || {};
                      accepts = accepts || [];
                    Severity: Major
                    Found in lib/validation.js - About 2 hrs to fix

                      Function done has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      HttpContext.prototype.done = function() {
                        // if response is already returned, then do nothing
                        if (this._done) return;
                      
                      
                      
                      Severity: Major
                      Found in lib/contexts/http.js - About 2 hrs to fix

                        Function coerceAccepts has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function coerceAccepts(uarg, desc) {
                          var name = desc.name || desc.arg;
                          var targetType = convertToBasicType(desc.type);
                          var targetTypeIsArray = _.isArray(targetType) && targetType.length === 1;
                        
                        
                        Severity: Minor
                        Found in lib/api_method.js - About 1 hr to fix

                          Function Sanitize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function Sanitize(params, accepts) {
                            params = params || {};
                            accepts = accepts || [];
                          
                            _.each(accepts, function(accept) {
                          Severity: Minor
                          Found in lib/sanitizer.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language