RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function getConfigByProfile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.getConfigByProfile = function (gConfig, req) {
    var profile = req.query.profile || req.headers.profile;
    var config = {};

    if (profile == undefined) {
Severity: Minor
Found in lib/engine/routeinjector/utils.js - About 1 hr to fix

    Function validateItem has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function validateItem(Model, id, cb) {
                Model.findOne({_id: id}, function (err, r) {
                    if (err) {
                        log.error(err);
                        res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
    Severity: Minor
    Found in lib/engine/routeinjector/rest/validate.js - About 1 hr to fix

      Function checkSetup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.checkSetup = function (Model) {
          var mConf = Model.injector();
      
          //Limit shards based on the environment!
          if (mConf.shard && mConf.shard.shardValues) {
      Severity: Minor
      Found in lib/engine/routeinjector/utils.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 PageLoader has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      var PageLoader = /** @class */ (function () {
          function PageLoader(config, pluginRegistry) {
              this.directories = [];
              this._pages = {};
              PageLoader.logger.trace("Creating PageLoader instance");
      Severity: Minor
      Found in lib/app/internals/PageLoader.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 QueryUtils has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      var QueryUtils = /** @class */ (function () {
          function QueryUtils() {
          }
          //TODO: Add population key if present
          QueryUtils.findOne = function (operation, model, req, cb) {
      Severity: Minor
      Found in lib/utils/QueryUtils.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 endOK has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                                  function endOK(_result) {
                                      res.statusCode = statusCode.OK;
                                      var sendObj = {};
                                      sendObj.status = {};
                                      sendObj.status.count = totalCount;
      Severity: Minor
      Found in lib/engine/routeinjector/rest/search.js - About 1 hr to fix

        Function optimiseImage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            GalleryInjector.prototype.optimiseImage = function (image, callback) {
                GalleryInjector.logger.debug("OPTIMIZING ", image);
                if (/\.png$/i.test(image)) {
                    GalleryInjector.logger.debug("PNG", image);
                    image = image.replace("$", "\\$");
        Severity: Minor
        Found in lib/engine/routeinjector/images/GalleryInjector.js - About 1 hr to fix

          Function MongooseFunction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function MongooseFunction () {
                  var arg = arguments[0];
                  var type = typeof arg;
                  var toFunc = custom || toFunction;
                  var fn;
          Severity: Minor
          Found in lib/mongoose-plugins/mongoose-injector/lib/button/type.js - About 1 hr to fix

            Function login has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.login = function (req, res) {
                var loginValue = req.body.login;
                var hash = req.body.password;
                var token = req.body.token;
            
            Severity: Minor
            Found in lib/engine/routeinjector/routes/auth.js - About 55 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 select has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.select = function(Model){
                return function(req, res){
                    var config = Model.injector();
                    var graphs = config.graphs;
            
            Severity: Minor
            Found in lib/engine/routeinjector/graphs/selector.js - About 55 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 getConfigByProfile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports.getConfigByProfile = function (gConfig, req) {
                var profile = req.query.profile || req.headers.profile;
                var config = {};
            
                if (profile == undefined) {
            Severity: Minor
            Found in lib/engine/routeinjector/utils.js - About 55 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 getRefField has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports.getRefField = function (Model, field, refModel, key) {
            
                return function (req, res) {
                    var gConfig = Model.injector();
                    var config = utils.getConfigByProfile(gConfig.get, req);
            Severity: Minor
            Found in lib/engine/routeinjector/typeBased/typeBased.js - About 55 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 getQueriedRefField has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports.getQueriedRefField = function (Model, field, refModel, key) {
            
                return function (req, res) {
                    var gConfig = Model.injector();
                    var config = utils.getConfigByProfile(gConfig.get, req);
            Severity: Minor
            Found in lib/engine/routeinjector/typeBased/typeBased.js - About 55 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 RouteLoader has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            var RouteLoader = /** @class */ (function () {
                function RouteLoader(config, pluginRegistry) {
                    RouteLoader.logger.trace("Creating RouteLoader instance");
                    this.config = config;
                    this.pluginRegistry = pluginRegistry;
            Severity: Minor
            Found in lib/app/internals/RouteLoader.js - About 55 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 rejectIfErrorOrDocumentNotFound has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                TypeBased.rejectIfErrorOrDocumentNotFound = function (operation, model, err, doc, req, res, cb) {
            Severity: Major
            Found in lib/engine/routeinjector/newTypeBased/TypeBased.js - About 50 mins to fix

              Function genDenorm has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function genDenorm(dest, src, denormalized, confRid, plain, doc, path) {
              Severity: Major
              Found in lib/engine/routeinjector/newdenormalizer.js - About 50 mins to fix

                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

                                      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 (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 (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
                        Severity
                        Category
                        Status
                        Source
                        Language