leap-protocol/leap-js

View on GitHub
src/explore.js

Summary

Maintainability
D
1 day
Test Coverage

Function count_to_path has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

exports.count_to_path = function count_to_path(root, path) {
  let data;
  if ((protocolKey.DATA in root) == false) {
    return null;
  }
Severity: Minor
Found in src/explore.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 extract_decendants has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

exports.extract_decendants = function extract_decendants(root, path) {
  const decendants = [];
  const start = exports.get_struct(root, path);
  if (start != null) {
    if (protocolKey.DATA in start) {
Severity: Minor
Found in src/explore.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 extract_branches has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

exports.extract_branches = function extract_branches(root, path) {
  const start = exports.get_struct(root, path);
  const branches = [];
  if (start != null) {
    if (protocolKey.DATA in start) {
Severity: Minor
Found in src/explore.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 count_to_path has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.count_to_path = function count_to_path(root, path) {
  let data;
  if ((protocolKey.DATA in root) == false) {
    return null;
  }
Severity: Minor
Found in src/explore.js - About 1 hr to fix

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

    exports.get_struct = function get_struct(root, path) {
      if (path.length === 0) {
        return root;
      }
    
    
    Severity: Minor
    Found in src/explore.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

    Avoid deeply nested control flow statements.
    Open

              for (i in next_branches) {
                const branch = next_branches[i];
                branches.push(name + "/" + branch);
              }
    Severity: Major
    Found in src/explore.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                for (i in next_decendants) {
                  decendants.push(name + "/" + next_decendants[i]);
                }
      Severity: Major
      Found in src/explore.js - About 45 mins to fix

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

        exports.extract_types = function extract_types(root, path) {
          const start = exports.get_struct(root, path);
          const types = [];
          if (start != null) {
            if (protocolKey.TYPE in start) {
        Severity: Minor
        Found in src/explore.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 count;
        Severity: Major
        Found in src/explore.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

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

            There are no issues that match your filters.

            Category
            Status