RouteInjector/route-injector

View on GitHub

Showing 220 of 414 total issues

Function PermissionsLoader has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

var PermissionsLoader = /** @class */ (function () {
    function PermissionsLoader(config, modelsLoader) {
        this.roles = [];
        this.holder = {
            routes: {}
Severity: Minor
Found in lib/app/internals/auth/PermissionsLoader.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 pruneDocument has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.pruneDocument = function (indoc) {
    return prune(indoc);

    function prune(doc) {
        if (doc instanceof Array) {
Severity: Minor
Found in lib/engine/routeinjector/utils.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/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/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 __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 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

          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

              File image-injector.js has 424 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/images/image-injector.js - About 6 hrs to fix

                Function genDenorm has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                Open

                function genDenorm(dest, src, denormalized, confRid, plain, doc, path) {
                    if (src) {
                        dest = {};
                        var target;
                        if (plain == true) {
                Severity: Minor
                Found in lib/engine/routeinjector/newdenormalizer.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 AuthManager has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                Open

                var AuthManager = /** @class */ (function () {
                    function AuthManager(config, models) {
                        var _this = this;
                        this.checkRole = function (role) { return ({
                            name: 'checkRole(' + role + ')',
                Severity: Minor
                Found in lib/app/internals/AuthManager.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 putByField has 152 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports.putByField = function (Model) {
                    var documentDb = {};
                    var originalDoc = {};
                    return function (req, res) {
                        var gConfig = Model.injector();
                Severity: Major
                Found in lib/engine/routeinjector/rest/put.js - About 6 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language