jaredhanson/locomotive

View on GitHub

Showing 62 of 62 total issues

Function render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

Controller.prototype.render = function(template, options, fn) {
  if (typeof options === 'function') {
    fn = options;
    options = undefined;
  } else if (typeof template === 'function') {
Severity: Minor
Found in lib/controller.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 respondWith has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

Controller.prototype.respondWith = function(obj) {
  var req = this.__req
    , res = this.__res
    , format = this.__req.params.format;
  format = format ? mime.lookup(format) : undefined;
Severity: Minor
Found in lib/controller.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

File controller.js has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Module dependencies.
 */
var router = require('actionrouter')
  , mime = require('express').mime
Severity: Minor
Found in lib/controller.js - About 3 hrs to fix

    Function _invoke has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    Controller.prototype._invoke = function(action) {
      if (typeof this[action] !== 'function') {
        return this.__next(new ControllerError(this.__id + '#' + action + ' is not a function'));
      }
      
    Severity: Minor
    Found in lib/controller.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

        for (var i = 0, len = arguments.length; i < len; i++) {
          var arg = arguments[i];
          var placeholder = placeholders[i];
        
          if (arg && (arg.id || arg.id === 0)) {
    Severity: Major
    Found in lib/helpers/route/pattern.js and 1 other location - About 3 hrs to fix
    lib/helpers/route/entry.js on lines 18..27

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

    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

        for (var i = 0, len = arguments.length; i < len; i++) {
          var arg = arguments[i];
          var placeholder = placeholders[i];
        
          if (arg && (arg.id || arg.id === 0)) {
    Severity: Major
    Found in lib/helpers/route/entry.js and 1 other location - About 3 hrs to fix
    lib/helpers/route/pattern.js on lines 30..39

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

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

    exports = module.exports = function server(dir, address, port, env, options) {
      console.log('CLI ENV: ' + env);
      options = options || {};
      
      var command, args, proc;
    Severity: Major
    Found in lib/cli/server.js - About 2 hrs to fix

      Function _devoke has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      Controller.prototype._devoke = function(err, cb) {
        if (this.__devoked) { return; }
        this.__devoked = true;
      
        var self = this
      Severity: Minor
      Found in lib/controller.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

      File create.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * Module dependencies.
       */
      var prompt = require('co-prompt')
        , os = require('os')
      Severity: Minor
      Found in lib/cli/create.js - About 2 hrs to fix

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

          for (var i = 0; i < len; ++i) {
            for (var j = 0, jlen = types.length; j < jlen; ++j) {
              if (exports.accept(normalized[j], accepted[i])) {
                return types[j];
              }
        Severity: Major
        Found in lib/utils.js and 1 other location - About 2 hrs to fix
        lib/utils.js on lines 266..272

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

        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

          for (var i = 0; i < len; ++i) {
            for (var j = 0, jlen = types.length; j < jlen; ++j) {
              if (exports.accept(normalized[j], accepted[i])) {
                return accepted[i];
              }
        Severity: Major
        Found in lib/utils.js and 1 other location - About 2 hrs to fix
        lib/utils.js on lines 115..121

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

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

        Controller.prototype.render = function(template, options, fn) {
          if (typeof options === 'function') {
            fn = options;
            options = undefined;
          } else if (typeof template === 'function') {
        Severity: Major
        Found in lib/controller.js - About 2 hrs to fix

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

          var app = process.argv[2] || process.cwd()
            , address = process.argv[3] || '0.0.0.0'
            , port = process.argv[4] || 3000
            , env = process.argv[5] || 'development';
          Severity: Major
          Found in lib/cli/server/debug.js and 1 other location - About 2 hrs to fix
          lib/cli/server/watch.js on lines 9..12

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

          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

          var app = process.argv[2] || process.cwd()
            , address = process.argv[3] || '0.0.0.0'
            , port = process.argv[4] || 3000
            , env = process.argv[5] || 'development';
          Severity: Major
          Found in lib/cli/server/watch.js and 1 other location - About 2 hrs to fix
          lib/cli/server/debug.js on lines 14..17

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

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

          Controller.prototype._invoke = function(action) {
            if (typeof this[action] !== 'function') {
              return this.__next(new ControllerError(this.__id + '#' + action + ' is not a function'));
            }
            
          Severity: Major
          Found in lib/controller.js - About 2 hrs to fix

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

                for (var i = 0, len = deps.length; i < len; ++i) {
                  debug('create %s', deps[i]);
                  var inst = container.create(deps[i], this);
                  args.push(inst);
                }
            Severity: Major
            Found in lib/instantiators/di/constructor.js and 2 other locations - About 2 hrs to fix
            lib/boot/di/routes.js on lines 37..41
            lib/instantiators/di/factory.js on lines 26..30

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

            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 3 locations. Consider refactoring.
            Open

                for (var i = 0, len = deps.length; i < len; ++i) {
                  debug('create %s', deps[i]);
                  var inst = container.create(deps[i], this);
                  args.push(inst);
                }
            Severity: Major
            Found in lib/boot/di/routes.js and 2 other locations - About 2 hrs to fix
            lib/instantiators/di/constructor.js on lines 26..30
            lib/instantiators/di/factory.js on lines 26..30

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

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

            module.exports = function(port, address, options) {
              var os = require('os')
                , http = require('http')
                , cluster = require('cluster')
                , debug = require('debug')('locomotive');
            Severity: Minor
            Found in lib/boot/httpservercluster.js - About 2 hrs to fix

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

                  for (var i = 0, len = deps.length; i < len; ++i) {
                    debug('create %s', deps[i]);
                    var inst = container.create(deps[i], this);
                    args.push(inst);
                  }
              Severity: Major
              Found in lib/instantiators/di/factory.js and 2 other locations - About 2 hrs to fix
              lib/boot/di/routes.js on lines 37..41
              lib/instantiators/di/constructor.js on lines 26..30

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

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

              exports = module.exports = function create(path) {
                console.log('creating Locomotive application at : ' + path);
                
                (function createApplication(path) {
                  emptyDirectory(path, function(empty) {
              Severity: Minor
              Found in lib/cli/create.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

              Severity
              Category
              Status
              Source
              Language