handsontable/formula.js

View on GitHub

Showing 506 of 506 total issues

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

exports.parseBool = function(bool) {
  if (typeof bool === 'boolean') {
    return bool;
  }

Severity: Minor
Found in lib/utils/common.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 SUBSTITUTE has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.SUBSTITUTE = function(text, old_text, new_text, occurrence) {
  if (arguments.length < 2) {
    return error.na;
  }
  if (!text || !old_text || !new_text) {
Severity: Minor
Found in lib/text.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 IPMT has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.IPMT = function(rate, period, periods, present, future, type) {
  // Credits: algorithm inspired by Apache OpenOffice

  future = future || 0;
  type = type || 0;
Severity: Minor
Found in lib/financial.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 ACCRINT has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

exports.ACCRINT = function(issue, first, settlement, rate, par, frequency, basis) {
Severity: Major
Found in lib/financial.js - About 50 mins to fix

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

        for (var i = 0; i < values.length; i++) {
          sum +=Math.pow((values[i] - x1), 2);
        }
    Severity: Minor
    Found in lib/statistical.js and 1 other location - About 50 mins to fix
    lib/statistical.js on lines 560..562

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

    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 < range.length; i++) {
        result += Math.pow((range[i] - mean), 2);
      }
    Severity: Minor
    Found in lib/statistical.js and 1 other location - About 50 mins to fix
    lib/statistical.js on lines 650..652

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

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

    exports.MODE.MULT = function() {
      // Credits: Roönaän
      var range = utils.parseNumberArray(utils.flatten(arguments));
      if (range instanceof Error) {
        return range;
    Severity: Minor
    Found in lib/statistical.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 VARPA has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.VARPA = function() {
      var range = utils.flatten(arguments);
      var n = range.length;
      var sigma = 0;
      var count = 0;
    Severity: Minor
    Found in lib/statistical.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

    Avoid deeply nested control flow statements.
    Open

            if (lookupArray[idx].toLowerCase().match(lookupValue.toLowerCase())) {
              return idx + 1;
            }
    Severity: Major
    Found in lib/lookup-reference.js - About 45 mins to fix

      Function EXC has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.PERCENTRANK.EXC = function(array, x, significance) {
        significance = (significance === undefined) ? 3 : significance;
        array = utils.parseNumberArray(utils.flatten(array));
        x = utils.parseNumber(x);
        significance = utils.parseNumber(significance);
      Severity: Minor
      Found in lib/statistical.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 INC has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.PERCENTRANK.INC = function(array, x, significance) {
        significance = (significance === undefined) ? 3 : significance;
        array = utils.parseNumberArray(utils.flatten(array));
        x = utils.parseNumber(x);
        significance = utils.parseNumber(significance);
      Severity: Minor
      Found in lib/statistical.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

      Avoid deeply nested control flow statements.
      Open

                if (!currentCriteriaResult) {
                  var isWildcard = criteria[p] === void 0 || criteria[p] === '*';
      
                  if (isWildcard) {
                    currentCriteriaResult = true;
      Severity: Major
      Found in lib/database.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (lookupArray[idx] === lookupValue) {
                  return idx + 1;
                }
        Severity: Major
        Found in lib/lookup-reference.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if (data[j] > bins[i - 1] && data[j] <= bins[i]) {
                    r[i] += 1;
                  }
          Severity: Major
          Found in lib/statistical.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (_ij instanceof Error) {
                        return _ij;
                      }
            Severity: Major
            Found in lib/math-trig.js - About 45 mins to fix

              Function MATH has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.FLOOR.MATH = function(number, significance, mode) {
                significance = (significance === undefined) ? 1 : significance;
                mode = (mode === undefined) ? 0 : mode;
              
                number = utils.parseNumber(number);
              Severity: Minor
              Found in lib/math-trig.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

              Avoid deeply nested control flow statements.
              Open

                    if (lookupArray[idx] === lookupValue) {
                      return idx + 1;
                    } else if (lookupArray[idx] > lookupValue) {
                      if (!indexValue) {
                        index = idx + 1;
              Severity: Major
              Found in lib/lookup-reference.js - About 45 mins to fix

                Function AVERAGEA has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.AVERAGEA = function() {
                  var range = utils.flatten(arguments);
                  var n = range.length;
                  var sum = 0;
                  var count = 0;
                Severity: Minor
                Found in lib/statistical.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 DIST has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                exports.BETA.DIST = function(x, alpha, beta, cumulative, A, B) {
                Severity: Minor
                Found in lib/statistical.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                        } else if (i === b) {
                          if (data[j] > bins[b - 1]) {
                            r[b] += 1;
                          }
                        }
                  Severity: Major
                  Found in lib/statistical.js - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language