RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

    if (field.class) {
        var sc = getElementSchema(Model.schema.paths, fullKey);
        if (sc) {
            sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
            sc.options["x-schema-form"]["htmlClass"] = field.class;
Severity: Major
Found in lib/engine/routeinjector/typeBased.js and 4 other locations - About 2 hrs to fix
lib/engine/routeinjector/typeBased.js on lines 101..107
lib/engine/routeinjector/typeBased.js on lines 109..115
lib/engine/routeinjector/typeBased.js on lines 117..123
lib/engine/routeinjector/typeBased.js on lines 125..131

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

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

    PluginRegistry.prototype.getPluginsWithRoutes = function () {
        var plugins = [];
        this.forEachPlugin(function (metaPlugin) {
            if (metaPlugin.plugin.routes && metaPlugin.plugin.routes.length) {
                plugins.push(metaPlugin);
Severity: Major
Found in lib/app/internals/PluginRegistry.js and 1 other location - About 2 hrs to fix
lib/app/internals/PluginRegistry.js on lines 69..77

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

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

    PluginRegistry.prototype.getPluginsWithStatics = function () {
        var plugins = [];
        this.forEachPlugin(function (plugin) {
            if (plugin.plugin.statics && plugin.plugin.statics.length) {
                plugins.push(plugin);
Severity: Major
Found in lib/app/internals/PluginRegistry.js and 1 other location - About 2 hrs to fix
lib/app/internals/PluginRegistry.js on lines 93..101

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

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 mainGetFn has 67 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

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

        ExpressManager.prototype.exportRoutes = function () {
            var _this = this;
            ExpressManager.logger.debug("Exporting routes");
            this.routeLoader.forEachRouteFile(function (route) {
                route(_this.app);
    Severity: Major
    Found in lib/app/internals/ExpressManager.js and 1 other location - About 2 hrs to fix
    lib/app/internals/ExpressManager.js on lines 92..99

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

    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

        ExpressManager.prototype.exportMiddlewares = function () {
            var _this = this;
            ExpressManager.logger.debug("Exporting middlewares");
            this.middlewareRegistry.forEachMiddleware(function (middleware) {
                middleware(_this.app);
    Severity: Major
    Found in lib/app/internals/ExpressManager.js and 1 other location - About 2 hrs to fix
    lib/app/internals/ExpressManager.js on lines 103..110

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

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

    module.exports.getQueriedRefField = 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

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

                  if(gConfig.id == "_id" && !mongoose.Types.ObjectId.isValid(req.params[gConfig.id])){
                      res.statusCode = statusCode.NOT_FOUND;
                      res.json("Document not found. Invalid mongoose id");
                      return res.end();
                  }
      Severity: Major
      Found in lib/engine/routeinjector/rest/get.js and 1 other location - About 2 hrs to fix
      lib/engine/routeinjector/rest/put.js on lines 22..26

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

      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.id == "_id" && !mongoose.Types.ObjectId.isValid(req.params[gConfig.id])) {
                      res.statusCode = statusCode.NOT_FOUND;
                      res.json("Document not found. Invalid mongoose id");
                      return res.end();
                  }
      Severity: Major
      Found in lib/engine/routeinjector/rest/put.js and 1 other location - About 2 hrs to fix
      lib/engine/routeinjector/rest/get.js on lines 25..29

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

      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 FSUtils has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      var FSUtils = /** @class */ (function () {
          function FSUtils() {
          }
          /**
           * Get the directories from the existing src path
      Severity: Minor
      Found in lib/utils/FSUtils.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 jsonform has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      var jsonform = function (schema, options) {
      
          var shardKey = undefined;
          if (schema.statics.injector) {
              var injector = schema.statics.injector();
      Severity: Minor
      Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.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 pruneDocument has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.pruneDocument = function (indoc) {
          return prune(indoc);
      
          function prune(doc) {
              if (doc instanceof Array) {
      Severity: Major
      Found in lib/engine/routeinjector/utils.js - About 2 hrs to fix

        File GalleryInjector.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        "use strict";
        var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
            return new (P || (P = Promise))(function (resolve, reject) {
                function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
                function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        Severity: Minor
        Found in lib/engine/routeinjector/images/GalleryInjector.js - About 2 hrs to fix

          Similar blocks of code found in 5 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/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 2 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 26..28
          lib/engine/routeinjector/typeBased/typeBased.js on lines 196..198
          lib/engine/routeinjector/typeBased/typeBased.js on lines 424..426
          lib/engine/routeinjector/typeBased/typeBased.js on lines 518..520

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

          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 5 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/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 2 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 108..110
          lib/engine/routeinjector/typeBased/typeBased.js on lines 196..198
          lib/engine/routeinjector/typeBased/typeBased.js on lines 424..426
          lib/engine/routeinjector/typeBased/typeBased.js on lines 518..520

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

          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 5 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/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 2 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 26..28
          lib/engine/routeinjector/typeBased/typeBased.js on lines 108..110
          lib/engine/routeinjector/typeBased/typeBased.js on lines 424..426
          lib/engine/routeinjector/typeBased/typeBased.js on lines 518..520

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

          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 5 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/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 2 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 26..28
          lib/engine/routeinjector/typeBased/typeBased.js on lines 108..110
          lib/engine/routeinjector/typeBased/typeBased.js on lines 196..198
          lib/engine/routeinjector/typeBased/typeBased.js on lines 424..426

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

          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 5 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/engine/routeinjector/typeBased/typeBased.js and 4 other locations - About 2 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 26..28
          lib/engine/routeinjector/typeBased/typeBased.js on lines 108..110
          lib/engine/routeinjector/typeBased/typeBased.js on lines 196..198
          lib/engine/routeinjector/typeBased/typeBased.js on lines 518..520

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

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

                  function mainPutFn() {
                      //Check incoming Model
                      if (req.body == undefined || req.body.element == undefined) {
                          res.statusCode = statusCode.BAD_REQUEST;
                          res.json("The body must containt the \"element\" key");
          Severity: Major
          Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

            Function mainPutFn has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function mainPutFn() {
                        //Check incoming Model
                        if (req.body == undefined || req.body.element == undefined) {
                            res.statusCode = statusCode.BAD_REQUEST;
                            res.json("The body must containt the \"element\" key");
            Severity: Major
            Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language