jaredhanson/locomotive

View on GitHub

Showing 62 of 62 total issues

Function exports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function(controller, action, placeholders, onlyPath) {

  return function(obj) {
    if (arguments.length !== placeholders.length) { throw new Error('Incorrect number of arguments passed to route helper for ' + controller + '#' + action); }
    
Severity: Minor
Found in lib/helpers/route/entry.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 urlFor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function urlFor(req, res) {
  
  return function(options) {
    options = options || {};
    var app = req._locomotive.app;
Severity: Minor
Found in lib/helpers/dynamic/url.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

        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 136..139

        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 275..278

        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 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')('locomotive');
        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 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 tag has a Cognitive Complexity of 10 (exceeds 5 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

        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 tag has 27 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

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

              (function iter(err) {
                filter = filters[i++];
                if (!filter) {
                  // filters done
                  cb && cb(err);
            Severity: Minor
            Found in lib/controller.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 134..144

                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 140..144

                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

                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

                  Function acceptsArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.acceptsArray = function(types, str) {
                    // accept anything when Accept is not present
                    if (!str) { return types[0]; }
                  
                    // parse
                  Severity: Minor
                  Found in lib/utils.js - About 35 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 acceptedViaArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.acceptedViaArray = function(types, str) {
                    // not accepted by anything when Accept is not present
                    if (!str) { return undefined; }
                  
                    // parse
                  Severity: Minor
                  Found in lib/utils.js - About 35 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

                  Severity
                  Category
                  Status
                  Source
                  Language