truongld/yodajs

View on GitHub

Showing 64 of 64 total issues

Function exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(env) {
  env = env || process.env.NODE_ENV || 'development';
  var self = this
    , app = express();
  
Severity: Minor
Found in lib/underlay/express.js - About 1 hr to fix

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

      (function iter(err, data) {
        if (err) { return self.error(err); }
    
        filter = filters[i++];
        if (!filter) {
    Severity: Minor
    Found in lib/controller.js - About 1 hr to fix

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

      exports.path = function(pattern) {
        // from underlay/express.js#L49
        var keys = []
          , placeholders = [];
        // TODO: Implement support for 'sensitive' and 'strict' options
      Severity: Minor
      Found in lib/helpers/route/pattern.js - About 1 hr to fix

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

        function tag(name, options, close, cb) {
          if (typeof close === 'function') {
            cb = close;
            close = true;
          }
        Severity: Minor
        Found in lib/helpers/tag.js - About 1 hr to fix

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

          function ControllerError(message) {
            Error.call(this);
            Error.captureStackTrace(this, ControllerError);
            this.name = 'ControllerError';
            this.message = message;
          Severity: Major
          Found in lib/errors/controllererror.js and 1 other location - About 1 hr to fix
          lib/errors/dispatcherror.js on lines 6..11

          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 58.

          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

          function DispatchError(message) {
            Error.call(this);
            Error.captureStackTrace(this, DispatchError);
            this.name = 'DispatchError';
            this.message = message;
          Severity: Major
          Found in lib/errors/dispatcherror.js and 1 other location - About 1 hr to fix
          lib/errors/controllererror.js on lines 6..11

          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 58.

          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 iter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            (function iter(err) {
              filter = filters[i++];
              if (!filter) {
                // filters done
                if (cb) {
          Severity: Minor
          Found in lib/controller.js - About 1 hr to fix

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

            exports.acceptedVia = function(type, str) {
              if ('string' == typeof type) { type = type.split(/ *, */); }
              return exports.acceptedViaArray(type, str);
            };
            Severity: Major
            Found in lib/utils.js and 1 other location - About 1 hr to fix
            lib/utils.js on lines 180..183

            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 57.

            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

            exports.accepts = function(type, str) {
              if ('string' == typeof type) { type = type.split(/ *, */); }
              return exports.acceptsArray(type, str);
            };
            Severity: Major
            Found in lib/utils.js and 1 other location - About 1 hr to fix
            lib/utils.js on lines 274..277

            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 57.

            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 instantiate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            Instantiator.prototype.instantiate = function(mod, id, cb) {
              var mechs = this._mechs
                , idx = 0;
              
              function next(err, inst) {
            Severity: Minor
            Found in lib/instantiator.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 exports has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(port, address, options) {
              var os = require('os')
                , http = require('http')
                , cluster = require('cluster')
                , debug = require('debug')('maglev');
            Severity: Minor
            Found in lib/boot/httpservercluster.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 exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(options, container) {
              if (!container) {
                try {
                  container = require('electrolyte');
                } catch (_) {
            Severity: Minor
            Found in lib/boot/di/routes.js - About 1 hr to fix

              Function _controller has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Application.prototype._controller = function(id, cb) {
                var mod = this.__controllers[id]
                  , mpath;
                
                if (!mod) {
              Severity: Minor
              Found in lib/application.js - About 1 hr to fix

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

                  } else if (fopts.extension) {
                    ext = fopts.extension;
                    if ('.' == ext[0]) { ext = ext.slice(1); }
                    comps = [ tmpl, ext ];
                  }
                Severity: Major
                Found in lib/controller.js and 1 other location - About 1 hr to fix
                lib/controller.js on lines 135..145

                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 55.

                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

                  } else if (options.extension) {
                    ext = options.extension;
                    if ('.' == ext[0]) { ext = ext.slice(1); }
                    comps = [ tmpl, ext ];
                  } else if (fopts.engine) {
                Severity: Major
                Found in lib/controller.js and 1 other location - About 1 hr to fix
                lib/controller.js on lines 141..145

                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 55.

                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 exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function(options, container) {
                  if (!container) {
                    try {
                      container = require('electrolyte');
                    } catch (_) {
                Severity: Minor
                Found in lib/boot/di/routes.js - About 55 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

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

                function expose(helpers) {
                  for (var method in helpers) {
                    if (helpers.hasOwnProperty(method)) {
                      exports[method] = helpers[method];
                    }
                Severity: Minor
                Found in lib/helpers/dynamic/index.js and 1 other location - About 50 mins to fix
                lib/helpers/index.js on lines 1..7

                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 52.

                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

                function expose(helpers) {
                  for (var method in helpers) {
                    if (helpers.hasOwnProperty(method)) {
                      exports[method] = helpers[method];
                    }
                Severity: Minor
                Found in lib/helpers/index.js and 1 other location - About 50 mins to fix
                lib/helpers/dynamic/index.js on lines 1..7

                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 52.

                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 before has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                Controller.prototype.before = function(action, fn) {
                  var i, len;
                  
                  // If an array of filters is passed as an argument, decompose the array into
                  // its constituent arguments.
                Severity: Minor
                Found in lib/controller.js - About 45 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

                Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                exports = module.exports = function server(dir, address, port, env, options) {
                Severity: Minor
                Found in lib/cli/server.js - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language