lowdefy/lowdefy

View on GitHub
packages/utils/helpers/src/type.js

Summary

Maintainability
C
1 day
Test Coverage
A
94%

Function kindOf has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function kindOf(val) {
  // eslint-disable-next-line no-void
  if (val === void 0) return 'undefined';
  if (val === null) return 'null';

Severity: Major
Found in packages/utils/helpers/src/type.js - About 2 hrs to fix

    Function kindOf has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function kindOf(val) {
      // eslint-disable-next-line no-void
      if (val === void 0) return 'undefined';
      if (val === null) return 'null';
    
    
    Severity: Minor
    Found in packages/utils/helpers/src/type.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 enforceType has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function enforceType(typeName, value) {
      switch (typeName) {
        case 'string':
          return type.isString(value) && value !== '' ? value : null;
        case 'number':
    Severity: Minor
    Found in packages/utils/helpers/src/type.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

    Avoid too many return statements within this function.
    Open

      return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
    Severity: Major
    Found in packages/utils/helpers/src/type.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 'generator';
      Severity: Major
      Found in packages/utils/helpers/src/type.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          if (isDate(val)) return 'date';
        Severity: Major
        Found in packages/utils/helpers/src/type.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            if (isArray(val)) return 'array';
          Severity: Major
          Found in packages/utils/helpers/src/type.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              if (isRegexp(val)) return 'regexp';
            Severity: Major
            Found in packages/utils/helpers/src/type.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (type === 'symbol') return 'symbol';
              Severity: Major
              Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  if (isError(val)) return 'error';
                Severity: Major
                Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    if (type === 'number') return 'number';
                  Severity: Major
                  Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      if (isArguments(val)) return 'arguments';
                    Severity: Major
                    Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        if (isBuffer(val)) return 'buffer';
                      Severity: Major
                      Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return isGeneratorFn(val) ? 'generatorfunction' : 'function';
                        Severity: Major
                        Found in packages/utils/helpers/src/type.js - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status