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;
}
- Read upRead up
- Create a ticketCreate a ticket
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);
}
- Create a ticketCreate a ticket
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 = {};
- Create a ticketCreate a ticket
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];
- Read upRead up
- Create a ticketCreate a ticket
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];
}
- Create a ticketCreate a ticket
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}.*`));
- Read upRead up
- Create a ticketCreate a ticket
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"