gerard2p/koaton

View on GitHub

Showing 46 of 48 total issues

Function rest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    rest (url, model) {
        if (model === undefined) {
            model = url;
            url = undefined;
        }
Severity: Minor
Found in src/support/KoatonRouter.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

Avoid deeply nested control flow statements.
Open

                    if (res.id) {
                        modelRelations[related].push(id);
                    }
Severity: Major
Found in src/support/RestModel.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (typeof related === 'object') {
                            related[foreignKey] = foreignValue;
                            modelRelations[relation].push((await child.create(related)).id);
                        } else {
                            let data = {};
Severity: Major
Found in src/support/RestModel.js - About 45 mins to fix

Function toMongooseStringQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export default async function toMongooseStringQuery (queryBody, model, database) {
    let filterset = await buildFilterSet(queryBody, model, database);
    let query = [];
    for (let index in filterset) {
        let filtergroup = filterset[index];
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

Avoid deeply nested control flow statements.
Open

                            if (!res[prop]) {
                                res[prop] = data[prop];
                            }
Severity: Major
Found in src/support/extend_caminte.js - About 45 mins to fix

Function prepareQuery has a Cognitive Complexity of 7 (exceeds 5 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 35 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