Showing 60 of 122 total issues
Function validationMiddleware
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const validationMiddleware = async (ctx, next) => {
logger.info(`[DatasetRouter] Validating`);
if (ctx.request.body.dataset) {
ctx.request.body = Object.assign(ctx.request.body, ctx.request.body.dataset);
delete ctx.request.body.dataset;
Function validationMiddleware
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const validationMiddleware = async (ctx, next) => {
logger.info(`[DatasetRouter] Validating`);
if (ctx.request.body.dataset) {
ctx.request.body = Object.assign(ctx.request.body, ctx.request.body.dataset);
delete ctx.request.body.dataset;
- 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 notifyAdapterCreate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async notifyAdapterCreate(ctx, dataset) {
const { connectorType, provider } = dataset;
const clonedDataset = { ...dataset.toObject() };
clonedDataset.id = dataset._id;
- 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 init
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const init: () => Promise<IInit> = async (): Promise<IInit> => {
return new Promise((resolve, reject) => {
async function onDbReady(err: Error): Promise<void> {
if (err) {
if (retries >= 0) {
- 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 exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
- 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 delete
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async delete(dataset, user, apiKey, applicationBasedDelete = true) {
logger.debug(`[DatasetService]: Getting dataset with id: ${dataset.id}`);
logger.info(`[DBACCESS-FIND]: dataset.id: ${dataset.id}`);
const id = dataset.id;
if (!dataset) {
- 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
Avoid deeply nested control flow statements. Open
} else if (Object.keys(result).indexOf(el.attributes.dataset) < 0) {
result[el.attributes.dataset] = [el];
} else {
result[el.attributes.dataset].push(el);
}
Function getTableName
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static getTableName(dataset) {
try {
if (dataset.provider === 'cartodb' && dataset.connectorUrl) {
if (dataset.connectorUrl.indexOf('/tables/') >= 0) {
return new URL(dataset.connectorUrl).pathname.split('/tables/')[1].split('/')[0];
- 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
Avoid deeply nested control flow statements. Open
if (isAdmin) {
result[el._id] = el;
}
Function notifyAdapter
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async notifyAdapter(ctx, dataset) {
const { connectorType, provider } = dataset;
const clonedDataset = { ...dataset.toObject() };
clonedDataset.id = dataset._id;
clonedDataset.connector_url = dataset.connectorUrl;
- 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 getAll
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async getAll(apiKey, query = {}, isAdmin = false) {
logger.debug(`[DatasetService]: Getting all datasets`);
const sort = query.sort || '';
const page = query['page[number]'] ? parseInt(query['page[number]'], 10) : 1;
const limit = query['page[size]'] ? parseInt(query['page[size]'], 10) : 10;
- 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
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return dataset.tableName;
Avoid too many return
statements within this function. Open
return;
Function create
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async create(ctx) {
logger.info(`[DatasetRouter] Creating dataset with name: ${ctx.request.body.name}`);
try {
const user = DatasetRouter.getUser(ctx);
const dataset = await DatasetService.create(ctx.request.body, user, ctx.request.headers['x-api-key']);
- 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 getFilteredQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static getFilteredQuery(query, ids = []) {
const { collection, favourite } = query;
if (!query.application && query.app) {
query.application = query.app;
if (favourite) {
- 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 get
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async get(ctx) {
const id = ctx.params.dataset;
logger.info(`[DatasetRouter] Getting dataset with id: ${id}`);
const user = DatasetRouter.getUser(ctx);
const { query } = ctx;
- 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 getFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async getFields(filePath, provider) {
logger.debug('Obtaining fields');
let fields = null;
try {
switch (provider) {
- 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 checkSync
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static checkSync(sync) {
if (DatasetValidator.isObject(sync)) {
try {
cronParser.parseExpression(sync.cronPattern);
if (['concat', 'overwrite'].indexOf(sync.action) >= 0 && DatasetValidator.validUrl(sync.url)) {
- 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"