RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

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

            function check(doc) {
                var defer = Q.defer();
                if (!doc) {
                    res.statusCode = statusCode.NOT_FOUND;
                    defer.reject('Document not found');
Severity: Major
Found in lib/engine/routeinjector/rest/delete.js and 1 other location - About 2 hrs to fix
lib/engine/routeinjector/rest/put.js on lines 80..89

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

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

File file-injector.js has 260 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/files/file-injector.js - About 2 hrs to fix

    Function bargraph has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.bargraph = function (Model, bargraph) {
    
        var groupBy = bargraph.groupBy || "";
        var axis = bargraph.xAxisField;
        var defaultQuery = bargraph.query || {};
    Severity: Major
    Found in lib/engine/routeinjector/graphs/bargraph.js - About 2 hrs to fix

      Function fromDB has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              Model.injector()._references.fromDB = function (doc, cb) {
                  var defer = Q.defer();
                  var promises = [];
                  var doc2 = doc.toObject();
      
      Severity: Major
      Found in lib/engine/routeinjector/newdenormalizer.js - About 2 hrs to fix

        Function QueryUtils has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var QueryUtils = /** @class */ (function () {
            function QueryUtils() {
            }
            //TODO: Add population key if present
            QueryUtils.findOne = function (operation, model, req, cb) {
        Severity: Major
        Found in lib/utils/QueryUtils.js - About 2 hrs to fix

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

          var Unauthorized = /** @class */ (function (_super) {
              __extends(Unauthorized, _super);
              function Unauthorized(msg) {
                  return _super.call(this, "Unauthorized", msg) || this;
              }
          Severity: Major
          Found in lib/responses/Unauthorized.js and 1 other location - About 2 hrs to fix
          lib/responses/NotFound.js on lines 20..29

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 79.

          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

              app.post(injector.config.routes.prefix + '/' + baseConfig.plural + '/' + key + '/:' + refConfig.id,
                  baseConfig.search.middleware || [],
                  typeBased.indirectReferencePost(Model, refModel, key)
              );
          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 238..241

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

          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

              app.get(injector.config.routes.prefix + '/' + baseConfig.plural + '/' + key + '/:' + refConfig.id,
                  baseConfig.search.middleware || [],
                  typeBased.indirectReferenceGet(Model, refModel, key)
              );
          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 244..247

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

          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

          var NotFound = /** @class */ (function (_super) {
              __extends(NotFound, _super);
              function NotFound(msg) {
                  return _super.call(this, "Not Found", msg) || this;
              }
          Severity: Major
          Found in lib/responses/NotFound.js and 1 other location - About 2 hrs to fix
          lib/responses/Unauthorized.js on lines 20..29

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 79.

          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

          ExpressManager has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ExpressManager {
              static logger = Logger.getLogger();
              public app = express();
              private config;
              private pluginRegistry: PluginRegistry;
          Severity: Minor
          Found in lib/app/internals/ExpressManager.ts - About 2 hrs to fix

            Function RouteLoader has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function validate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.validate = function (Model) {
              
                  var config = Model.injector();
                  var additionalId = (config.id != '_id') ? config.id : undefined;
                  var shardKey = (config.shard && config.shard.shardKey) ? config.shard.shardKey : undefined;
              Severity: Major
              Found in lib/engine/routeinjector/rest/validate.js - About 2 hrs to fix

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

                        function mainGetFn() {
                            var query = {};
                            for (var i in config.mongo.query) {
                                //COPY the object
                                query[i] = config.mongo.query[i];
                Severity: Major
                Found in lib/engine/routeinjector/typeBased/typeBased.js - About 2 hrs to fix

                  Function injectImages has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.injectImages = function (_app, param) {
                  
                      var imageConf = injector.config.env.images;
                      imagePath = imageConf.path;
                      cachePath = imageConf.cache;
                  Severity: Minor
                  Found in lib/engine/routeinjector/images/image-injector.js - About 1 hr to fix

                    Function injectImages has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.injectImages = function (_app, param) {
                    
                        var imageConf = injector.config.env.images;
                        imagePath = imageConf.path;
                        cachePath = imageConf.cache;
                    Severity: Minor
                    Found in lib/engine/routeinjector/images/new-image-injector.js - About 1 hr to fix

                      Function iterate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                          function iterate(path, obj) {
                                              if (matches = path.match(/([^.]+)\.(.*)/)) {
                                                  var key = matches[1];
                                                  if (!obj[key]) {
                                                      // Humanize object title
                      Severity: Minor
                      Found in lib/mongoose-plugins/mongoose-jsonform/lib/mongoose-jsonform.js - About 1 hr to fix

                        Function Configurations has 48 lines of code (exceeds 25 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 1 hr to fix

                          Function configureForm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports.configureForm = function (Model) {
                              var inj = Model.injector();
                              if (inj.form && inj.form.tabs) {
                                  for (var t in inj.form.tabs) {
                                      var tab = inj.form.tabs[t];
                          Severity: Minor
                          Found in lib/engine/routeinjector/utils.js - About 1 hr 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 isRoleAcceptable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private isRoleAcceptable(role, user) {
                                  var config = this.config;
                                  var restrictions = this.config.env.restrictions;
                                  if (config.permissions.adminRole && user.role == config.permissions.adminRole) {
                                      return true;
                          Severity: Minor
                          Found in lib/app/internals/AuthManager.ts - About 1 hr 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 iterateCursor has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              HooksUtils.iterateCursor = function (cursor, limit, func, ctx) { return __awaiter(_this, void 0, void 0, function () {
                                  var partial, state, doc_1, next, _a, result, _b, err_1;
                                  return __generator(this, function (_c) {
                                      switch (_c.label) {
                                          case 0:
                          Severity: Minor
                          Found in lib/utils/HooksUtils.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language