Codibre/chai-callslike

View on GitHub

Showing 7 of 9 total issues

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

export function compareDeep(
  actual: any,
  expected: any,
  tab: string,
  references: Set<unknown>,
Severity: Minor
Found in src/lib/compare-deep.ts - 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 compareDeep has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function compareDeep(
  actual: any,
  expected: any,
  tab: string,
  references: Set<unknown>,
Severity: Minor
Found in src/lib/compare-deep.ts - About 1 hr to fix

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

    export function match(actual: unknown, expected: unknown) {
      let matchResult: boolean = true;
      try {
        if (actual !== expected) {
          if (shouldFailOnExactCompare(typeof actual, typeof expected)) {
    Severity: Minor
    Found in src/lib/match.ts - 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 deeply nested control flow statements.
    Open

              if (compareResult) {
                deepResult += `${prefix}${key}: {${compareResult},\n${tab}}`;
              }
    Severity: Major
    Found in src/lib/compare-deep.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (matchResult) {
                  deepResult += `${prefix}${key}: ${matchResult},`;
                }
      Severity: Major
      Found in src/lib/compare-deep.ts - About 45 mins to fix

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

        export function mustGoDeep(a: unknown, e: unknown, references: Set<unknown>) {
          const result =
            isJsonComparable(a) &&
            isJsonComparable(e) &&
            !references.has(a) &&
        Severity: Minor
        Found in src/lib/must-go-deep.ts - 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 checkSomeCallsError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function checkSomeCallsError(
          actualCall: SinonStub,
          expectedCall: object[][],
          compareFunc: (actual: unknown, expected: unknown) => string,
        ) {
        Severity: Minor
        Found in src/lib/check-some-calls-error.ts - 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