RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function PassportLocal has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var PassportLocal = /** @class */ (function () {
    //TODO: Use IAuthConfig when defining strategies on a next steps of this refactor
    function PassportLocal(config) {
        var _this = this;
        this.tokens = require('../../../engine/routeinjector/routes/auth/tokens');
Severity: Major
Found in lib/app/internals/auth/PassportLocal.js - About 3 hrs to fix

    Function mainGetFn has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function mainGetFn() {
                
                //ID CHECKING
                if(gConfig.id == "_id" && !mongoose.Types.ObjectId.isValid(req.params[gConfig.id])){
                    res.statusCode = statusCode.NOT_FOUND;
    Severity: Major
    Found in lib/engine/routeinjector/rest/get.js - About 3 hrs to fix

      Function getInvRefField has 74 lines of code (exceeds 25 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: Major
      Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

        Function HooksUtils has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var HooksUtils = /** @class */ (function () {
            function HooksUtils() {
            }
            HooksUtils.funcMerge = function (funcArray) {
                return function (doc, cb, state) { return __awaiter(_this, void 0, void 0, function () {
        Severity: Major
        Found in lib/utils/HooksUtils.js - About 2 hrs to fix

          Function jsonform has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              schema.methods.jsonform = function (opt) {
                  var self = this;
                  var jf = {};
                  if (!opt) opt = {excluded: [], includes: '*', setDefaults: false};
                  if (!opt.includes) opt.includes = '*';
          Severity: Major
          Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 2 hrs to fix

            Function postArrayElementAt has 71 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports.postArrayElementAt = function (Model, key) {
            
                return function (req, res) {
                    var gConfig = Model.injector();
                    var field = gConfig.id;
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

              Function appendArrayElement has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.appendArrayElement = function (Model, key) {
              
                  return function (req, res) {
                      var gConfig = Model.injector();
                      var field = gConfig.id;
              Severity: Major
              Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                Function getFormConfig has 71 lines of code (exceeds 25 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: Major
                Found in lib/engine/routeinjector/routes/model.js - About 2 hrs to fix

                  Function handleGetImage has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private handleGetImage() {
                          let IMGR = require('imgr').IMGR;
                          let config = this.routeInjector.config.env.images.imgrConfig || {};
                          if (config.optimisation == undefined) {
                              config.optimisation = this.optimiseImage;
                  Severity: Major
                  Found in lib/engine/routeinjector/images/GalleryInjector.ts - About 2 hrs to fix

                    Function mongoConfigurationCheck has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function mongoConfigurationCheck(config, gConfig, method) {
                        if (config.profiles == undefined) {
                            config.profiles = {};
                        }
                    
                    Severity: Minor
                    Found in lib/engine/routeinjector/utils.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 mainGetFn has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function mainGetFn() {
                                var query = {};
                                for (var i in config.mongo.query) {
                                    //COPY the object
                                    query[i] = config.mongo.query[i];
                    Severity: Major
                    Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                      Function getQueriedRefField has 66 lines of code (exceeds 25 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: Major
                      Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

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

                        var jsonform = function (schema, options) {
                        
                            var shardKey = undefined;
                            if (schema.statics.injector) {
                                var injector = schema.statics.injector();
                        Severity: Minor
                        Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.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 FSUtils has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        var FSUtils = /** @class */ (function () {
                            function FSUtils() {
                            }
                            /**
                             * Get the directories from the existing src path
                        Severity: Minor
                        Found in lib/utils/FSUtils.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 pruneDocument has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports.pruneDocument = function (indoc) {
                            return prune(indoc);
                        
                            function prune(doc) {
                                if (doc instanceof Array) {
                        Severity: Major
                        Found in lib/engine/routeinjector/utils.js - About 2 hrs to fix

                          File GalleryInjector.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          "use strict";
                          var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
                              return new (P || (P = Promise))(function (resolve, reject) {
                                  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
                                  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
                          Severity: Minor
                          Found in lib/engine/routeinjector/images/GalleryInjector.js - About 2 hrs to fix

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

                                    function mainPutFn() {
                                        //Check incoming Model
                                        if (req.body == undefined || req.body.element == undefined) {
                                            res.statusCode = statusCode.BAD_REQUEST;
                                            res.json("The body must containt the \"element\" key");
                            Severity: Major
                            Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

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

                                      function mainPutFn() {
                                          //Check incoming Model
                                          if (req.body == undefined || req.body.element == undefined) {
                                              res.statusCode = statusCode.BAD_REQUEST;
                                              res.json("The body must containt the \"element\" key");
                              Severity: Major
                              Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                                Function parseSchema has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        function parseSchema(subschema, out, fullPath) {
                                            subschema.eachPath(function (pathString, pathO) {
                                
                                                var include = excludedPaths.indexOf(pathString) === -1;
                                                if (include && opt.includes != '*')
                                Severity: Major
                                Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 2 hrs to fix

                                  Function prune has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      function prune(doc) {
                                          if (doc instanceof Array) {
                                              var objDoc = {};
                                  
                                              //CAREFUL!!! --> Strictly necessary iterate over the plain object
                                  Severity: Major
                                  Found in lib/engine/routeinjector/utils.js - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language