enclose-io/compiler

View on GitHub
lts/lib/internal/assert/assertion_error.js

Summary

Maintainability
F
3 wks
Test Coverage

Function createErrDiff has a Cognitive Complexity of 117 (exceeds 5 allowed). Consider refactoring.
Open

function createErrDiff(actual, expected, operator) {
  let other = '';
  let res = '';
  let end = '';
  let skipped = false;
Severity: Minor
Found in lts/lib/internal/assert/assertion_error.js - About 2 days 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 constructor has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(options) {
    if (typeof options !== 'object' || options === null) {
      throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
    }
    const {
Severity: Minor
Found in lts/lib/internal/assert/assertion_error.js - 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 createErrDiff has 164 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createErrDiff(actual, expected, operator) {
  let other = '';
  let res = '';
  let end = '';
  let skipped = false;
Severity: Major
Found in lts/lib/internal/assert/assertion_error.js - About 6 hrs to fix

    File assertion_error.js has 361 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const {
      Error,
      MathMax,
    Severity: Minor
    Found in lts/lib/internal/assert/assertion_error.js - About 4 hrs to fix

      Function constructor has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(options) {
          if (typeof options !== 'object' || options === null) {
            throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
          }
          const {
      Severity: Major
      Found in lts/lib/internal/assert/assertion_error.js - About 4 hrs to fix

        Consider simplifying this complex logical expression.
        Open

              if (typeof actual === 'object' && actual !== null &&
                  typeof expected === 'object' && expected !== null &&
                  'stack' in actual && actual instanceof Error &&
                  'stack' in expected && expected instanceof Error) {
                actual = copyError(actual);
        Severity: Critical
        Found in lts/lib/internal/assert/assertion_error.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

            if (operator === 'strictEqual' &&
                ((typeof actual === 'object' && actual !== null &&
                  typeof expected === 'object' && expected !== null) ||
                 (typeof actual === 'function' && typeof expected === 'function'))) {
              operator = 'strictEqualObject';
          Severity: Major
          Found in lts/lib/internal/assert/assertion_error.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (identical > 4) {
                        if (identical === 5) {
                          res += `\n  ${lines[i - 3]}`;
                          printedLines++;
                        } else {
            Severity: Major
            Found in lts/lib/internal/assert/assertion_error.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      while (actualRaw[i] === expectedRaw[i]) {
                        i++;
                      }
              Severity: Major
              Found in lts/lib/internal/assert/assertion_error.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (identical > 3) {
                            if (identical > 4) {
                              if (identical === 5) {
                                res += `\n  ${actualLines[i - 3]}`;
                                printedLines++;
                Severity: Major
                Found in lts/lib/internal/assert/assertion_error.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          if (i > 2) {
                            // Add position indicator for the first mismatch in case it is a
                            // single line and the input length is less than the column length.
                            indicator = `\n  ${' '.repeat(i)}^`;
                            i = 0;
                  Severity: Major
                  Found in lts/lib/internal/assert/assertion_error.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (newOp) {
                                  res = `${newOp}\n\n${res}\n\nshould not loosely deep-equal\n\n`;
                                } else {
                                  other = ` ${operator} ${other}`;
                                }
                    Severity: Major
                    Found in lts/lib/internal/assert/assertion_error.js - About 45 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                            if ((typeof actual !== 'object' || actual === null) &&
                                (typeof expected !== 'object' || expected === null) &&
                                (actual !== 0 || expected !== 0)) { // -0 === +0
                              return `${kReadableOperator[operator]}\n\n` +
                                  `${actualLines[0]} !== ${expectedLines[0]}\n`;
                      Severity: Major
                      Found in lts/lib/internal/assert/assertion_error.js - About 40 mins to fix

                        Function inspect.custom has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          [inspect.custom](recurseTimes, ctx) {
                            // Long strings should not be fully inspected.
                            const tmpActual = this.actual;
                            const tmpExpected = this.expected;
                        
                        
                        Severity: Minor
                        Found in lts/lib/internal/assert/assertion_error.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

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                        function createErrDiff(actual, expected, operator) {
                          let other = '';
                          let res = '';
                          let end = '';
                          let skipped = false;
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 1 wk to fix
                        current/lib/internal/assert/assertion_error.js on lines 74..304

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 2002.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                            if (message != null) {
                              super(String(message));
                            } else {
                              if (process.stderr.isTTY) {
                                // Reset on each call to make sure we handle dynamically set environment
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 5 days to fix
                        current/lib/internal/assert/assertion_error.js on lines 327..418

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 864.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                          [inspect.custom](recurseTimes, ctx) {
                            // Long strings should not be fully inspected.
                            const tmpActual = this.actual;
                            const tmpExpected = this.expected;
                        
                        
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 1 day to fix
                        current/lib/internal/assert/assertion_error.js on lines 458..490

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 261.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                        function copyError(source) {
                          const keys = ObjectKeys(source);
                          const target = ObjectCreate(ObjectGetPrototypeOf(source));
                          for (const key of keys) {
                            target[key] = source[key];
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 2 hrs to fix
                        current/lib/internal/assert/assertion_error.js on lines 43..51

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 85.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                        function inspectValue(val) {
                          // The util.inspect default values could be changed. This makes sure the
                          // error messages contain the necessary information nevertheless.
                          return inspect(
                            val,
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 1 hr to fix
                        current/lib/internal/assert/assertion_error.js on lines 53..72

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 67.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                        const kReadableOperator = {
                          deepStrictEqual: 'Expected values to be strictly deep-equal:',
                          strictEqual: 'Expected values to be strictly equal:',
                          strictEqualObject: 'Expected "actual" to be reference-equal to "expected":',
                          deepEqual: 'Expected values to be loosely deep-equal:',
                        Severity: Major
                        Found in lts/lib/internal/assert/assertion_error.js and 1 other location - About 1 hr to fix
                        current/lib/internal/assert/assertion_error.js on lines 25..37

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 61.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        There are no issues that match your filters.

                        Category
                        Status