RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

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

            if (gConfig.shard && gConfig.shard.shardKey && req.query[gConfig.shard.shardKey] !== undefined) {
                query[gConfig.shard.shardKey] = req.query[gConfig.shard.shardKey];
            }
    Severity: Major
    Found in lib/utils/QueryUtils.ts and 1 other location - About 2 hrs to fix
    lib/utils/QueryUtils.ts on lines 91..93

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

    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 (gConfig.shard && gConfig.shard.shardKey && req.query[gConfig.shard.shardKey] !== undefined) {
                query[gConfig.shard.shardKey] = req.query[gConfig.shard.shardKey];
            }
    Severity: Major
    Found in lib/utils/QueryUtils.ts and 1 other location - About 2 hrs to fix
    lib/utils/QueryUtils.ts on lines 64..66

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

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

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

      module.exports.iterate = function it(fullPath, doc, iterator, callback, parents) {
      
          var paths = fullPath.split('.');
          parents = parents || [];
      
      Severity: Major
      Found in lib/engine/routeinjector/utils.js - About 2 hrs to fix

        Function injectImages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.injectImages = function (_app, param) {
        
            var imageConf = injector.config.env.images;
            imagePath = imageConf.path;
            cachePath = imageConf.cache;
        Severity: Minor
        Found in lib/engine/routeinjector/images/image-injector.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 injectImages has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.injectImages = function (_app, param) {
        
            var imageConf = injector.config.env.images;
            imagePath = imageConf.path;
            cachePath = imageConf.cache;
        Severity: Minor
        Found in lib/engine/routeinjector/images/new-image-injector.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 ExpressManager has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        var ExpressManager = /** @class */ (function () {
            function ExpressManager(config, pluginRegistry, pageLoader) {
                this.app = express();
                ExpressManager.logger.trace("Creating ExpressManager instance");
                this.config = config;
        Severity: Minor
        Found in lib/app/internals/ExpressManager.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

        File newdenormalizer.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        var utils = require('./utils');
        var Q = require('q');
        var _ = require('lodash');
        var injector = require('../../');
        var async = require('async');
        Severity: Minor
        Found in lib/engine/routeinjector/newdenormalizer.js - About 2 hrs to fix

          Function toDB has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              Model.injector()._references.toDB = function (doc, cb) {
                  var defer = Q.defer();
                  var self = doc;
                  var promises = [];
          
          Severity: Major
          Found in lib/engine/routeinjector/newdenormalizer.js - About 2 hrs to fix

            Function getRefField has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports.getRefField = 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 mainGetFn has 59 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

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

                                function postCallbacks(doc) {
                                    var defer = Q.defer();
                                    if (config.post) {
                                        utils.runPostCallbacks(config, req, res, doc, function () {
                                            defer.resolve(doc);
                Severity: Major
                Found in lib/engine/routeinjector/rest/post.js and 1 other location - About 2 hrs to fix
                lib/engine/routeinjector/rest/put.js on lines 62..73

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

                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 postCallbacks(doc) {
                                    var defer = Q.defer();
                                    if (config.post) {
                                        utils.runPostCallbacks(config, req, res, doc, function () {
                                            defer.resolve(doc);
                Severity: Major
                Found in lib/engine/routeinjector/rest/put.js and 1 other location - About 2 hrs to fix
                lib/engine/routeinjector/rest/post.js on lines 56..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 82.

                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 propagate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        RefModel.injector()._references.propagate = function (doc) {
                            var models = Object.keys(RefModel.injector()._references.propagations);
                            var promises = [];
                
                            async.each(models, function (item, cb) {
                Severity: Major
                Found in lib/engine/routeinjector/newdenormalizer.js - About 2 hrs to fix

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

                          } else if (!(field.dependsOn.params instanceof Array)) {
                              var sc = getElementSchema(Model.schema.paths, fullKey);
                              if (sc) {
                                  var params = [];
                                  params.push(sc.options.dependsOn.params);
                  Severity: Major
                  Found in lib/engine/routeinjector/typeBased.js and 1 other location - About 2 hrs to fix
                  lib/engine/routeinjector/typeBased.js on lines 158..172

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

                  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 (!field.dependsOn.params) {
                              var sc = getElementSchema(Model.schema.paths, fullKey);
                              if (sc) {
                                  var params = [];
                                  params.push(sc.options.dependsOn.field);
                  Severity: Major
                  Found in lib/engine/routeinjector/typeBased.js and 1 other location - About 2 hrs to fix
                  lib/engine/routeinjector/typeBased.js on lines 165..172

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

                  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

                                  function checkDocument(doc) {
                                      var defer = Q.defer();
                                      if (!doc) {
                                          res.statusCode = statusCode.NOT_FOUND;
                                          defer.reject('Document not found');
                  Severity: Major
                  Found in lib/engine/routeinjector/rest/put.js and 1 other location - About 2 hrs to fix
                  lib/engine/routeinjector/rest/delete.js on lines 52..61

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

                  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

                      public getPluginsWithRoutes():IMetaPlugin[] {
                          var plugins = [];
                          this.forEachPlugin((metaPlugin:IMetaPlugin)=> {
                              if (metaPlugin.plugin.routes && metaPlugin.plugin.routes.length) {
                                  plugins.push(metaPlugin);
                  Severity: Major
                  Found in lib/app/internals/PluginRegistry.ts and 1 other location - About 2 hrs to fix
                  lib/app/internals/PluginRegistry.ts on lines 82..90

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

                  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

                      public getPluginsWithStatics():IMetaPlugin[] {
                          var plugins = [];
                          this.forEachPlugin((plugin:IMetaPlugin)=> {
                              if (plugin.plugin.statics && plugin.plugin.statics.length) {
                                  plugins.push(plugin);
                  Severity: Major
                  Found in lib/app/internals/PluginRegistry.ts and 1 other location - About 2 hrs to fix
                  lib/app/internals/PluginRegistry.ts on lines 108..116

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

                  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