RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

function getAbsoluteImage(param) {
    return function (req, res) {
        var redUrl = "";
        if (req.params["size"]) {
            redUrl = '/images/' + param.folder + '/' + req.params["size"] + '/' + req.params.path;
Severity: Major
Found in lib/engine/routeinjector/images/new-image-injector.js and 1 other location - About 4 hrs to fix
lib/engine/routeinjector/images/image-injector.js on lines 181..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 129.

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 getAbsoluteImage(param) {
    return function (req, res) {
        var redUrl = "";
        if (req.params["size"]) {
            redUrl = '/images/' + param.folder + '/' + req.params["size"] + '/' + req.params.path;
Severity: Major
Found in lib/engine/routeinjector/images/image-injector.js and 1 other location - About 4 hrs to fix
lib/engine/routeinjector/images/new-image-injector.js on lines 181..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 129.

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 postInjectPlugins() {
        ExpressManager.logger.info("Calling PostInject functions for Plugins");
        this.pluginRegistry.forEachPlugin((metaPlugin: IMetaPlugin)=> {
            var plugin: IPlugin = metaPlugin.plugin;
            ExpressManager.logger.info("\t Calling PostInject on %s", plugin.name);
Severity: Major
Found in lib/app/internals/ExpressManager.ts and 1 other location - About 4 hrs to fix
lib/app/internals/ExpressManager.ts on lines 195..204

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

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 preInjectPlugins() {
        ExpressManager.logger.info("Calling PreInjecting functions for Plugins");
        this.pluginRegistry.forEachPlugin((metaPlugin: IMetaPlugin)=> {
            var plugin: IPlugin = metaPlugin.plugin;
            ExpressManager.logger.info("\t Calling PreInject on %s", plugin.name);
Severity: Major
Found in lib/app/internals/ExpressManager.ts and 1 other location - About 4 hrs to fix
lib/app/internals/ExpressManager.ts on lines 209..218

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

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

var ModelsLoader = /** @class */ (function () {
    function ModelsLoader(config, pluginRegistry) {
        this._models = {};
        ModelsLoader.logger.trace("Creating ModelsLoader instance");
        this.config = config;
Severity: Major
Found in lib/app/internals/ModelsLoader.js - About 4 hrs to fix

    Function insertImage has 115 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/image-injector.js - About 4 hrs to fix

      Function insertFile has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function insertFile(param) {
          return function (req, res) {
              var outDirectory = param.out;
              if (req.files.file != undefined) {
                  //ext includes '.'
      Severity: Major
      Found in lib/engine/routeinjector/files/file-injector.js - About 4 hrs to fix

        Function GalleryInjector has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

        var GalleryInjector = /** @class */ (function () {
            function GalleryInjector(routeInjector) {
                var _this = this;
                this.fileExistsMiddleware = function (req, res, next) {
                    var reqPath = req.params.path;
        Severity: Minor
        Found in lib/engine/routeinjector/images/GalleryInjector.js - About 4 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 typeBased.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        var utils = require('../utils');
        var statusCode = require('http-status-codes');
        var confs = utils.getModels();
        var Q = require('q');
        
        Severity: Minor
        Found in lib/engine/routeinjector/typeBased/typeBased.js - About 4 hrs to fix

          Function PermissionsLoader has 114 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var PermissionsLoader = /** @class */ (function () {
              function PermissionsLoader(config, modelsLoader) {
                  this.roles = [];
                  this.holder = {
                      routes: {}
          Severity: Major
          Found in lib/app/internals/auth/PermissionsLoader.js - About 4 hrs to fix

            Function getFormConfig has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports.getFormConfig = function (req, res) {
                var modelName = req.params.modelname;
                try {
                    var Model = mongoose.model(modelName);
                    var minjector = Model.injector();
            Severity: Minor
            Found in lib/engine/routeinjector/routes/model.js - About 4 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 getNDocumentsPost has a Cognitive Complexity of 30 (exceeds 5 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: Minor
            Found in lib/engine/routeinjector/rest/search.js - About 4 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 utils.js has 350 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            var async = require('async');
            var statusCode = require('http-status-codes');
            var _ = require('lodash');
            var Q = require('q');
            
            Severity: Minor
            Found in lib/engine/routeinjector/utils.js - About 4 hrs to fix

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

                              function error(err) {
                                  log.error(err);
                                  utils.runErrorCallbacks(config, req, err);
              
                                  if (err.name === "ValidationError") {
              Severity: Major
              Found in lib/engine/routeinjector/rest/post.js and 1 other location - About 4 hrs to fix
              lib/engine/routeinjector/rest/put.js on lines 178..190

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

              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) {
                                  log.error(err);
                                  utils.runErrorCallbacks(config, req, err);
              
                                  if (err.name === "ValidationError") {
              Severity: Major
              Found in lib/engine/routeinjector/rest/put.js and 1 other location - About 4 hrs to fix
              lib/engine/routeinjector/rest/post.js on lines 94..106

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

              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 clearCache(model, imageName) {
                  glob(path.join(cachePath, model, "**", imageName), function (err, files) {
              
                      for (var i = 0; i < files.length; i++) {
                          fs.unlink(files[i], function (err) {
              Severity: Major
              Found in lib/engine/routeinjector/images/new-image-injector.js and 1 other location - About 3 hrs to fix
              lib/engine/routeinjector/images/image-injector.js on lines 237..249

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

              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 clearCache(model, imageName) {
                  glob(path.join(cachePath, model, "**", imageName), function (err, files) {
              
                      for (var i = 0; i < files.length; i++) {
                          fs.unlink(files[i], function (err) {
              Severity: Major
              Found in lib/engine/routeinjector/images/image-injector.js and 1 other location - About 3 hrs to fix
              lib/engine/routeinjector/images/new-image-injector.js on lines 196..208

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

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

              module.exports.deleteByField = function (Model) {
                  return function (req, res) {
                      var gConfig = Model.injector();
                      var field = gConfig.id;
                      var config = utils.getConfigByProfile(gConfig.delete, req);
              Severity: Minor
              Found in lib/engine/routeinjector/rest/delete.js - About 3 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 deleteByField has 96 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.deleteByField = function (Model) {
                  return function (req, res) {
                      var gConfig = Model.injector();
                      var field = gConfig.id;
                      var config = utils.getConfigByProfile(gConfig.delete, req);
              Severity: Major
              Found in lib/engine/routeinjector/rest/delete.js - About 3 hrs to fix

                Function walkSchema has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                Open

                function walkSchema(app, Model, schema, parentName, fromArray, rawPath) {
                    var modelConfig = utils.getModels()[Model.modelName];
                    for (var key in schema) {
                        var field = schema[key];
                
                Severity: Minor
                Found in lib/engine/routeinjector/typeBased.js - About 3 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

                Severity
                Category
                Status
                Source
                Language