RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

Function getElementSchema has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.getElementSchema = function (paths, element) {
    var sc = paths[element];
    if (sc) {
        return sc;
    } else {
Severity: Minor
Found in lib/engine/routeinjector/utils.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 PassportLocal has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var PassportLocal = /** @class */ (function () {
    //TODO: Use IAuthConfig when defining strategies on a next steps of this refactor
    function PassportLocal(config) {
        var _this = this;
        this.tokens = require('../../../engine/routeinjector/routes/auth/tokens');
Severity: Major
Found in lib/app/internals/auth/PassportLocal.js - About 3 hrs to fix

    Function mainGetFn has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function mainGetFn() {
                
                //ID CHECKING
                if(gConfig.id == "_id" && !mongoose.Types.ObjectId.isValid(req.params[gConfig.id])){
                    res.statusCode = statusCode.NOT_FOUND;
    Severity: Major
    Found in lib/engine/routeinjector/rest/get.js - About 3 hrs to fix

      Function getInvRefField has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.getInvRefField = function (Model, refModel, field) {
          return function (req, res) {
              var gConfig = Model.injector();
              var config = utils.getConfigByProfile(gConfig.get, req);
              (config.pre) ? utils.runPreCallbacks(config.pre, Model, req, res, mainGetFn) : mainGetFn();
      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

            if (field.validationMessage != undefined) {
                var sc = getElementSchema(Model.schema.paths, fullKey);
                if (sc) {
                    sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                    sc.options["x-schema-form"]["feedback"] = field.feedback;
        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 133..139

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

        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.feedback != undefined) {
                var sc = getElementSchema(Model.schema.paths, fullKey);
                if (sc) {
                    sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                    sc.options["x-schema-form"]["feedback"] = field.feedback;
        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 141..147

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 93.

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

        var HooksUtils = /** @class */ (function () {
            function HooksUtils() {
            }
            HooksUtils.funcMerge = function (funcArray) {
                return function (doc, cb, state) { return __awaiter(_this, void 0, void 0, function () {
        Severity: Major
        Found in lib/utils/HooksUtils.js - About 2 hrs to fix

          Function jsonform has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              schema.methods.jsonform = function (opt) {
                  var self = this;
                  var jf = {};
                  if (!opt) opt = {excluded: [], includes: '*', setDefaults: false};
                  if (!opt.includes) opt.includes = '*';
          Severity: Major
          Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 2 hrs to fix

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

            function deleteFullPathImage(filePath, cb) {
                fs.exists(filePath, function (exists) {
                    if (exists) {
                        fs.unlink(filePath, function (err) {
                            if (err) {
            Severity: Major
            Found in lib/engine/routeinjector/images/image-injector.js and 2 other locations - About 2 hrs to fix
            lib/engine/routeinjector/files/file-injector.js on lines 281..296
            lib/engine/routeinjector/images/new-image-injector.js on lines 431..446

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

            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 deleteFullPathImage(filePath, cb) {
                fs.exists(filePath, function (exists) {
                    if (exists) {
                        fs.unlink(filePath, function (err) {
                            if (err) {
            Severity: Major
            Found in lib/engine/routeinjector/images/new-image-injector.js and 2 other locations - About 2 hrs to fix
            lib/engine/routeinjector/files/file-injector.js on lines 281..296
            lib/engine/routeinjector/images/image-injector.js on lines 473..488

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

            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 deleteFullPathFile(filePath, cb) {
                fs.exists(filePath, function (exists) {
                    if (exists) {
                        fs.unlink(filePath, function (err) {
                            if (err) {
            Severity: Major
            Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 2 hrs to fix
            lib/engine/routeinjector/images/image-injector.js on lines 473..488
            lib/engine/routeinjector/images/new-image-injector.js on lines 431..446

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

            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 getFormConfig has 71 lines of code (exceeds 25 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: Major
            Found in lib/engine/routeinjector/routes/model.js - About 2 hrs to fix

              Function appendArrayElement has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.appendArrayElement = function (Model, key) {
              
                  return function (req, res) {
                      var gConfig = Model.injector();
                      var field = gConfig.id;
              Severity: Major
              Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                Function postArrayElementAt has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports.postArrayElementAt = function (Model, key) {
                
                    return function (req, res) {
                        var gConfig = Model.injector();
                        var field = gConfig.id;
                Severity: Major
                Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                  Function handleGetImage has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private handleGetImage() {
                          let IMGR = require('imgr').IMGR;
                          let config = this.routeInjector.config.env.images.imgrConfig || {};
                          if (config.optimisation == undefined) {
                              config.optimisation = this.optimiseImage;
                  Severity: Major
                  Found in lib/engine/routeinjector/images/GalleryInjector.ts - About 2 hrs to fix

                    Function mongoConfigurationCheck has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function mongoConfigurationCheck(config, gConfig, method) {
                        if (config.profiles == undefined) {
                            config.profiles = {};
                        }
                    
                    Severity: Minor
                    Found in lib/engine/routeinjector/utils.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

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

                        if (field.notitle) {
                            var sc = getElementSchema(Model.schema.paths, fullKey);
                            if (sc) {
                                sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                                sc.options["x-schema-form"]["notitle"] = field.notitle;
                    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 93..99
                    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

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

                        if (field.labelClass) {
                            var sc = getElementSchema(Model.schema.paths, fullKey);
                            if (sc) {
                                sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                                sc.options["x-schema-form"]["labelHtmlClass"] = field.labelClass;
                    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 93..99
                    lib/engine/routeinjector/typeBased.js on lines 101..107
                    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 5 locations. Consider refactoring.
                    Open

                        if (field.placeholder) {
                            var sc = getElementSchema(Model.schema.paths, fullKey);
                            if (sc) {
                                sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                                sc.options["x-schema-form"]["placeholder"] = field.placeholder;
                    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 93..99
                    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 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 5 locations. Consider refactoring.
                    Open

                        if (field.fieldClass) {
                            var sc = getElementSchema(Model.schema.paths, fullKey);
                            if (sc) {
                                sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
                                sc.options["x-schema-form"]["fieldHtmlClass"] = field.fieldClass;
                    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 93..99
                    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

                    Severity
                    Category
                    Status
                    Source
                    Language