kwiniarski/spiral

View on GitHub

Showing 17 of 17 total issues

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

module.exports = function (grunt) {
  'use strict';

  function readCodeclimateTokenFile() {
    var filename = './codeclimate.txt';
Severity: Major
Found in Gruntfile.js - About 3 hrs to fix

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

    module.exports = function (req, res, next) {
    
      var finishedAt = null;
    
      if (req && req._startedAt) {
    Severity: Major
    Found in middleware/response.js - About 2 hrs to fix

      Function resourceActionBlueprint has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function resourceActionBlueprint(model, mountPath) {
      
        var proto = Object.create({});
      
        defineProperty(proto, 'model', model);
      Severity: Major
      Found in lib/resource/action-blueprint.js - About 2 hrs to fix

        Function PolicyConfig has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function PolicyConfig(configData) {
          var config = readConfig(configData);
        
          for (var key in config) {
            var record = config[key];
        Severity: Minor
        Found in lib/policy/config.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 agregateActions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        Resource.prototype.agregateActions = function (actions) {
          var mountPaths = {};
        
          for (var i in actions) {
            var action = actions[i];
        Severity: Minor
        Found in lib/resource/index.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 resourceActionBlueprint has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function resourceActionBlueprint(model, mountPath) {
        
          var proto = Object.create({});
        
          defineProperty(proto, 'model', model);
        Severity: Minor
        Found in lib/resource/action-blueprint.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 (req, res, next) {
        
          var finishedAt = null;
        
          if (req && req._startedAt) {
        Severity: Minor
        Found in middleware/response.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 PolicyConfig has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function PolicyConfig(configData) {
          var config = readConfig(configData);
        
          for (var key in config) {
            var record = config[key];
        Severity: Minor
        Found in lib/policy/config.js - About 1 hr to fix

          Function validateAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function validateAction(config) {
          
            if (!config.id || typeof config.id !== 'string' && config.id.length > 0) {
              throw new TypeError('ResourceAction(config.id) needs to be a non empty string');
            }
          Severity: Minor
          Found in lib/resource/action.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 resolveMountPath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function resolveMountPath(model, controller) {
            var mountPath = null;
            if (controller && controller.path) {
              mountPath = controller.path;
            }
          Severity: Minor
          Found in lib/resource/index.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 RequestError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function RequestError(status, message) {
          
            /**
             * Instance property which shouldn't be enumerable because
             * we don't want to list stored stack traces in serialized data.
          Severity: Minor
          Found in lib/errors.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 validateTypeOfArrayRecords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function validateTypeOfArrayRecords(array, name, type) {
            if (!array || !array instanceof Array) {
              throw new TypeError('ResourceAction(config.' + name + ') needs to be an Array');
            } else {
              for (var i = 0, j = array.length; i < j; i++) {
          Severity: Minor
          Found in lib/resource/action.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 getRouter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          Resource.prototype.getRouter = function () {
            var resourceRouter = router()
              , actions = this.agregateActions(this.actions)
              , replaced = this.agregateActions(this.replaced);
          
          
          Severity: Minor
          Found in lib/resource/index.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 actionWrapper has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function actionWrapper(handler) {
          
            if (handler.wrapped === true) {
              return handler;
            }
          Severity: Minor
          Found in lib/resource/action-wrapper.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

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

          PolicyRegistry.prototype.allow = function () {
            if (this._allow) {
              return this._allow;
            } else {
              throw new Error('Allow policy/middleware is not configured');
          Severity: Minor
          Found in lib/policy/registry.js and 1 other location - About 40 mins to fix
          lib/policy/registry.js on lines 53..59

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

          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

          PolicyRegistry.prototype.block = function () {
            if (this._block) {
              return this._block;
            } else {
              throw new Error('Block policy/middleware is not configured');
          Severity: Minor
          Found in lib/policy/registry.js and 1 other location - About 40 mins to fix
          lib/policy/registry.js on lines 45..51

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

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

          function Resource(model, controller, policies) {
          
            var blueprint = {}
              , actions = controller ? controller.actions : null;
          
          
          Severity: Minor
          Found in lib/resource/index.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