ForestAdmin/forest-express-sequelize

View on GitHub
src/services/apimap-field-type-detector.js

Summary

Maintainability
C
1 day
Test Coverage
B
88%

Function ApimapFieldTypeDetector has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

function ApimapFieldTypeDetector(column, options) {
  const DataTypes = options.Sequelize;

  this.perform = () => {
    if (column.type instanceof DataTypes.STRING
Severity: Minor
Found in src/services/apimap-field-type-detector.js - About 4 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 ApimapFieldTypeDetector has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ApimapFieldTypeDetector(column, options) {
  const DataTypes = options.Sequelize;

  this.perform = () => {
    if (column.type instanceof DataTypes.STRING
Severity: Minor
Found in src/services/apimap-field-type-detector.js - About 1 hr to fix

    Function perform has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      this.perform = () => {
        if (column.type instanceof DataTypes.STRING
          || column.type instanceof DataTypes.TEXT
          || (DataTypes.CITEXT && column.type instanceof DataTypes.CITEXT)
          || column.type === 'citext') { // TODO: Remove 'citext' once Sequelize 4 has been deprecated.
    Severity: Minor
    Found in src/services/apimap-field-type-detector.js - About 1 hr to fix

      Avoid too many return statements within this function.
      Wontfix

            return 'Uuid';
      Severity: Major
      Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return 'Point';
        Severity: Major
        Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return 'Number';
          Severity: Major
          Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return 'Json';
            Severity: Major
            Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return [new ApimapFieldTypeDetector({ type: column.type.type }, options).perform()];
              Severity: Major
              Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return 'Time';
                Severity: Major
                Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return null;
                  Severity: Major
                  Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return 'Date';
                    Severity: Major
                    Found in src/services/apimap-field-type-detector.js - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status