lyfeyaj/poplar

View on GitHub

Showing 53 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  delegate(proto, 'request')
    .method('accepts')
    .method('acceptsCharsets')
    .method('acceptsEncodings')
    .method('acceptsLanguages')
Severity: Major
Found in lib/contexts/http.js and 1 other location - About 7 hrs to fix
lib/contexts/http.js on lines 74..98

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 190.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  delegate(proto, 'response')
    .getter('headersSent')
    .getter('locals')

    .method('append')
Severity: Major
Found in lib/contexts/http.js and 1 other location - About 7 hrs to fix
lib/contexts/http.js on lines 104..129

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 190.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          _.each(events, function(fns, type) {
            if (Array.isArray(fns)) {
              _.each(fns, function(fn) {
                if (_.isFunction(fn)) {
                  self.on(type, fn);
        Severity: Major
        Found in lib/api_builder.js and 1 other location - About 3 hrs to fix
        lib/poplar.js on lines 152..162

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 106.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            _.each(events, function(fns, type) {
              if (Array.isArray(fns)) {
                _.each(fns, function(fn) {
                  if (_.isFunction(fn)) {
                    self.on(type, fn);
        Severity: Major
        Found in lib/poplar.js and 1 other location - About 3 hrs to fix
        lib/api_builder.js on lines 128..138

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 106.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          RestAdapter.urlNotFoundHandler = function() {
            return function restUrlNotFound(req, res, next) {
              var message = 'There is no method to handle ' + req.method + ' ' + req.url;
              var error = new Error(message);
              error.status = error.statusCode = 404;
          Severity: Major
          Found in lib/adapters/rest.js and 1 other location - About 3 hrs to fix
          lib/adapters/rest.js on lines 194..201

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          RestAdapter.methodNotFoundHandler = function() {
            return function restMethodNotFound(req, res, next) {
              var message ='There is no method handling ' + req.method + ' ' + req.url;
              var error = new Error(message);
              error.status = error.statusCode = 404;
          Severity: Major
          Found in lib/adapters/rest.js and 1 other location - About 3 hrs to fix
          lib/adapters/rest.js on lines 206..213

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 97.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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
                Severity
                Category
                Status
                Source
                Language