RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

Avoid deeply nested control flow statements.
Open

                                            if (e) {
                                                log.error(e);
                                                res.json(e);
                                                res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                return res.end();
Severity: Major
Found in lib/engine/routeinjector/images/image-injector.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (i == 0) {
                                fileName = sourceFileName;
                            } else {
                                fileName = addStringBeforeExtension(sourceFileName, '_' + i);
                            }
    Severity: Major
    Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

      Function injectArrays has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function injectArrays(app, field, key, Model, baseConfig, rawPath) {
      Severity: Minor
      Found in lib/engine/routeinjector/typeBased.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (Object.keys(objDoc).length > 0) {
                                for (var i in objDoc) {
                                    if (objDoc.hasOwnProperty(i)) {
                                        //Prune all the elements in the object
                                        //Although we are working with the plain object, we COPY and PRUNE the original object
        Severity: Major
        Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

          Function getInvRefField has a Cognitive Complexity of 8 (exceeds 5 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: Minor
          Found in lib/engine/routeinjector/typeBased/typeBased.js - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                              if (parentPath) {
                                  parentPath += "." + chunk
                              } else {
                                  parentPath = chunk;
                              }
          Severity: Major
          Found in lib/engine/routeinjector/utils.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (value !== undefined) {
                                    _.set(target, f.target, value);
                                }
            Severity: Major
            Found in lib/engine/routeinjector/newdenormalizer.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                          if (e) {
                                                              log.error(e);
                                                              res.json(e);
                                                              res.statusCode = statusCode.INTERNAL_SERVER_ERROR;
                                                              return res.end();
              Severity: Major
              Found in lib/engine/routeinjector/files/file-injector.js - About 45 mins to fix

                Function Configurations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                var Configurations = /** @class */ (function () {
                    function Configurations() {
                        if (Configurations.configHolder) {
                            throw new Error("Don't instantiate directly a configuration");
                        }
                Severity: Minor
                Found in lib/app/internals/Configurations.js - About 45 mins 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

                Avoid deeply nested control flow statements.
                Open

                                        if (route.hasOwnProperty(role)) {
                                            var userRole = route[role];
                                            if (!result[userRole])
                                                result[userRole] = {};
                                            if (!result[userRole][modelName])
                Severity: Major
                Found in lib/app/internals/auth/PermissionsLoader.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for (var v in verbs) {
                                              var verb = verbs[v];
                                              if (this.holder.routes[model][verb].indexOf(role) == -1) {
                                                  if (!result[role][model]) {
                                                      result[role][model] = {};
                  Severity: Major
                  Found in lib/app/internals/auth/PermissionsLoader.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                    if (type.items.type == 'object') {
                                                        // TODO: Pass to the the parseSchema the current path
                                                        parseSchema(pathO.schema, obj[path].items.properties, pathO.path);
                                                    } else {
                                                        type = getType(pathString, pathO.caster.instance);
                    Severity: Major
                    Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                          if (type.type == 'date') {
                                                              pathO.options.default = pathO.options.default.toISOString();
                                                          }
                      Severity: Major
                      Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if (route.hasOwnProperty(role)) {
                                                    var userRole = route[role];
                        
                                                    if (!result[userRole])
                                                        result[userRole] = {};
                        Severity: Major
                        Found in lib/app/internals/auth/PermissionsLoader.ts - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  for (var v in verbs) {
                                                      var verb:string = verbs[v];
                                                      if (this.holder.routes[model][verb].indexOf(role) == -1) {
                                                          if (!result[role][model]) {
                                                              result[role][model] = {};
                          Severity: Major
                          Found in lib/app/internals/auth/PermissionsLoader.ts - About 45 mins to fix

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

                                if (this.config.globals.app) {
                                  RouteInjector.logger.info('     app');
                                  global['app'] = this.app;
                                }
                            Severity: Major
                            Found in lib/app/RouteInjector.ts and 3 other locations - About 40 mins to fix
                            lib/app/RouteInjector.ts on lines 155..158
                            lib/app/RouteInjector.ts on lines 165..168
                            lib/app/RouteInjector.ts on lines 173..176

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

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

                                if (this.config.globals.logger) {
                                  RouteInjector.logger.info('     log');
                                  global['log'] = this.log;
                                }
                            Severity: Major
                            Found in lib/app/RouteInjector.ts and 3 other locations - About 40 mins to fix
                            lib/app/RouteInjector.ts on lines 150..153
                            lib/app/RouteInjector.ts on lines 155..158
                            lib/app/RouteInjector.ts on lines 165..168

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

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

                                    if (this.config.globals.app) {
                                        RouteInjector.logger.info('     app');
                                        global['app'] = this.app;
                                    }
                            Severity: Major
                            Found in lib/app/RouteInjector.js and 3 other locations - About 40 mins to fix
                            lib/app/RouteInjector.js on lines 146..149
                            lib/app/RouteInjector.js on lines 154..157
                            lib/app/RouteInjector.js on lines 161..164

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

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

                                    if (this.config.globals.security) {
                                        RouteInjector.logger.info('     security');
                                        global['security'] = this.security;
                                    }
                            Severity: Major
                            Found in lib/app/RouteInjector.js and 3 other locations - About 40 mins to fix
                            lib/app/RouteInjector.js on lines 142..145
                            lib/app/RouteInjector.js on lines 146..149
                            lib/app/RouteInjector.js on lines 161..164

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

                            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

                                Object.defineProperty(PluginRegistry.prototype, "plugins", {
                                    /**
                                     *
                                     * @returns {{}}
                                     */
                            Severity: Minor
                            Found in lib/app/internals/PluginRegistry.js and 1 other location - About 40 mins to fix
                            lib/app/internals/TranslationRepository.js on lines 25..35

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

                            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