BeameryHQ/Ditto

View on GitHub

Showing 17 of 19 total issues

Function map has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

async function map(document, mappings, plugins) {

    /**
     * @function processMappings
     *
Severity: Minor
Found in ditto/mappers/map.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 map has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function map(document, mappings, plugins) {

    /**
     * @function processMappings
     *
Severity: Major
Found in ditto/mappers/map.js - About 4 hrs to fix

    Function processMappings has 118 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function processMappings(mappings, document, result, parentKey) {
    
            _.each(mappings, function(path, key) {
    
                key = parentKey ? `${parentKey}.${key}` : key;
    Severity: Major
    Found in ditto/mappers/map.js - About 4 hrs to fix

      Function cleanURI has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function cleanURI(source, service) {
      
          if (!!source && typeof(source) === "string") {
      
          // Replace all spaces with nothing, and truncate to 400 chars,
      Severity: Minor
      Found in ditto/plugins/cleanURI.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 getValue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function getValue(path, subDocument) {
      
                  if (!path) return;
      
                  if (path === '!') return document;
      Severity: Minor
      Found in ditto/mappers/map.js - About 1 hr to fix

        Function parseMappings has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                            function parseMappings(result, innerResult, path, key, $value, $key) {
        Severity: Minor
        Found in ditto/mappers/map.js - About 45 mins to fix

          Function getLinkType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function getLinkType(source, service) {
          
              if (!source || typeof(source) !== "string") return null;
          
              if(!!service && MESSAGING_SERVICES.find(item => item.toLowerCase().trim() === service.toLowerCase().trim())){
          Severity: Minor
          Found in ditto/plugins/getLinkType.js - About 45 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 deeply nested control flow statements.
          Open

                                          if (!!path.prerequisite) {
                                              if (!!eval(path.prerequisite)) _.set(result, fullPath, innerResult);
                                          } else _.set(result, fullPath, innerResult);
          Severity: Major
          Found in ditto/mappers/map.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                            if (!!path.prerequisite) {
                                                if (!!eval(path.prerequisite)) _.updateWith(result, key, function(theArray){ theArray.push(innerResult); return theArray }, []);
                                            } else _.updateWith(result, key, function(theArray){ theArray.push(innerResult); return theArray }, []);
            Severity: Major
            Found in ditto/mappers/map.js - About 45 mins to fix

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

              function extractName(fullName, position) {
              
                  const ALLOWED_POSITIONS = ["firstName", "middleName", "lastName"];
              
                  if (!!fullName && typeof(fullName) === "string"
              Severity: Minor
              Found in ditto/plugins/extractName.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 _.isPlainObject(subDocument) ? _.get(subDocument, path) :  _.get(document, path);
              Severity: Major
              Found in ditto/mappers/map.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                    return plugins[functionCall].apply(null, paramteresValues);
                Severity: Major
                Found in ditto/mappers/map.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              } else return getValue(path, $value);
                  Severity: Major
                  Found in ditto/mappers/map.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        } else return null;
                    Severity: Major
                    Found in ditto/plugins/cleanURI.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return isValidValue ? applyTransformation(null, parameters.targetValue, null, subDocument) : null;
                      Severity: Major
                      Found in ditto/mappers/map.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return getValue(pathWithDefault[0], subDocument) || getValue(`${pathWithDefault[1]}`);
                        Severity: Major
                        Found in ditto/mappers/map.js - About 30 mins to fix

                          Function getLinkService has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function getLinkService(source, service) {
                          
                              if (!source || typeof(source) !== "string" || !Joi.validate(source, Joi.string().email({errorLevel: true})).error ) return null;
                              if (!!service) return service.replace(/\s\s+/g, "").trim().toLowerCase();
                          
                          
                          Severity: Minor
                          Found in ditto/plugins/getLinkService.js - About 25 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

                          Severity
                          Category
                          Status
                          Source
                          Language