gerard2p/koaton

View on GitHub

Showing 46 of 48 total issues

Function loadSecurityContext has 33 lines of code (exceeds 25 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

Function manyToMany has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        manyToMany (configuration) {
            let targetModel = inflector.pluralize(configuration.targetModel);
            let intermediateTable = `${modelName}_${targetModel}`;
            let key1 = `${modelName}ID`;
            let key2 = `${targetModel}ID`;
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function initializeORM has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function initializeORM (seed) {
    let res = null;
    /* istanbul ignore next */
    schema.on('error', (err) => {
        debug(err.stack);
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function rest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    rest (url, model) {
        if (model === undefined) {
            model = url;
            url = undefined;
        }
Severity: Minor
Found in src/support/KoatonRouter.js - About 1 hr to fix

Function subdomainrouter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default async function subdomainrouter (ctx, next) {
    ctx.subdomain = 'www';
    for (const subdomain of configuration.server.subdomains) {
        if (ctx.request.host.indexOf(subdomain) === 0) {
            ctx.state.subdomain = subdomain;
Severity: Minor
Found in src/middleware/subdomainrouter.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 makeLink has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function makeLink (ctx, url, render) {
    let route = KoatonRouter.AllRoutes(ctx.subdomain).map(exp => {
        let variables = (exp[1].match(/\$/g) || []).length;
        let matches = (url.match(exp[0]) || []).length - 1;
        if (matches === variables && url.replace(...exp).indexOf('.') === -1) {
Severity: Minor
Found in src/views/setup.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 getQuery has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function getQuery (database, model, filtergroup) {
    let group = [];
    for (let index in filtergroup) {
        let filter = filtergroup[index];
        if (filter.key.indexOf('.') > -1) {
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 1 hr to fix

Function start has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

App.start = function (port, usehttp2 = false) {
    for (const route of koaton.router.options()) {
        App.use(route);
    }
    let callback = () => {
Severity: Minor
Found in src/index.js - About 1 hr to fix

Function token has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        async function token (ctx, next) {
            await next();
            ctx.state = {
                data: {
                    client: await models.oauth2applications.findOne({
Severity: Minor
Found in src/middleware/oauth2server.js - About 1 hr to fix

Function request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    request (method, url, binding = 'index', secured = false) {
        let Action;
        if (typeof binding === 'boolean') {
            secured = binding;
            binding = 'index';
Severity: Minor
Found in src/support/KoatonRouter.js - About 1 hr to fix

Function makerelation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makerelation (model, relation) {
    let options = {
        as: relation.As,
        foreignKey: relation.key
    };
Severity: Minor
Found in src/middleware/orm.js - About 1 hr to fix

Function getQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

async function getQuery (database, model, filtergroup) {
    let group = [];
    for (let index in filtergroup) {
        let filter = filtergroup[index];
        if (filter.key.indexOf('.') > -1) {
Severity: Minor
Found in src/support/toMongooseStringQuery.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 prepareQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function prepareQuery (database, model, query, item) {
    let [modelname, property] = item.split('.');
    let prequery = {};
    let value = (query.value ? query.value : query[item]);
    value = query.condition === '===' ? value : (property === 'id' ? value : new RegExp(`.*${value}.*`));
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 1 hr to fix

Function oauth2application has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    oauth2application (schema) {
        return {
            'model': {
                'ClientId': {
                    type: schema.String
Severity: Minor
Found in src/middleware/oauth2models.js - About 1 hr to fix

Function constructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor () {
        /** @type {Object} */
        this.bundles = null;
        /** @type {Object} */
        this.conections = null;
Severity: Minor
Found in src/support/configuration.js - About 1 hr to fix

Function oauth2accesstoken has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    oauth2accesstoken (schema) {
        return {
            'model': {
                'UserId': {
                    type: schema.String
Severity: Minor
Found in src/middleware/oauth2models.js - About 1 hr to fix

Function rawWhere has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        model.rawWhere = function rawWhere (stringquery, opts) {
            let that = this;
            return new Promise(function (resolve, reject) {
                let where = that.$where(stringquery);
                for (let prop in opts) {
Severity: Minor
Found in src/support/extend_caminte.js - About 1 hr to fix

Function start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

App.start = function (port, usehttp2 = false) {
    for (const route of koaton.router.options()) {
        App.use(route);
    }
    let callback = () => {
Severity: Minor
Found in src/index.js - About 55 mins 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 request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    request (method, url, binding = 'index', secured = false) {
        let Action;
        if (typeof binding === 'boolean') {
            secured = binding;
            binding = 'index';
Severity: Minor
Found in src/support/KoatonRouter.js - About 55 mins 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 buildFilterSet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

async function buildFilterSet (query, model, database) {
    let filterset = query.filterset || [];
    if (query.filterset) {
        delete query.filterset;
    }
Severity: Minor
Found in src/support/toMongooseStringQuery.js - About 45 mins 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