aurelia/aurelia

View on GitHub
packages/testing/src/specialized-assertions.ts

Summary

Maintainability
F
3 days
Test Coverage

Function verifyBindingInstructionsEqual has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

export function verifyBindingInstructionsEqual(actual: any, expected: any, errors?: string[], path?: string): any {
  if (path === undefined) {
    path = 'instruction';
  }
  if (errors === undefined) {
Severity: Minor
Found in packages/testing/src/specialized-assertions.ts - About 1 day 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 verifyBindingInstructionsEqual has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function verifyBindingInstructionsEqual(actual: any, expected: any, errors?: string[], path?: string): any {
  if (path === undefined) {
    path = 'instruction';
  }
  if (errors === undefined) {
Severity: Major
Found in packages/testing/src/specialized-assertions.ts - About 2 hrs to fix

    Function verifyEqual has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
      if (depth === undefined) {
        depth = 0;
      }
      if (typeof expected !== 'object' || expected === null) {
    Severity: Minor
    Found in packages/testing/src/specialized-assertions.ts - 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 instructionTypeName has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function instructionTypeName(type: string): string {
      switch (type) {
        case InstructionType.textBinding:
          return 'textBinding';
        case InstructionType.interpolation:
    Severity: Minor
    Found in packages/testing/src/specialized-assertions.ts - About 1 hr to fix

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

      export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
        if (depth === undefined) {
          depth = 0;
        }
        if (typeof expected !== 'object' || expected === null) {
      Severity: Minor
      Found in packages/testing/src/specialized-assertions.ts - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                if (typeof actual === 'object' && actual != null) {
                  actual = JSON.stringify(actual);
                }
        Severity: Major
        Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if (typeof expected === 'object' && expected != null) {
                    expected = JSON.stringify(expected);
                  }
          Severity: Major
          Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                for (const prop in actual) {
                  if (!seen[prop]) {
                    verifyBindingInstructionsEqual(actual[prop], expected[prop], errors, `${path}.${prop}`);
                  }
                }
            Severity: Major
            Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      if (String(expected).endsWith('unnamed') && /unnamed-\d+$/.test(String(actual))) {
                        errors.push(`OK   : ${path} === ${expected} (${actual})`);
                      }
              Severity: Major
              Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                    for (const prop in expected) {
                      verifyBindingInstructionsEqual(actual[prop], expected[prop], errors, `${path}.${prop}`);
                      seen[prop] = true;
                    }
                Severity: Major
                Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                        if (actual.outerHTML !== expected['outerHTML']) {
                          errors.push(`WRONG: ${path}.outerHTML === ${actual.outerHTML} (expected: ${expected['outerHTML']})`);
                        } else {
                          errors.push(`OK   : ${path}.outerHTML === ${expected}`);
                        }
                  Severity: Major
                  Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                            if (path.endsWith('type')) {
                              expected = instructionTypeName(expected);
                              actual = instructionTypeName(actual);
                            }
                    Severity: Major
                    Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                            for (let i = 0, ii = Math.max(expected.childNodes.length, actual.childNodes.length); i < ii; ++i) {
                              verifyBindingInstructionsEqual(actual.childNodes.item(i), expected.childNodes.item(i), errors, `${path}.childNodes[${i}]`);
                            }
                      Severity: Major
                      Found in packages/testing/src/specialized-assertions.ts - About 45 mins to fix

                        Function verifyEqual has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
                        Severity: Minor
                        Found in packages/testing/src/specialized-assertions.ts - About 35 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status