RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function Configurations has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Configurations = /** @class */ (function () {
    function Configurations() {
        if (Configurations.configHolder) {
            throw new Error("Don't instantiate directly a configuration");
        }
Severity: Minor
Found in lib/app/internals/Configurations.js - About 1 hr to fix

    Function configureForm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.configureForm = function (Model) {
        var inj = Model.injector();
        if (inj.form && inj.form.tabs) {
            for (var t in inj.form.tabs) {
                var tab = inj.form.tabs[t];
    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 isRoleAcceptable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private isRoleAcceptable(role, user) {
            var config = this.config;
            var restrictions = this.config.env.restrictions;
            if (config.permissions.adminRole && user.role == config.permissions.adminRole) {
                return true;
    Severity: Minor
    Found in lib/app/internals/AuthManager.ts - 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 iterateCursor has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        HooksUtils.iterateCursor = function (cursor, limit, func, ctx) { return __awaiter(_this, void 0, void 0, function () {
            var partial, state, doc_1, next, _a, result, _b, err_1;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
    Severity: Minor
    Found in lib/utils/HooksUtils.js - About 1 hr to fix

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

              function mainGetNPostFn() {
                  var format = req.body.format || req.query.format || "csv";
                  var query = req.body.query;
      
                  var options = {};
      Severity: Minor
      Found in lib/engine/routeinjector/rest/export.js - About 1 hr to fix

        Function genDenorm has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function genDenorm(dest, src, denormalized, confRid, plain, doc, path) {
            if (src) {
                dest = {};
                var target;
                if (plain == true) {
        Severity: Minor
        Found in lib/engine/routeinjector/newdenormalizer.js - About 1 hr to fix

          Function TranslationRepository has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var TranslationRepository = /** @class */ (function () {
              function TranslationRepository(config, pluginRegistry) {
                  this.i18nDirs = [];
                  this.i18nFiles = [];
                  TranslationRepository.logger.trace("Creating TranslationRepository instance");
          Severity: Minor
          Found in lib/app/internals/TranslationRepository.js - About 1 hr to fix

            Function RouteInjector has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            var RouteInjector = /** @class */ (function () {
                //private middlewareRegistry:MiddlewareRegistry;
                function RouteInjector() {
                    this.version = require('../../package.json').version;
                    this.cache = { middlewares: {} };
            Severity: Minor
            Found in lib/app/RouteInjector.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 PassportLocal has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function PassportLocal(config) {
                    var _this = this;
                    this.tokens = require('../../../engine/routeinjector/routes/auth/tokens');
                    var jwt = require('jsonwebtoken');
                    var BearerStrategy = require('passport-http-bearer');
            Severity: Minor
            Found in lib/app/internals/auth/PassportLocal.js - About 1 hr to fix

              Function geograph has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.geograph = function (Model, geograph) {
              
                  var geoField = geograph.geoField;
                  var groupBy = geograph.groupBy || "";
                  var defaultQuery = geograph.query || {};
              Severity: Minor
              Found in lib/engine/routeinjector/graphs/geograph.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if ((routesRestrictions.blacklist && routesRestrictions.blacklist.routes) || (routesRestrictions.whitelist && routesRestrictions.whitelist.routes)) {
                        allowed = (routesRestrictions.whitelist && routesRestrictions.whitelist.routes && routesRestrictions.whitelist.routes.indexOf(method) > -1) ||
                            (routesRestrictions.blacklist && routesRestrictions.blacklist.routes && routesRestrictions.blacklist.routes.indexOf(method) == -1);
                    }
                Severity: Critical
                Found in lib/engine/routeinjector/utils.js - About 1 hr to fix

                  Function exports has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function (injector) {
                      log = RouteInjector.log;
                      config = injector.config.auth;
                  
                      // Passport
                  Severity: Minor
                  Found in lib/engine/routeinjector/routes/auth/passport-local.js - About 1 hr to fix

                    Function processAllPermissionsByRole has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private processAllPermissionsByRole() {
                            var result = {};
                            var allModels = Object.keys(this.holder.routes);
                            var verbs = ["get", "post", "delete", "search", "put", "export", "import", "menu"];
                    
                    
                    Severity: Minor
                    Found in lib/app/internals/auth/PermissionsLoader.ts - About 1 hr to fix

                      Function processAllPermissionsByRole has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          PermissionsLoader.prototype.processAllPermissionsByRole = function () {
                              var result = {};
                              var allModels = Object.keys(this.holder.routes);
                              var verbs = ["get", "post", "delete", "search", "put", "export", "import", "menu"];
                              for (var modelName in this.holder.routes) {
                      Severity: Minor
                      Found in lib/app/internals/auth/PermissionsLoader.js - About 1 hr to fix

                        Function handleGetImage has a Cognitive Complexity of 13 (exceeds 5 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: Minor
                        Found in lib/engine/routeinjector/images/GalleryInjector.ts - 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 checkSetup has 39 lines of code (exceeds 25 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

                          Function getType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function getType(pathString, mongotype) {
                                  switch (mongotype) {
                                      case('String'):
                                      case('SchemaString'):
                                          return {type: 'string'};
                          Severity: Minor
                          Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 1 hr to fix

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

                                function AuthManager(config, models) {
                                    var _this = this;
                                    this.checkRole = function (role) { return ({
                                        name: 'checkRole(' + role + ')',
                                        middleware: function (req, res, next) {
                            Severity: Minor
                            Found in lib/app/internals/AuthManager.js - About 1 hr to fix

                              Function constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  constructor(parentOptions, RIOptions) {
                                      super(parentOptions);
                              
                                      RIOptions.res.attachment(RIOptions.modelName + RIOptions.format);
                              
                              Severity: Minor
                              Found in lib/engine/routeinjector/rest/export.js - About 1 hr to fix

                                Function constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    constructor(config:any) {
                                        var jwt = require('jsonwebtoken');
                                        var BearerStrategy = require('passport-http-bearer');
                                        this.config = config;
                                        passport.use(new BearerStrategy((token, done) => {
                                Severity: Minor
                                Found in lib/app/internals/auth/PassportLocal.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language