RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

File image-injector.js has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var mkdirp = require('mkdirp');
var fs = require('fs');
var glob = require('glob');
var async = require('async');
var path = require('path');
Severity: Minor
Found in lib/engine/routeinjector/images/image-injector.js - About 6 hrs to fix

    Function genDenorm has a Cognitive Complexity of 40 (exceeds 5 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 6 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 AuthManager has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    var AuthManager = /** @class */ (function () {
        function AuthManager(config, models) {
            var _this = this;
            this.checkRole = function (role) { return ({
                name: 'checkRole(' + role + ')',
    Severity: Minor
    Found in lib/app/internals/AuthManager.js - About 6 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 putByField has 152 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.putByField = function (Model) {
        var documentDb = {};
        var originalDoc = {};
        return function (req, res) {
            var gConfig = Model.injector();
    Severity: Major
    Found in lib/engine/routeinjector/rest/put.js - About 6 hrs to fix

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

                              refModel.findOne(newQuery, gConfig.mongo.projection, function (err, results) {
                                  if (err) {
                                      res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                      res.json(err);
                                      return res.end();
      Severity: Major
      Found in lib/engine/routeinjector/typeBased/typeBased.js and 1 other location - About 6 hrs to fix
      lib/engine/routeinjector/typeBased/typeBased.js on lines 253..268

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

      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

                                      refModel.find(newQuery, gConfig.mongo.projection, function (err, results) {
                                          if (err) {
                                              res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                              res.json(err);
                                              return res.end();
      Severity: Major
      Found in lib/engine/routeinjector/typeBased/typeBased.js and 1 other location - About 6 hrs to fix
      lib/engine/routeinjector/typeBased/typeBased.js on lines 68..83

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

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

      module.exports.getNDocumentsPost = function (Model) {
      
          return function (req, res) {
              if (!req.body) req.body = {};
              if (!req.body.query) req.body.query = {};
      Severity: Major
      Found in lib/engine/routeinjector/rest/search.js - About 5 hrs to fix

        Function getByField has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports.getByField = function (Model) {
        
            return function (req, res) {
                var gConfig = Model.injector();
                var isTypeBack = (req.query.type && req.query.type == "back"); //Special for filter normalizations
        Severity: Minor
        Found in lib/engine/routeinjector/rest/get.js - About 5 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 147 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var jsonform = function (schema, options) {
        
            var shardKey = undefined;
            if (schema.statics.injector) {
                var injector = schema.statics.injector();
        Severity: Major
        Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 5 hrs to fix

          Function export has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.export = function (Model) {
              /*var doc = new Model({});
               var schema = doc.jsonform({});
          
               var validFields = [];
          Severity: Minor
          Found in lib/engine/routeinjector/rest/export.js - About 5 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 mainPutFn has 142 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function mainPutFn() {
                      //ID CHECKING
                      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");
          Severity: Major
          Found in lib/engine/routeinjector/rest/put.js - About 5 hrs to fix

            Function FSUtils has 142 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var FSUtils = /** @class */ (function () {
                function FSUtils() {
                }
                /**
                 * Get the directories from the existing src path
            Severity: Major
            Found in lib/utils/FSUtils.js - About 5 hrs to fix

              File new-image-injector.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              var mkdirp = require('mkdirp');
              var fs = require('fs');
              var glob = require('glob');
              var async = require('async');
              var path = require('path');
              Severity: Minor
              Found in lib/engine/routeinjector/images/new-image-injector.js - About 5 hrs to fix

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

                        function mainGetNPostFn() {
                            var query = req.body.query;
                
                            function validateOID(q) {
                                _.forOwn(q, function (value, key) {
                Severity: Major
                Found in lib/engine/routeinjector/rest/search.js - About 5 hrs to fix

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

                      ExpressManager.prototype.preInjectPlugins = function () {
                          var _this = this;
                          ExpressManager.logger.info("Calling PreInjecting functions for Plugins");
                          this.pluginRegistry.forEachPlugin(function (metaPlugin) {
                              var plugin = metaPlugin.plugin;
                  Severity: Major
                  Found in lib/app/internals/ExpressManager.js and 1 other location - About 5 hrs to fix
                  lib/app/internals/ExpressManager.js on lines 182..192

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

                  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.postInjectPlugins = function () {
                          var _this = this;
                          ExpressManager.logger.info("Calling PostInject functions for Plugins");
                          this.pluginRegistry.forEachPlugin(function (metaPlugin) {
                              var plugin = metaPlugin.plugin;
                  Severity: Major
                  Found in lib/app/internals/ExpressManager.js and 1 other location - About 5 hrs to fix
                  lib/app/internals/ExpressManager.js on lines 168..178

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

                  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

                  function deleteImage(param) {
                      return function (req, res) {
                          var filePath = req.params.path;
                  
                          deleteFullPathImage(path.join(param.out, filePath), function (err) {
                  Severity: Major
                  Found in lib/engine/routeinjector/images/new-image-injector.js and 2 other locations - About 4 hrs to fix
                  lib/engine/routeinjector/files/file-injector.js on lines 298..313
                  lib/engine/routeinjector/images/image-injector.js on lines 490..505

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

                  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

                  function deleteImage(param) {
                      return function (req, res) {
                          var filePath = req.params.path;
                  
                          deleteFullPathImage(path.join(param.out, filePath), function (err) {
                  Severity: Major
                  Found in lib/engine/routeinjector/images/image-injector.js and 2 other locations - About 4 hrs to fix
                  lib/engine/routeinjector/files/file-injector.js on lines 298..313
                  lib/engine/routeinjector/images/new-image-injector.js on lines 448..463

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

                  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

                  function deleteFile(param) {
                      return function (req, res) {
                          var filePath = req.params.path;
                  
                          deleteFullPathFile(path.join(param.out, filePath), function (err) {
                  Severity: Major
                  Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 4 hrs to fix
                  lib/engine/routeinjector/images/image-injector.js on lines 490..505
                  lib/engine/routeinjector/images/new-image-injector.js on lines 448..463

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

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

                  function insertImage(param) {
                      return function (req, res) {
                          var outDirectory = param.out;
                          if (req.files.image != undefined) {
                              //ext includes '.'
                  Severity: Major
                  Found in lib/engine/routeinjector/images/new-image-injector.js - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language