dopry/netlify-cms

View on GitHub
scripts/autoconfigure.collection.js

Summary

Maintainability
C
1 day
Test Coverage

Function inferWidget has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function inferWidget(name, value) {
  if (value == null) {
    return { widget: 'string' };
  }
  if (value instanceof Date) {
Severity: Minor
Found in scripts/autoconfigure.collection.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 inferWidget has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function inferWidget(name, value) {
  if (value == null) {
    return { widget: 'string' };
  }
  if (value instanceof Date) {
Severity: Minor
Found in scripts/autoconfigure.collection.js - About 1 hr to fix

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

    function combineFields(a, b) {
      if (b == null && a) {
        return a;
      }
      if (a == null && b) {
    Severity: Minor
    Found in scripts/autoconfigure.collection.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

    Avoid too many return statements within this function.
    Open

        return { widget: 'text' };
    Severity: Major
    Found in scripts/autoconfigure.collection.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return { widget: 'number' };
      Severity: Major
      Found in scripts/autoconfigure.collection.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return { widget: 'image' };
        Severity: Major
        Found in scripts/autoconfigure.collection.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return [a, b].sort((fieldA, fieldB) => compareWidget(fieldB.widget, fieldA.widget))[0];
          Severity: Major
          Found in scripts/autoconfigure.collection.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return a;
            Severity: Major
            Found in scripts/autoconfigure.collection.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return { widget: 'markdown' };
              Severity: Major
              Found in scripts/autoconfigure.collection.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return { widget: 'string' };
                Severity: Major
                Found in scripts/autoconfigure.collection.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return { widget: 'object', fields: inferFields([value]) };
                  Severity: Major
                  Found in scripts/autoconfigure.collection.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return { widget: 'checkbox' };
                    Severity: Major
                    Found in scripts/autoconfigure.collection.js - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status