RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

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

            private exportRoutes(): void {
                ExpressManager.logger.debug("Exporting routes");
                this.routeLoader.forEachRouteFile((route)=> {
                    route(this.app);
                });
        Severity: Major
        Found in lib/app/internals/ExpressManager.ts and 1 other location - About 1 hr to fix
        lib/app/internals/ExpressManager.ts on lines 117..123

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

        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

            private exportMiddlewares(): void {
                ExpressManager.logger.debug("Exporting middlewares");
                this.middlewareRegistry.forEachMiddleware((middleware)=> {
                    middleware(this.app);
                });
        Severity: Major
        Found in lib/app/internals/ExpressManager.ts and 1 other location - About 1 hr to fix
        lib/app/internals/ExpressManager.ts on lines 128..134

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

        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

                } else if (field.type == "object" && field.properties && field.properties.image && field.properties.image.format && field.properties.image.format == 'image') {
                    injectImages(app, Model, fullKey);
                } else if (field.type == "object" && field.properties && field.properties.file && field.properties.file.format && field.properties.file.format == 'file') {
                    injectFiles(app, Model, fullKey);
                } else if (field.type == "array") {
        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 213..219

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

        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

                } else if (field.type == "object" && field.properties && field.properties.file && field.properties.file.format && field.properties.file.format == 'file') {
                    injectFiles(app, Model, fullKey);
                } else if (field.type == "array") {
                    injectArrays(app, field, fullKey, Model, modelConfig, absolutePath);
                } else if (field.type == "object") {
        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 211..219

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

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

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

                    app.post(injector.config.routes.prefix + '/' + baseConfig.path + '/:' + baseConfig.id + '/' + key, refs.appendArrayElement(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 296..296

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

            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, refs.appendArrayElement(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 303..303

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

            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

                            function error(err) {
                                if (res.statsCode == statusCode.OK)
                                    res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
            
                                res.json(err.message);
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js and 1 other location - About 1 hr to fix
            lib/engine/routeinjector/typeBased/typeBased.js on lines 481..487

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

            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

                            function error(err) {
                                if (res.statsCode == statusCode.OK)
                                    res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
            
                                res.json(err.message);
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js and 1 other location - About 1 hr to fix
            lib/engine/routeinjector/typeBased/typeBased.js on lines 576..582

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

            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 5 locations. Consider refactoring.
            Open

                            if (err) {
                                log.error(err);
                                utils.runErrorCallbacks(config, req, err);
                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                res.json(err);
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 1 hr to fix
            lib/engine/routeinjector/rest/search.js on lines 87..235
            lib/engine/routeinjector/rest/search.js on lines 105..111
            lib/engine/routeinjector/typeBased/typeBased.js on lines 32..85
            lib/engine/routeinjector/typeBased/typeBased.js on lines 202..272

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

            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 5 locations. Consider refactoring.
            Open

                            if (err) {
                                log.error(err);
                                utils.runErrorCallbacks(config, req, err);
                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                res.json(err);
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 1 hr to fix
            lib/engine/routeinjector/rest/search.js on lines 87..235
            lib/engine/routeinjector/rest/search.js on lines 105..111
            lib/engine/routeinjector/typeBased/typeBased.js on lines 114..174
            lib/engine/routeinjector/typeBased/typeBased.js on lines 202..272

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

            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 5 locations. Consider refactoring.
            Open

                            if (err) {
                                log.error(err);
                                utils.runErrorCallbacks(config, req, err);
                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                res.json(err);
            Severity: Major
            Found in lib/engine/routeinjector/rest/search.js and 4 other locations - About 1 hr to fix
            lib/engine/routeinjector/rest/search.js on lines 105..111
            lib/engine/routeinjector/typeBased/typeBased.js on lines 32..85
            lib/engine/routeinjector/typeBased/typeBased.js on lines 114..174
            lib/engine/routeinjector/typeBased/typeBased.js on lines 202..272

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

            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 5 locations. Consider refactoring.
            Open

                                    if (err) {
                                        log.error(err);
                                        utils.runErrorCallbacks(config, req, err);
                                        res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                        res.json(err);
            Severity: Major
            Found in lib/engine/routeinjector/rest/search.js and 4 other locations - About 1 hr to fix
            lib/engine/routeinjector/rest/search.js on lines 87..235
            lib/engine/routeinjector/typeBased/typeBased.js on lines 32..85
            lib/engine/routeinjector/typeBased/typeBased.js on lines 114..174
            lib/engine/routeinjector/typeBased/typeBased.js on lines 202..272

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

            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 5 locations. Consider refactoring.
            Open

                            if (err) {
                                log.error(err);
                                utils.runErrorCallbacks(config, req, err);
                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                res.json(err);
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 1 hr to fix
            lib/engine/routeinjector/rest/search.js on lines 87..235
            lib/engine/routeinjector/rest/search.js on lines 105..111
            lib/engine/routeinjector/typeBased/typeBased.js on lines 32..85
            lib/engine/routeinjector/typeBased/typeBased.js on lines 114..174

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

            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.blacklist && restrictions.blacklist.roles && restrictions.blacklist.roles.indexOf(req.user.role) > -1)
                            return kick();
            Severity: Major
            Found in lib/engine/routeinjector/routes/auth/utils.js and 1 other location - About 1 hr to fix
            lib/engine/routeinjector/routes/auth/utils.js on lines 36..37

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

            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

                                                if (defaultValue && opt.setDefaults) {
                                                    pathO.options.default = defaultValue;
                                                    if (type.type == 'date') {
                                                        pathO.options.default = pathO.options.default.toISOString();
                                                    }
            lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js on lines 142..147

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

            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

            Severity
            Category
            Status
            Source
            Language