RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if (modelConf.get.disable != true) {
                log.debug("Inject route: GET " + path + '/:' + identifier);
                var getMiddlewares = routeMiddlewares("get");
                app.get(prefix + '/' + path + '/:' + identifier, getMiddlewares, getByField(Model));
            }
    Severity: Major
    Found in lib/engine/routeinjector/inject.js and 1 other location - About 1 hr to fix
    lib/engine/routeinjector/inject.js on lines 172..176

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 71.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if (modelConf.put.disable != true) {
                log.debug("Inject route: PUT " + path + '/:' + identifier);
                var putMiddlewares = routeMiddlewares("put");
                app.put(prefix + '/' + path + '/:' + identifier, putMiddlewares, putByField(Model));
            }
    Severity: Major
    Found in lib/engine/routeinjector/inject.js and 1 other location - About 1 hr to fix
    lib/engine/routeinjector/inject.js on lines 159..163

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 71.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    app.get('/permissions/trace', getUserIfExists.middleware, checkRole(config.permissions.adminRole).middleware, function (req, res) {
                        res.json(injector.cache.middlewares);
                        return res.end();
                    });
        Severity: Major
        Found in lib/engine/routeinjector/inject.js and 2 other locations - About 1 hr to fix
        lib/engine/routeinjector/inject.js on lines 59..62
        lib/engine/routeinjector/inject.js on lines 64..67

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    app.get('/permissions/routes', getUserIfExists.middleware, checkRole(config.permissions.adminRole).middleware, function (req, res) {
                        res.json(injector.security.permissionsByRole);
                        return res.end();
                    });
        Severity: Major
        Found in lib/engine/routeinjector/inject.js and 2 other locations - About 1 hr to fix
        lib/engine/routeinjector/inject.js on lines 54..57
        lib/engine/routeinjector/inject.js on lines 59..62

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                    app.get('/permissions/roles', getUserIfExists.middleware, checkRole(config.permissions.adminRole).middleware, function (req, res) {
                        res.json(injector.security.permissions);
                        return res.end();
                    });
        Severity: Major
        Found in lib/engine/routeinjector/inject.js and 2 other locations - About 1 hr to fix
        lib/engine/routeinjector/inject.js on lines 54..57
        lib/engine/routeinjector/inject.js on lines 64..67

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 70.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      app.post(injector.config.routes.prefix + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key + '/:index', refs.postArrayElementAt(Model, key));
              Severity: Major
              Found in lib/engine/routeinjector/typeBased.js and 1 other location - About 1 hr to fix
              lib/engine/routeinjector/typeBased.js on lines 304..304

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 68.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      app.post(injector.config.routes.prefix + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key + '/:index', refs.postArrayElementAt(Model, key));
              Severity: Major
              Found in lib/engine/routeinjector/typeBased.js and 1 other location - About 1 hr to fix
              lib/engine/routeinjector/typeBased.js on lines 297..297

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 68.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

                    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 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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if (restrictions && restrictions.blacklist && restrictions.blacklist.shards) {
                                mConf.shard.shardValues = _.xor(restrictions.blacklist.shards, mConf.shard.shardValues);
                            }
                    Severity: Major
                    Found in lib/engine/routeinjector/utils.js and 1 other location - About 1 hr to fix
                    lib/engine/routeinjector/utils.js on lines 25..27

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                            if (restrictions && restrictions.whitelist && restrictions.whitelist.shards) {
                                mConf.shard.shardValues = _.intersection(restrictions.whitelist.shards, mConf.shard.shardValues);
                            }
                    Severity: Major
                    Found in lib/engine/routeinjector/utils.js and 1 other location - About 1 hr to fix
                    lib/engine/routeinjector/utils.js on lines 21..23

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 67.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language