Showing 220 of 414 total issues
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");
}
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];
- Read upRead up
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;
- Read upRead up
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:
Function mainGetNPostFn
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mainGetNPostFn() {
var format = req.body.format || req.query.format || "csv";
var query = req.body.query;
var options = {};
Function genDenorm
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function genDenorm(dest, src, denormalized, confRid, plain, doc, path) {
if (src) {
dest = {};
var target;
if (plain == true) {
Function TranslationRepository
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
var TranslationRepository = /** @class */ (function () {
function TranslationRepository(config, pluginRegistry) {
this.i18nDirs = [];
this.i18nFiles = [];
TranslationRepository.logger.trace("Creating TranslationRepository instance");
Function RouteInjector
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
var RouteInjector = /** @class */ (function () {
//private middlewareRegistry:MiddlewareRegistry;
function RouteInjector() {
this.version = require('../../package.json').version;
this.cache = { middlewares: {} };
- Read upRead up
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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function PassportLocal(config) {
var _this = this;
this.tokens = require('../../../engine/routeinjector/routes/auth/tokens');
var jwt = require('jsonwebtoken');
var BearerStrategy = require('passport-http-bearer');
Function geograph
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.geograph = function (Model, geograph) {
var geoField = geograph.geoField;
var groupBy = geograph.groupBy || "";
var defaultQuery = geograph.query || {};
Consider simplifying this complex logical expression. Open
if ((routesRestrictions.blacklist && routesRestrictions.blacklist.routes) || (routesRestrictions.whitelist && routesRestrictions.whitelist.routes)) {
allowed = (routesRestrictions.whitelist && routesRestrictions.whitelist.routes && routesRestrictions.whitelist.routes.indexOf(method) > -1) ||
(routesRestrictions.blacklist && routesRestrictions.blacklist.routes && routesRestrictions.blacklist.routes.indexOf(method) == -1);
}
Function exports
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (injector) {
log = RouteInjector.log;
config = injector.config.auth;
// Passport
Function processAllPermissionsByRole
has 41 lines of code (exceeds 25 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"];
Function processAllPermissionsByRole
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
PermissionsLoader.prototype.processAllPermissionsByRole = function () {
var result = {};
var allModels = Object.keys(this.holder.routes);
var verbs = ["get", "post", "delete", "search", "put", "export", "import", "menu"];
for (var modelName in this.holder.routes) {
Function handleGetImage
has a Cognitive Complexity of 13 (exceeds 5 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;
- Read upRead up
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 checkSetup
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.checkSetup = function (Model) {
var mConf = Model.injector();
//Limit shards based on the environment!
if (mConf.shard && mConf.shard.shardValues) {
Function getType
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getType(pathString, mongotype) {
switch (mongotype) {
case('String'):
case('SchemaString'):
return {type: 'string'};
Function AuthManager
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AuthManager(config, models) {
var _this = this;
this.checkRole = function (role) { return ({
name: 'checkRole(' + role + ')',
middleware: function (req, res, next) {
Function constructor
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(parentOptions, RIOptions) {
super(parentOptions);
RIOptions.res.attachment(RIOptions.modelName + RIOptions.format);
Function constructor
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(config:any) {
var jwt = require('jsonwebtoken');
var BearerStrategy = require('passport-http-bearer');
this.config = config;
passport.use(new BearerStrategy((token, done) => {