leap-protocol/leap-js

View on GitHub
src/configDataVerifier.js

Summary

Maintainability
C
1 day
Test Coverage

Function verify_values has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  verify_values(values, branch) {
    const depth = (branch.match(/\//) || []).length;
    if (typeof values !== "object") {
      this.failure = `value of ${branch} must be an object`;
    }
Severity: Minor
Found in src/configDataVerifier.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 get_next_address has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  get_next_address(addr, depth) {
    let next_addr;
    if (addr == null) {
      if (this.current_addr == null) {
        next_addr = 0;
Severity: Minor
Found in src/configDataVerifier.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 verify_values has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  verify_values(values, branch) {
    const depth = (branch.match(/\//) || []).length;
    if (typeof values !== "object") {
      this.failure = `value of ${branch} must be an object`;
    }
Severity: Minor
Found in src/configDataVerifier.js - About 1 hr to fix

    Function get_next_address has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      get_next_address(addr, depth) {
        let next_addr;
        if (addr == null) {
          if (this.current_addr == null) {
            next_addr = 0;
    Severity: Minor
    Found in src/configDataVerifier.js - About 1 hr to fix

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

        verify_item(item, branch) {
          if (typeof item !== "object") {
            this.failure = `data item "${item}" in ${branch} must be an object`;
          }
          else {
      Severity: Minor
      Found in src/configDataVerifier.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 verify_typeset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        verify_typeset(typeset, branch) {
          if (typeof typeset === "object") {
            for (let i in typeset) {
              const item = typeset[i];
              if ((typeof item !== "string") 
      Severity: Minor
      Found in src/configDataVerifier.js - About 35 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 verify_dataset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        verify_dataset(data, branch) {
          if (data.length == 0) {
            this.failure = `data in ${branch} is empty`;
          }
          else {
      Severity: Minor
      Found in src/configDataVerifier.js - About 35 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 verify_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        verify_type(type, branch) {
          const valid_types = ['u8', 'u16', 'u32', 'u64', 'i8', 'i16', 'i32', 'i64', 'bool', 'float', 'double', 'string', 'none'];
      
          if ((typeof type !== "string") && (typeof type !== "object")) {
            this.failure = `"${protocolKey.TYPE}" of "${branch}", "${type}" must be a string (or an array if (enum)`;
      Severity: Minor
      Found in src/configDataVerifier.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

      There are no issues that match your filters.

      Category
      Status