handsontable/formula.js

View on GitHub

Showing 506 of 506 total issues

Function AVERAGEIFS has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.AVERAGEIFS = function() {
  // Does not work with multi dimensional ranges yet!
  //http://office.microsoft.com/en-001/excel-help/averageifs-function-HA010047493.aspx
  var args = utils.argsToArray(arguments);
  var criteriaLength = (args.length - 1) / 2;
Severity: Minor
Found in lib/statistical.js - About 1 hr to fix

    Function HEX2OCT has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.HEX2OCT = function(number, places) {
      // Return error if number is not hexadecimal or contains more than ten characters (10 digits)
      if (!/^[0-9A-Fa-f]{1,10}$/.test(number)) {
        return error.num;
      }
    Severity: Minor
    Found in lib/engineering.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 AVERAGEIF has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.AVERAGEIF = function(range, criteria, average_range) {
      if (arguments.length <= 1) {
        return error.na;
      }
      average_range = average_range || range;
    Severity: Minor
    Found in lib/statistical.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 GCD has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.GCD = function() {
      var range = utils.parseNumberArray(utils.flatten(arguments));
      if (range instanceof Error) {
        return range;
      }
    Severity: Minor
    Found in lib/math-trig.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 CUMIPMT has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.CUMIPMT = function(rate, periods, value, start, end, type) {
      // Credits: algorithm inspired by Apache OpenOffice
      // Credits: Hannes Stiebitzhofer for the translations of function and variable names
      // Requires exports.FV() and exports.PMT() from exports.js [http://stoic.com/exports/]
    
    
    Severity: Minor
    Found in lib/financial.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 DB has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.DB = function(cost, salvage, life, period, month) {
      // Initialize month
      month = (month === undefined) ? 12 : month;
    
      cost = utils.parseNumber(cost);
    Severity: Minor
    Found in lib/financial.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 SUMPRODUCT has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.SUMPRODUCT = function() {
      if (!arguments || arguments.length === 0) {
        return error.value;
      }
      var arrays = arguments.length + 1;
    Severity: Minor
    Found in lib/math-trig.js - About 1 hr to fix

      Function DAYS360 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.DAYS360 = function(start_date, end_date, method) {
        method = utils.parseBool(method);
        start_date = utils.parseDate(start_date);
        end_date = utils.parseDate(end_date);
      
      
      Severity: Minor
      Found in lib/date-time.js - About 1 hr to fix

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

          if (negative) {
            return '1' + text.REPT('0', 9 - (512 + decimal).toString(2).length) + (512 + decimal).toString(2);
          }
        Severity: Major
        Found in lib/engineering.js and 1 other location - About 1 hr to fix
        lib/engineering.js on lines 796..798

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

        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 (negative) {
            return '1' + text.REPT('0', 9 - (512 + decimal).toString(2).length) + (512 + decimal).toString(2);
          }
        Severity: Major
        Found in lib/engineering.js and 1 other location - About 1 hr to fix
        lib/engineering.js on lines 1483..1485

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

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

        exports.SUMIFS = function() {
          var args = utils.argsToArray(arguments);
          var range = utils.parseNumberArray(utils.flatten(args.shift()));
        
          if (range instanceof Error) {
        Severity: Minor
        Found in lib/math-trig.js - About 1 hr to fix

          Function tokenizeExpression has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function tokenizeExpression(expression) {
            var expressionLength = expression.length;
            var tokens = [];
            var cursorIndex = 0;
            var processedValue = '';
          Severity: Minor
          Found in lib/utils/criteria-eval.js - About 1 hr to fix

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

              for (var i = 0; i < array_x.length; i++) {
                result += array_x[i] * array_x[i] - array_y[i] * array_y[i];
              }
            Severity: Major
            Found in lib/math-trig.js and 1 other location - About 1 hr to fix
            lib/math-trig.js on lines 1135..1137

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

            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 < array_x.length; i++) {
                result += array_x[i] * array_x[i] + array_y[i] * array_y[i];
              }
            Severity: Major
            Found in lib/math-trig.js and 1 other location - About 1 hr to fix
            lib/math-trig.js on lines 1120..1122

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

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

            exports.CUMPRINC = function(rate, periods, value, start, end, type) {
              // Credits: algorithm inspired by Apache OpenOffice
              // Credits: Hannes Stiebitzhofer for the translations of function and variable names
            
              rate = utils.parseNumber(rate);
            Severity: Minor
            Found in lib/financial.js - About 1 hr to fix

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

              exports.SEC = function(number) {
                number = utils.parseNumber(number);
                if (number instanceof Error) {
                  return number;
                }
              Severity: Major
              Found in lib/math-trig.js and 2 other locations - About 1 hr to fix
              lib/math-trig.js on lines 274..280
              lib/math-trig.js on lines 291..297

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

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

              exports.COT = function(number) {
                number = utils.parseNumber(number);
                if (number instanceof Error) {
                  return number;
                }
              Severity: Major
              Found in lib/math-trig.js and 2 other locations - About 1 hr to fix
              lib/math-trig.js on lines 291..297
              lib/math-trig.js on lines 694..700

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

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

              exports.CSC = function(number) {
                number = utils.parseNumber(number);
                if (number instanceof Error) {
                  return number;
                }
              Severity: Major
              Found in lib/math-trig.js and 2 other locations - About 1 hr to fix
              lib/math-trig.js on lines 274..280
              lib/math-trig.js on lines 694..700

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

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

              exports.CUMIPMT = function(rate, periods, value, start, end, type) {
                // Credits: algorithm inspired by Apache OpenOffice
                // Credits: Hannes Stiebitzhofer for the translations of function and variable names
                // Requires exports.FV() and exports.PMT() from exports.js [http://stoic.com/exports/]
              
              
              Severity: Minor
              Found in lib/financial.js - About 1 hr to fix

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

                exports.HLOOKUP = function (needle, table, index, rangeLookup) {
                  if (!needle || !table || !index) {
                    return error.na;
                  }
                
                
                Severity: Minor
                Found in lib/lookup-reference.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