ilios/frontend

View on GitHub
packages/ilios-common/addon/helpers/sort-by.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function perform has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  perform(keys = []) {
    let swapped = false;

    let compFuncs = keys.map((key) => this.comparator(key));
    let compFunc = (a, b) => {
Severity: Minor
Found in packages/ilios-common/addon/helpers/sort-by.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 sortDesc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function sortDesc(key, a, b) {
  if (isEmpty(key)) {
    return 0;
  }

Severity: Minor
Found in packages/ilios-common/addon/helpers/sort-by.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 sortAsc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function sortAsc(key, a, b) {
  if (isEmpty(key)) {
    return 0;
  }

Severity: Minor
Found in packages/ilios-common/addon/helpers/sort-by.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

Avoid too many return statements within this function.
Open

    return -1;
Severity: Major
Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return collator.compare(bValue, aValue);
    Severity: Major
    Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 1;
      Severity: Major
      Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          return 0;
        Severity: Major
        Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return 0;
          Severity: Major
          Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return 1;
            Severity: Major
            Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return collator.compare(aValue, bValue);
              Severity: Major
              Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return -1;
                Severity: Major
                Found in packages/ilios-common/addon/helpers/sort-by.js - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status