RouteInjector/route-injector

View on GitHub

Showing 414 of 414 total issues

Function __generator has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
Severity: Minor
Found in lib/engine/routeinjector/images/GalleryInjector.js - About 1 day 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 __generator has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
Severity: Minor
Found in lib/utils/HooksUtils.js - About 1 day 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 __generator has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
Severity: Minor
Found in lib/utils/FSUtils.js - About 1 day 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 GalleryInjector has 222 lines of code (exceeds 25 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: Major
Found in lib/engine/routeinjector/images/GalleryInjector.js - About 1 day to fix

    Function processAllPermissionsByRole has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

        private processAllPermissionsByRole() {
            var result = {};
            var allModels = Object.keys(this.holder.routes);
            var verbs = ["get", "post", "delete", "search", "put", "export", "import", "menu"];
    
    
    Severity: Minor
    Found in lib/app/internals/auth/PermissionsLoader.ts - About 1 day 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 post has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

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

    module.exports.denormalize = function (field, rkey, Model, isArray, fullPath) {
        var needsFromDBhook = true;
        var denormalizedFields = field.denormalize;
        log.debug("Adding denormalized params :\"" + denormalizedFields + "\" to field " + fullPath + " in model " + Model.modelName);
    
    Severity: Major
    Found in lib/engine/routeinjector/newdenormalizer.js - About 1 day to fix

      Function ExpressManager has 193 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function export has 180 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports.export = function (Model) {
            /*var doc = new Model({});
             var schema = doc.jsonform({});
        
             var validFields = [];
        Severity: Major
        Found in lib/engine/routeinjector/rest/export.js - About 7 hrs to fix

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

                              if (gConfig.shard && gConfig.shard.shardKey && gConfig.shard.shardKey != "") {
                                  if (doc[gConfig.shard.shardKey] == undefined) {
                                      if (req.query[gConfig.shard.shardKey == undefined]) {
                                          log.error("Shard key not present in query");
                                          res.statusCode = statusCode.BAD_REQUEST;
          Severity: Major
          Found in lib/engine/routeinjector/typeBased/typeBased.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/rest/put.js on lines 101..111
          lib/engine/routeinjector/typeBased/typeBased.js on lines 452..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 173.

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

                              if (gConfig.shard && gConfig.shard.shardKey && gConfig.shard.shardKey != "") {
                                  if (doc[gConfig.shard.shardKey] == undefined) {
                                      if (req.query[gConfig.shard.shardKey == undefined]) {
                                          log.error("Shard key not present in query");
                                          res.statusCode = statusCode.BAD_REQUEST;
          Severity: Major
          Found in lib/engine/routeinjector/typeBased/typeBased.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/rest/put.js on lines 101..111
          lib/engine/routeinjector/typeBased/typeBased.js on lines 546..557

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

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

                              if (gConfig.shard && gConfig.shard.shardKey && gConfig.shard.shardKey != "") {
                                  if (doc[gConfig.shard.shardKey] == undefined) {
                                      if (req.query[gConfig.shard.shardKey == undefined]) {
                                          log.error("Shard key not present in query");
                                          res.statusCode = statusCode.BAD_REQUEST;
          Severity: Major
          Found in lib/engine/routeinjector/rest/put.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/typeBased/typeBased.js on lines 452..463
          lib/engine/routeinjector/typeBased/typeBased.js on lines 546..557

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

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

          function copyFile(source, target, cb) {
              var cbCalled = false;
          
              var rd = fs.createReadStream(source);
              rd.on("error", function (err) {
          Severity: Major
          Found in lib/engine/routeinjector/images/image-injector.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/files/file-injector.js on lines 257..279
          lib/engine/routeinjector/images/new-image-injector.js on lines 407..429

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

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

          function copyFile(source, target, cb) {
              var cbCalled = false;
          
              var rd = fs.createReadStream(source);
              rd.on("error", function (err) {
          Severity: Major
          Found in lib/engine/routeinjector/files/file-injector.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/images/image-injector.js on lines 449..471
          lib/engine/routeinjector/images/new-image-injector.js on lines 407..429

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

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

          function copyFile(source, target, cb) {
              var cbCalled = false;
          
              var rd = fs.createReadStream(source);
              rd.on("error", function (err) {
          Severity: Major
          Found in lib/engine/routeinjector/images/new-image-injector.js and 2 other locations - About 6 hrs to fix
          lib/engine/routeinjector/files/file-injector.js on lines 257..279
          lib/engine/routeinjector/images/image-injector.js on lines 449..471

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

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

          function transform(Model, key, fullKey, modelConfig, field) {
              /*var sc = getElementSchema(Model.schema.paths, fullKey);
               if(sc){
               sc.options["x-schema-form"] = sc.options["x-schema-form"] || {};
               sc.options["x-schema-form"]["disableSuccessState"] = true;
          Severity: Minor
          Found in lib/engine/routeinjector/typeBased.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 postArrayElementAt has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.postArrayElementAt = function (Model, key) {
          
              return function (req, res) {
                  var gConfig = Model.injector();
                  var field = gConfig.id;
          Severity: Minor
          Found in lib/engine/routeinjector/typeBased/typeBased.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 RouteInjector has 159 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var RouteInjector = /** @class */ (function () {
              //private middlewareRegistry:MiddlewareRegistry;
              function RouteInjector() {
                  this.version = require('../../package.json').version;
                  this.cache = { middlewares: {} };
          Severity: Major
          Found in lib/app/RouteInjector.js - About 6 hrs to fix

            Function exports has 157 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function (app) {
                var config = injector.config;
                var prefix = config.routes.prefix;
                var exprConfig = config.express || {};
            
            Severity: Major
            Found in lib/engine/routeinjector/inject.js - About 6 hrs to fix

              Function appendArrayElement has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports.appendArrayElement = function (Model, key) {
              
                  return function (req, res) {
                      var gConfig = Model.injector();
                      var field = gConfig.id;
              Severity: Minor
              Found in lib/engine/routeinjector/typeBased/typeBased.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

              Severity
              Category
              Status
              Source
              Language