ngryman/ribs

View on GitHub

Showing 31 of 31 total issues

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

module.exports = function(root) {

    // root required
    if (!root) throw new Error('ribs.middleware() root path required');

Severity: Major
Found in lib/middleware.js - About 3 hrs to fix

    Function cropConstraintsHook has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    hooks.cropConstraintsHook = function(params, image) {
        var dstWidth = params.width,
            dstHeight = params.height,
            anchor = params.anchor,
            gravity = params.gravity,
    Severity: Minor
    Found in lib/hooks.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 use has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    Pipeline.prototype.use = function(name, params) {
        // bypass on error
        if (this.error) return this;
    
        try {
    Severity: Minor
    Found in lib/pipeline.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 exports has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(grunt) {
        // load npm tasks
        require('load-grunt-tasks')(grunt);
        // load time grunt
        require('time-grunt')(grunt);
    Severity: Major
    Found in Gruntfile.js - About 2 hrs to fix

      Function parseArguments has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function parseArguments() {
          var src = args._[0],
              dst = args._[1],
              operations;
      
      
      Severity: Major
      Found in lib/cli.js - About 2 hrs to fix

        Function parseOperations has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function parseOperations(req, next, callback) {
                var url = req.url,
                    operations = [],
                    current;
        
        
        Severity: Minor
        Found in lib/middleware.js - About 2 hrs to fix

          Function to has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function to(params, image, next) {
              // arguments type
              check('next', next, false, 'function');
          
              try {
          Severity: Minor
          Found in lib/operations/to.js - About 1 hr to fix

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

            utils.computeFormula = function(formula, number) {
                var f = parseFloat(formula),
                    i, o, v, len;
            
                // early return for falsy values
            Severity: Minor
            Found in lib/utils.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 cropConstraintsHook has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            hooks.cropConstraintsHook = function(params, image) {
                var dstWidth = params.width,
                    dstHeight = params.height,
                    anchor = params.anchor,
                    gravity = params.gravity,
            Severity: Minor
            Found in lib/hooks.js - About 1 hr to fix

              Function use has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Pipeline.prototype.use = function(name, params) {
                  // bypass on error
                  if (this.error) return this;
              
                  try {
              Severity: Minor
              Found in lib/pipeline.js - About 1 hr to fix

                Function crop has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function crop(params, image, next) {
                    var width, height;
                
                    // arguments type
                    check('next', next, false, 'function');
                Severity: Minor
                Found in lib/operations/crop.js - About 1 hr to fix

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

                  var ribs = function(src, dst, bulk, callback) {
                      var pipeline = new Pipeline();
                  
                      /** `(bulk, callback)` */
                  
                  
                  Severity: Minor
                  Found in lib/ribs.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 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function(root) {
                  
                      // root required
                      if (!root) throw new Error('ribs.middleware() root path required');
                  
                  
                  Severity: Minor
                  Found in lib/middleware.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 resizeConstraintsHook has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  hooks.resizeConstraintsHook = function(params, image) {
                      var dstWidth = params.width,
                          dstHeight = params.height,
                          srcWidth = image.width,
                          srcHeight = image.height;
                  Severity: Minor
                  Found in lib/hooks.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 from has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function from(src, next) {
                      check('next', next, false, 'function');
                  
                      try {
                          check('params', src, false, 'string', 'object', 'array');
                  Severity: Minor
                  Found in lib/operations/from.js - About 1 hr to fix

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

                    hooks.resizeConstraintsHook = function(params, image) {
                        var dstWidth = params.width,
                            dstHeight = params.height,
                            srcWidth = image.width,
                            srcHeight = image.height;
                    Severity: Minor
                    Found in lib/hooks.js - About 1 hr to fix

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

                          if (~anchor.indexOf('l')) coords.x = x;
                          else if (~anchor.indexOf('r')) coords.x = x - width;
                          else coords.x = x - Math.round(width / 2);
                      Severity: Major
                      Found in lib/utils.js and 1 other location - About 1 hr to fix
                      lib/utils.js on lines 126..128

                      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

                          if (~anchor.indexOf('t')) coords.y = y;
                          else if (~anchor.indexOf('b')) coords.y = y - height;
                          else coords.y = y - Math.round(height / 2);
                      Severity: Major
                      Found in lib/utils.js and 1 other location - About 1 hr to fix
                      lib/utils.js on lines 121..123

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

                      function resize(params, image, next) {
                          // arguments type
                          check('next', next, false, 'function');
                      
                          try {
                      Severity: Minor
                      Found in lib/operations/resize.js - About 1 hr to fix

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

                            if (0 === dstHeight)
                                dstHeight = srcHeight;
                            else if (dstHeight < 0)
                                dstHeight = srcHeight + 2 * dstHeight;
                            else if (dstHeight > srcHeight)
                        Severity: Major
                        Found in lib/hooks.js and 1 other location - About 1 hr to fix
                        lib/hooks.js on lines 143..148

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language