RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function getNDocumentsPost has 148 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.getNDocumentsPost = function (Model) {

    return function (req, res) {
        if (!req.body) req.body = {};
        if (!req.body.query) req.body.query = {};
Severity: Major
Found in lib/engine/routeinjector/rest/search.js - About 5 hrs to fix

    Function getByField has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.getByField = function (Model) {
    
        return function (req, res) {
            var gConfig = Model.injector();
            var isTypeBack = (req.query.type && req.query.type == "back"); //Special for filter normalizations
    Severity: Minor
    Found in lib/engine/routeinjector/rest/get.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 jsonform has 147 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var jsonform = function (schema, options) {
    
        var shardKey = undefined;
        if (schema.statics.injector) {
            var injector = schema.statics.injector();
    Severity: Major
    Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 5 hrs to fix

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

      module.exports.export = function (Model) {
          /*var doc = new Model({});
           var schema = doc.jsonform({});
      
           var validFields = [];
      Severity: Minor
      Found in lib/engine/routeinjector/rest/export.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 mainPutFn has 142 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function mainPutFn() {
                  //ID CHECKING
                  if (gConfig.id == "_id" && !mongoose.Types.ObjectId.isValid(req.params[gConfig.id])) {
                      res.statusCode = statusCode.NOT_FOUND;
                      res.json("Document not found. Invalid mongoose id");
      Severity: Major
      Found in lib/engine/routeinjector/rest/put.js - About 5 hrs to fix

        Function FSUtils has 142 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var FSUtils = /** @class */ (function () {
            function FSUtils() {
            }
            /**
             * Get the directories from the existing src path
        Severity: Major
        Found in lib/utils/FSUtils.js - About 5 hrs to fix

          File new-image-injector.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          var mkdirp = require('mkdirp');
          var fs = require('fs');
          var glob = require('glob');
          var async = require('async');
          var path = require('path');
          Severity: Minor
          Found in lib/engine/routeinjector/images/new-image-injector.js - About 5 hrs to fix

            Function mainGetNPostFn has 137 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function mainGetNPostFn() {
                        var query = req.body.query;
            
                        function validateOID(q) {
                            _.forOwn(q, function (value, key) {
            Severity: Major
            Found in lib/engine/routeinjector/rest/search.js - About 5 hrs to fix

              Function insertImage has 122 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function insertImage(param) {
                  return function (req, res) {
                      var outDirectory = param.out;
                      if (req.files.image != undefined) {
                          //ext includes '.'
              Severity: Major
              Found in lib/engine/routeinjector/images/new-image-injector.js - About 4 hrs to fix

                Function ModelsLoader has 116 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var ModelsLoader = /** @class */ (function () {
                    function ModelsLoader(config, pluginRegistry) {
                        this._models = {};
                        ModelsLoader.logger.trace("Creating ModelsLoader instance");
                        this.config = config;
                Severity: Major
                Found in lib/app/internals/ModelsLoader.js - About 4 hrs to fix

                  Function insertFile has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function insertFile(param) {
                      return function (req, res) {
                          var outDirectory = param.out;
                          if (req.files.file != undefined) {
                              //ext includes '.'
                  Severity: Major
                  Found in lib/engine/routeinjector/files/file-injector.js - About 4 hrs to fix

                    Function insertImage has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function insertImage(param) {
                        return function (req, res) {
                            var outDirectory = param.out;
                            if (req.files.image != undefined) {
                                //ext includes '.'
                    Severity: Major
                    Found in lib/engine/routeinjector/images/image-injector.js - About 4 hrs to fix

                      Function GalleryInjector has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                      var GalleryInjector = /** @class */ (function () {
                          function GalleryInjector(routeInjector) {
                              var _this = this;
                              this.fileExistsMiddleware = function (req, res, next) {
                                  var reqPath = req.params.path;
                      Severity: Minor
                      Found in lib/engine/routeinjector/images/GalleryInjector.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

                      File typeBased.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      var utils = require('../utils');
                      var statusCode = require('http-status-codes');
                      var confs = utils.getModels();
                      var Q = require('q');
                      
                      Severity: Minor
                      Found in lib/engine/routeinjector/typeBased/typeBased.js - About 4 hrs to fix

                        Function PermissionsLoader has 114 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        var PermissionsLoader = /** @class */ (function () {
                            function PermissionsLoader(config, modelsLoader) {
                                this.roles = [];
                                this.holder = {
                                    routes: {}
                        Severity: Major
                        Found in lib/app/internals/auth/PermissionsLoader.js - About 4 hrs to fix

                          Function getNDocumentsPost has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports.getNDocumentsPost = function (Model) {
                          
                              return function (req, res) {
                                  if (!req.body) req.body = {};
                                  if (!req.body.query) req.body.query = {};
                          Severity: Minor
                          Found in lib/engine/routeinjector/rest/search.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 getFormConfig has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports.getFormConfig = function (req, res) {
                              var modelName = req.params.modelname;
                              try {
                                  var Model = mongoose.model(modelName);
                                  var minjector = Model.injector();
                          Severity: Minor
                          Found in lib/engine/routeinjector/routes/model.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

                          File utils.js has 350 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          var async = require('async');
                          var statusCode = require('http-status-codes');
                          var _ = require('lodash');
                          var Q = require('q');
                          
                          Severity: Minor
                          Found in lib/engine/routeinjector/utils.js - About 4 hrs to fix

                            Function deleteByField has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                            Open

                            module.exports.deleteByField = function (Model) {
                                return function (req, res) {
                                    var gConfig = Model.injector();
                                    var field = gConfig.id;
                                    var config = utils.getConfigByProfile(gConfig.delete, req);
                            Severity: Minor
                            Found in lib/engine/routeinjector/rest/delete.js - About 3 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 deleteByField has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports.deleteByField = function (Model) {
                                return function (req, res) {
                                    var gConfig = Model.injector();
                                    var field = gConfig.id;
                                    var config = utils.getConfigByProfile(gConfig.delete, req);
                            Severity: Major
                            Found in lib/engine/routeinjector/rest/delete.js - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language