RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function walkSchema has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

function walkSchema(app, Model, schema, parentName, fromArray, rawPath) {
    var modelConfig = utils.getModels()[Model.modelName];
    for (var key in schema) {
        var field = schema[key];
Severity: Minor
Found in lib/engine/routeinjector/typeBased.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 process has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                        function process() {

                            var outFile = path.join(outDirectory, fileName);//path.basename(req.files.image.path));

                            var fileToDb = {
Severity: Major
Found in lib/engine/routeinjector/images/new-image-injector.js - About 3 hrs to fix

    Function post has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function login has 89 lines of code (exceeds 25 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: Major
      Found in lib/engine/routeinjector/routes/auth.js - About 3 hrs to fix

        Function PluginRegistry has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function process has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                              function process() {
          
                                  var outFile = path.join(outDirectory, fileName);//path.basename(req.files.image.path));
                                  log.debug('File: ', outFile);
          
          Severity: Major
          Found in lib/engine/routeinjector/images/image-injector.js - About 3 hrs to fix

            Function process has 86 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                                function process() {
            
                                    var outFile = path.join(outDirectory, fileName);//path.basename(req.files.file.path));
                                    log.debug('File: ', outFile);
            
            Severity: Major
            Found in lib/engine/routeinjector/files/file-injector.js - About 3 hrs to fix

              Function transform has 86 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function transform(Model, key, fullKey, modelConfig, field) {
                  /*var sc = getElementSchema(Model.schema.paths, fullKey);
                   if(sc){
                   sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                   sc.options["x-schema-form"]["disableSuccessState"] = true;
              Severity: Major
              Found in lib/engine/routeinjector/typeBased.js - About 3 hrs to fix

                Function mainDeleteFn has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Function expressSetup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function expressSetup(app, config) {
                      app.set('views', FSUtils.join(config.appPath, 'views'));
                      app.set('view engine', config.application.view_engine || 'ejs');
                      logger.token('body', function getUrlToken(req) {
                          return req.__body || "";
                  Severity: Minor
                  Found in lib/app/internals/express/ExpressMiddlewares.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 expressSetup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function expressSetup(app:Express, config:any) {
                  
                      app.set('views', FSUtils.join(config.appPath, 'views'));
                      app.set('view engine', config.application.view_engine || 'ejs');
                  
                  
                  Severity: Minor
                  Found in lib/app/internals/express/ExpressMiddlewares.ts - 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 getByField has 84 lines of code (exceeds 25 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: Major
                  Found in lib/engine/routeinjector/rest/get.js - About 3 hrs to fix

                    Function TypeBased has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var TypeBased = /** @class */ (function () {
                        function TypeBased() {
                        }
                        //TODO: Add hooks and middlewares
                        TypeBased.directReference = function (model, field, refModel, refField) {
                    Severity: Major
                    Found in lib/engine/routeinjector/newTypeBased/TypeBased.js - About 3 hrs to fix

                      Function AuthManager has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      var AuthManager = /** @class */ (function () {
                          function AuthManager(config, models) {
                              var _this = this;
                              this.checkRole = function (role) { return ({
                                  name: 'checkRole(' + role + ')',
                      Severity: Major
                      Found in lib/app/internals/AuthManager.js - About 3 hrs to fix

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

                            GalleryInjector.prototype.handleGetImage = function () {
                                var _this = this;
                                var IMGR = require('imgr').IMGR;
                                var config = this.routeInjector.config.env.images.imgrConfig || {};
                                if (config.optimisation == undefined) {
                        Severity: Major
                        Found in lib/engine/routeinjector/images/GalleryInjector.js - About 3 hrs to fix

                          Function PageLoader has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

                            Function denormalize has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                            Open

                            module.exports.denormalize = function (field, rkey, Model, isArray, fullPath) {
                                var needsFromDBhook = true;
                                var denormalizedFields = field.denormalize;
                                log.debug("Adding denormalized params :\"" + denormalizedFields + "\" to field " + fullPath + " in model " + Model.modelName);
                            
                            Severity: Minor
                            Found in lib/engine/routeinjector/newdenormalizer.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 mainPostFn has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    function mainPostFn() {
                                        var documentDB;
                                        var newModel = {};
                                        //Check incoming body has value
                                        if (req.body != undefined && req.body) {
                            Severity: Major
                            Found in lib/engine/routeinjector/rest/post.js - About 3 hrs to fix

                              Function punchgraph has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              module.exports.punchgraph = function (Model, punchcard) {
                              
                                  var dateField = punchcard.dateField;
                                  var groupBy = punchcard.groupBy || "";
                                  var defaultQuery = punchcard.query || {};
                              Severity: Major
                              Found in lib/engine/routeinjector/graphs/punchgraph.js - About 3 hrs to fix

                                Function getElementSchema has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                                Open

                                module.exports.getElementSchema = function (paths, element) {
                                    var sc = paths[element];
                                    if (sc) {
                                        return sc;
                                    } else {
                                Severity: Minor
                                Found in lib/engine/routeinjector/utils.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

                                Severity
                                Category
                                Status
                                Source
                                Language