dhis2/d2-utilizr

View on GitHub

Showing 11 of 13 total issues

Function arrayFrom has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export default function arrayFrom(param, isNewRef) {
    var toArray = function(iterable, start, end) {
        if (!iterable || !iterable.length) {
            return [];
        }
Severity: Minor
Found in src/arrayFrom.js - About 3 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 arraySort has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function arraySort(array, direction, key, emptyFirst) {
    // supports [number], [string], [{key: number}], [{key: string}], [[string]], [[number]]

    if (!isArray(array)) {
        return;
Severity: Minor
Found in src/arraySort.js - About 1 hr to fix

    Function arrayFrom has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function arrayFrom(param, isNewRef) {
        var toArray = function(iterable, start, end) {
            if (!iterable || !iterable.length) {
                return [];
            }
    Severity: Minor
    Found in src/arrayFrom.js - About 1 hr to fix

      Function arrayMax has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function arrayMax(array, comparisonFn) {
          var i = 0,
              ln = array.length,
              item,
              max = array[0];        
      Severity: Minor
      Found in src/arrayMax.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 arrayMin has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function arrayMin(array, comparisonFn) {
          var i = 0,
              ln = array.length,
              item,
              min = array[0];
      Severity: Minor
      Found in src/arrayMin.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 arrayTo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function arrayTo(param) {
          if (isArray(param)) {
              return param;
          }
      
      
      Severity: Minor
      Found in src/arrayTo.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 arrayRepeat has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function arrayRepeat(array, n=1, byIndex=false) {
          
          if (typeof array === 'undefined') {
              throw `Cannot repeat array of type undefined`;
          }
      Severity: Minor
      Found in src/arrayRepeat.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 too many return statements within this function.
      Open

              return -1;
      Severity: Major
      Found in src/arraySort.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return emptyFirst ? 1 : -1;
        Severity: Major
        Found in src/arraySort.js - About 30 mins to fix

          Function objectApplyIf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function objectApplyIf(object, config) {
              var property;
          
              if (object) {
                  for (property in config) {
          Severity: Minor
          Found in src/objectApplyIf.js - About 25 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 arrayReplace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function arrayReplace(array, index, removeCount, insert) {
              if (insert && insert.length) {
                  if (index < array.length) {
                      array.splice.apply(array, [index, removeCount].concat(insert));
                  } else {
          Severity: Minor
          Found in src/arrayReplace.js - About 25 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