immanuel192/dtobase

View on GitHub

Showing 13 of 13 total issues

Function convertByDataType has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

function convertByDataType(datatype, input, fieldDef) {
    if (datatype === String) {
        const testMinMax = function testMinMax(inpValue) {
            const minLength = fieldDef.minLength || inpValue.length;
            const maxLength = fieldDef.maxLength || inpValue.length;
Severity: Minor
Found in src/DtoConvertion.js - About 5 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 convertBySchemaDefinition has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    convertBySchemaDefinition(SchemaModel, inputObj, errors, method = TYPE_ANY) {
        const targetObj = {};
        const schemaInstance = new SchemaModel();
        const restMethod = method.toLowerCase();

Severity: Major
Found in src/DtoConvertion.js - About 2 hrs to fix

    Function convertByDataType has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function convertByDataType(datatype, input, fieldDef) {
        if (datatype === String) {
            const testMinMax = function testMinMax(inpValue) {
                const minLength = fieldDef.minLength || inpValue.length;
                const maxLength = fieldDef.maxLength || inpValue.length;
    Severity: Major
    Found in src/DtoConvertion.js - About 2 hrs to fix

      Function convertPrimitiveDataType has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function convertPrimitiveDataType(options) {
          // normal cases
          /**
           * Result:
           * - { valid : false } when could not convert input value because of wrong datatype validating
      Severity: Minor
      Found in src/DtoConvertion.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

      Consider simplifying this complex logical expression.
      Open

          else if (result === undefined &&
              (
                  options.fieldDef.required
                  || (options.fieldDef.requiredUpdate && TYPE_UPDATE_VALIDATOR.indexOf(options.restMethod) >= 0)
                  || (options.fieldDef.requiredPut && options.restMethod === METHOD_PUT)
      Severity: Critical
      Found in src/DtoConvertion.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                            else if (
                                fieldDef.required
                                || (fieldDef.requiredUpdate && TYPE_UPDATE_VALIDATOR.indexOf(restMethod) >= 0)
                                || (fieldDef.requiredPut && restMethod === METHOD_PUT)
                                || (fieldDef.requiredPatch && restMethod === METHOD_PATCH)
        Severity: Critical
        Found in src/DtoConvertion.js - About 1 hr to fix

          Function canMatchType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function canMatchType(sourceField, type) {
              return (
                  (type === TYPE_ANY) ||
                  (type === METHOD_FIND && sourceField.canFind !== false) ||
                  (type === METHOD_GET && sourceField.canGet !== false) ||
          Severity: Minor
          Found in src/DtoConvertion.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

          Avoid deeply nested control flow statements.
          Open

                                          if (!fieldType) {
                                              throw new Error(`Could not detect model type of ${fieldName}`);
                                          }
          Severity: Major
          Found in src/DtoConvertion.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

                        return false;
            Severity: Major
            Found in src/DtoConvertion.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return ret;
              Severity: Major
              Found in src/DtoConvertion.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return undefined;
                Severity: Major
                Found in src/DtoConvertion.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return undefined;
                  Severity: Major
                  Found in src/DtoConvertion.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return (input === null || input === undefined) ? undefined : input;
                    Severity: Major
                    Found in src/DtoConvertion.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language