Showing 33 of 82 total issues
Function serialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static serialize(data, link = null, forceArray = false) {
const result = {};
if (data) {
if (data.docs) {
result.data = data.docs.map((el) => LayerSerializer.serializeElement(el));
Function serializeElement
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
static serializeElement(el) {
return {
id: el._id,
type: 'layer',
attributes: {
Function deleteByDataset
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async deleteByDataset(id, apiKey) {
logger.debug(`[LayerService - deleteByDataset]: Getting layers of dataset with id: ${id}`);
const layers = await Layer.find({
dataset: id
}).exec();
Function getByDataset
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getByDataset(resource) {
logger.debug(`[LayerService - getByDataset] Getting layers for datasets with ids ${resource.ids}`);
if (resource.app) {
if (resource.app.indexOf('@') >= 0) {
resource.app = {
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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async get(ctx) {
const id = ctx.params.layer;
logger.info(`[LayerRouter] Getting layer with id: ${id}`);
const includes = ctx.query.includes ? ctx.query.includes.split(',').map((elem) => elem.trim()) : [];
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 getFilteredQuery
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static getFilteredQuery(query, ids = []) {
const { collection } = query;
const { favourite } = query;
if (!query.application && query.app) {
query.application = query.app;
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
static async delete(layer, apiKey) {
logger.debug(`[LayerService - delete]: Getting layer with id: ${layer.id}`);
if (!layer) {
logger.error(`[LayerService]: Layer with id ${layer.id} doesn't exist`);
throw new LayerNotFound(`Layer with id '${layer.id}' doesn't exist`);
- 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;
Function getAll
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async getAll(query = {}, dataset = null, user, apiKey) {
logger.debug(`[LayerService - getAll]: Getting all layers`);
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
Function checkDataset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async checkDataset(ctx) {
if (ctx.params.dataset || ctx.request.body.dataset) {
const datasetId = ctx.params.dataset || ctx.request.body.dataset;
logger.info(`[DatasetService] Validating presence of dataset with id: ${datasetId}`);
- 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 getByDataset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static async getByDataset(resource) {
logger.debug(`[LayerService - getByDataset] Getting layers for datasets with ids ${resource.ids}`);
if (resource.app) {
if (resource.app.indexOf('@') >= 0) {
resource.app = {
- 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 validationMiddleware
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const validationMiddleware = async (ctx, next) => {
logger.debug(`[LayerRouter] Validating`);
if (ctx.request.body.layer) {
ctx.request.body = Object.assign(ctx.request.body, ctx.request.body.layer);
delete ctx.request.body.layer;
- 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"