gerard2p/koaton

View on GitHub

Showing 48 of 48 total issues

Function REST_POST_SINGLE has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

export async function REST_POST_SINGLE (Model, model, entity = null) {
    if (!entity) {
        entity = await Model.create(model);
    }
    let modelRelations = {};
Severity: Minor
Found in src/support/RestModel.js - About 7 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 error.js has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/** @ignore */
let codes = [
    {
        'code': '1xx',
        'phrase': '**Informational**',
Severity: Minor
Found in src/middleware/error.js - About 6 hrs to fix

Function RestModel has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

export function RestModel (options, route, modelname) {
    let routers = {
        public: new Router(),
        private: new Router()
    };
Severity: Minor
Found in src/support/RestModel.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 oauth2server has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function oauth2server () {
    AuthModel = models[inflector.pluralize(configuration.security.model)];
    for (let model in oauth2models) {
        addModel(inflector.pluralize(model), oauth2models[model]);
    }
Severity: Major
Found in src/middleware/oauth2server.js - About 4 hrs to fix

Function RestModel has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function RestModel (options, route, modelname) {
    let routers = {
        public: new Router(),
        private: new Router()
    };
Severity: Major
Found in src/support/RestModel.js - About 4 hrs to fix

Function default has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (model) {
    for (const fn of promesifythem) {
        if (model[fn]) {
            const rawFN = model[fn].bind(model);
            model.rawAPI[fn] = rawFN;
Severity: Major
Found in src/support/extend_caminte.js - About 3 hrs to fix

Function default has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export default function (model) {
    for (const fn of promesifythem) {
        if (model[fn]) {
            const rawFN = model[fn].bind(model);
            model.rawAPI[fn] = rawFN;
Severity: Minor
Found in src/support/extend_caminte.js - About 2 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 REST_POST_SINGLE has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function REST_POST_SINGLE (Model, model, entity = null) {
    if (!entity) {
        entity = await Model.create(model);
    }
    let modelRelations = {};
Severity: Major
Found in src/support/RestModel.js - About 2 hrs to fix

Function restify has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export async function restify (modelinstance, /* istanbul ignore next */ relations = {}, /* istanbul ignore next */MODEL = {}) {
    /* istanbul ignore next */
    let model = modelinstance.toJSON ? modelinstance.toJSON() : modelinstance;
    for (const key of Object.keys(relations)) {
        const keyTo = relations[key].keyTo === 'id' ? '_id' : relations[key].keyTo;
Severity: Minor
Found in src/support/RestModel.js - About 2 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 initialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export function initialize () {
    subdomainRouters = {
        www: new KoatonRouter('www')
    };
    let routers = glob('koaton_modules/**/routes.js').concat(glob('routes.js'));
Severity: Minor
Found in src/middleware/router.js - About 2 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 addModel has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function addModel (modelName, definition) {
    relations[modelName] = [];
    const rel = {
        belongsTo: relation.bind(modelName, 'belongsTo'),
        hasMany: relation.bind(modelName, 'hasMany'),
Severity: Major
Found in src/middleware/orm.js - About 2 hrs to fix

Function restify has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function restify (modelinstance, /* istanbul ignore next */ relations = {}, /* istanbul ignore next */MODEL = {}) {
    /* istanbul ignore next */
    let model = modelinstance.toJSON ? modelinstance.toJSON() : modelinstance;
    for (const key of Object.keys(relations)) {
        const keyTo = relations[key].keyTo === 'id' ? '_id' : relations[key].keyTo;
Severity: Major
Found in src/support/RestModel.js - About 2 hrs to fix

Function initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function initialize () {
    subdomainRouters = {
        www: new KoatonRouter('www')
    };
    let routers = glob('koaton_modules/**/routes.js').concat(glob('routes.js'));
Severity: Minor
Found in src/middleware/router.js - About 1 hr to fix

Function ex2engine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function ex2engine (fullpath) {
    let extension = extname(fullpath).slice(1);
    let file = fullpath.replace(extname(fullpath), '');
    let engine;
    if (!extension && !cacher[fullpath] && !exists(fullpath)) {
Severity: Minor
Found in src/views/index.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 loadSecurityContext has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function loadSecurityContext () {
    AuthModel = models[inflector.pluralize(configuration.security.model)];
    const Model = models[inflector.pluralize(configuration.security.model)];
    /* istanbul ignore if */
    if (!Model) {
Severity: Minor
Found in src/middleware/auth.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 cached has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export default async function cached (ctx, next) {
    await next();
    const body = ctx.body;
    /* istanbul ignore if */
    if (!body || ctx.response.get('ETag') || ctx.state.nocache) return;
Severity: Minor
Found in src/middleware/cached.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 REST_GET has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    pOrp(routers, options.get).get('/', async function REST_GET (ctx, next) {
        let res = {},
            filteroptions = { skip: 0 };
        filteroptions.limit = isNaN(ctx.query.size) ? isNaN(configuration.server.pagination.limit) ? /* istanbul ignore next */50 : configuration.server.pagination.limit : parseInt(ctx.query.size, 10);
        if (ctx.query.size) {
Severity: Minor
Found in src/support/RestModel.js - About 1 hr to fix

Function DeepDevOrProd has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function DeepDevOrProd (object, prop) {
    let target = object[prop];
    if (Object.keys(target).indexOf('dev') === -1 && typeof target === 'object') {
        for (const deep of Object.keys(target)) {
            DeepDevOrProd(object[prop], deep);
Severity: Minor
Found in src/support/configuration.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 oauth2server has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function oauth2server () {
    AuthModel = models[inflector.pluralize(configuration.security.model)];
    for (let model in oauth2models) {
        addModel(inflector.pluralize(model), oauth2models[model]);
    }
Severity: Minor
Found in src/middleware/oauth2server.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 nunjucks has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function nunjucks () {
    const nunjucks = require(ProyPath('node_modules', 'nunjucks'));
    const env = new nunjucks.Environment();
    class Link {
        constructor () {
Severity: Minor
Found in src/views/setup.js - About 1 hr to fix
Severity
Category
Status
Source
Language