RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Avoid deeply nested control flow statements.
Open

                    if (value !== undefined) {
                        _.set(target, f, value);
                    }
Severity: Major
Found in lib/engine/routeinjector/newdenormalizer.js - About 45 mins to fix

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

    function routeConfigurationCheck(config, method) {
        var routesRestrictions = injector.config.env.restrictions || {};
        var allowed = true;
    
        if ((routesRestrictions.blacklist && routesRestrictions.blacklist.routes) || (routesRestrictions.whitelist && routesRestrictions.whitelist.routes)) {
    Severity: Minor
    Found in lib/engine/routeinjector/utils.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

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

    function walkSchema(app, Model, schema, parentName, fromArray, rawPath) {
    Severity: Minor
    Found in lib/engine/routeinjector/typeBased.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (i == 0) {
                                  fileName = sourceFileName;
                              } else {
                                  fileName = addStringBeforeExtension(sourceFileName, '_' + i);
                              }
      Severity: Major
      Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

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

        var TypeBased = /** @class */ (function () {
            function TypeBased() {
            }
            //TODO: Add hooks and middlewares
            TypeBased.directReference = function (model, field, refModel, refField) {
        Severity: Minor
        Found in lib/engine/routeinjector/newTypeBased/TypeBased.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

                            for (let field of Model.schema.paths[key].options.denormalize)
                                validFields.push(key + "." + field);
        Severity: Major
        Found in lib/engine/routeinjector/rest/export.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (i == 0) {
                                      fileName = sourceFileName;
                                  } else {
                                      fileName = addStringBeforeExtension(sourceFileName, '_' + i);
                                  }
          Severity: Major
          Found in lib/engine/routeinjector/images/new-image-injector.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                for (var i in doc) {
                                    if (doc.hasOwnProperty(i)) {
                                        //Prune all the elements in the object
                                        doc[i] = prune(doc[i]);
                                    }
            Severity: Major
            Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

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

              function injectRefs(app, baseConfig, refConfig, Model, refModel, key) {
              Severity: Minor
              Found in lib/engine/routeinjector/typeBased.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                            if (e) {
                                                                log.error(e);
                                                                res.json(e);
                                                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                                return res.end();
                Severity: Major
                Found in lib/engine/routeinjector/images/image-injector.js - About 45 mins to fix

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

                  function injectArrays(app, field, key, Model, baseConfig, rawPath) {
                  Severity: Minor
                  Found in lib/engine/routeinjector/typeBased.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (i == 0) {
                                                fileName = sourceFileName;
                                            } else {
                                                fileName = addStringBeforeExtension(sourceFileName, '_' + i);
                                            }
                    Severity: Major
                    Found in lib/engine/routeinjector/images/image-injector.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                                              if (e) {
                                                                                  log.error(e);
                                                                                  res.json(e);
                                                                                  res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                                                  return res.end();
                      Severity: Major
                      Found in lib/engine/routeinjector/images/new-image-injector.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if (parent) {
                                                var child = element.substring(parentPath.length + 1);
                                                return module.exports.getElementSchema(parent.schema.paths, child);
                                            }
                        Severity: Major
                        Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if (Object.keys(objDoc).length > 0) {
                                                  for (var i in objDoc) {
                                                      if (objDoc.hasOwnProperty(i)) {
                                                          //Prune all the elements in the object
                                                          //Although we are working with the plain object, we COPY and PRUNE the original object
                          Severity: Major
                          Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

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

                            module.exports.getInvRefField = function (Model, refModel, field) {
                                return function (req, res) {
                                    var gConfig = Model.injector();
                                    var config = utils.getConfigByProfile(gConfig.get, req);
                                    (config.pre) ? utils.runPreCallbacks(config.pre, Model, req, res, mainGetFn) : mainGetFn();
                            Severity: Minor
                            Found in lib/engine/routeinjector/typeBased/typeBased.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 (objDoc == null || objDoc == undefined) {
                                                    //Null objects marked as undefined
                                                    doc = undefined;
                                                }
                            Severity: Major
                            Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

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

                              function injectArrays(app, field, key, Model, baseConfig, rawPath) {
                                  log.debug("Inject array methods for model " + Model.modelName + " and field " + key);
                                  //app.get(gConfig.apiBasePath + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key, refs.getAllArray(Model, key));
                                  //app.get(gConfig.apiBasePath + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key + '/:index', refs.getArrayElementAt(Model, key));
                              
                              Severity: Minor
                              Found in lib/engine/routeinjector/typeBased.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 (e) {
                                                                              log.error(e);
                                                                              res.json(e);
                                                                              res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                                              return res.end();
                              Severity: Major
                              Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if (parentPath) {
                                                        parentPath += "." + chunk
                                                    } else {
                                                        parentPath = chunk;
                                                    }
                                Severity: Major
                                Found in lib/engine/routeinjector/utils.js - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language