Showing 44 of 126 total issues
Function exports
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
Function get
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async get(ctx) {
logger.info(`Obtaining v2 area with areaId ${ctx.params.id}`);
if (!mongoose.Types.ObjectId.isValid(ctx.params.id)) {
ctx.throw(404, 'Area not found');
Function getRequestBodyForSubscriptionFromArea
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static getRequestBodyForSubscriptionFromArea(area) {
const body = {
name: area.name,
datasets: SubscriptionsService.getDatasetsForSubscription(area),
language: area.language,
Function get
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static async get(ctx) {
logger.info(`Obtaining v2 area with areaId ${ctx.params.id}`);
if (!mongoose.Types.ObjectId.isValid(ctx.params.id)) {
ctx.throw(404, 'Area not found');
- 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 saveArea
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static async saveArea(ctx, userId) {
logger.info('Saving area');
let image = '';
if (ctx.request.files && ctx.request.files.image && ctx.request.files.image.s3Url) {
image = ctx.request.files.image.s3Url;
- 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 groupPoints
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static groupPoints(dataViirs, dataGlad, precisionBbox) {
logger.debug('Group points', ' and precisionBbox ', precisionBbox);
const result = {};
if (dataViirs) {
for (let i = 0, { length } = dataViirs; i < length; i++) {
- 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 groupPoints
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
static groupPoints(dataViirs, dataGlad, precisionBbox) {
logger.debug('Group points', ' and precisionBbox ', precisionBbox);
const result = {};
if (dataViirs) {
for (let i = 0, { length } = dataViirs; i < length; i++) {
Function update
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async update(ctx, next) {
logger.debug('Validating body for update area');
ctx.checkBody('name').optional().len(2, 100);
ctx.checkBody('application').optional().check((application) => AreaValidatorV2.notEmptyString(application), 'cannot be empty');
Function deleteByUserId
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async deleteByUserId(ctx) {
logger.info(`Deleting areas of user with id ${ctx.params.userId}`);
const userIdToDelete = ctx.params.userId;
try {
Function delete
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async delete(ctx) {
logger.info(`Deleting area with id ${ctx.params.id}`);
const areaToDelete = await AreaModel.findById(ctx.params.id);
if (areaToDelete) {
if (areaToDelete.subscriptionId) {
Function getFilteredQuery
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static getFilteredQuery(query, ids = []) {
const areaAttributes = Object.keys(Area.schema.obj);
logger.debug(`[getFilteredQuery] areaAttributes: ${areaAttributes}`);
Object.keys(query).forEach((param) => {
if (areaAttributes.indexOf(param) < 0) {
Function create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async create(ctx, next) {
logger.debug('Validating body for create area');
ctx.checkBody('name').notEmpty().len(1, 100);
ctx.checkBody('application').optional().check((application) => AreaValidatorV2.notEmptyString(application), 'cannot be empty');
Function loadAPI
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const loadAPI = (app, path, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
routesFiles.forEach((file) => {
const newPath = path ? (`${path}/${file}`) : file;
Function saveArea
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async saveArea(ctx, userId) {
logger.info('Saving area');
let image = '';
if (ctx.request.files && ctx.request.files.image && ctx.request.files.image.s3Url) {
image = ctx.request.files.image.s3Url;
Function updateByGeostore
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async updateByGeostore(ctx) {
const geostores = ctx.request.body.geostores || [];
const updateParams = ctx.request.body.update_params || {};
logger.info('Updating geostores: ', geostores);
logger.info('Updating with params: ', updateParams);
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 loggedUserToState
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function loggedUserToState(ctx, next) {
if (ctx.query && ctx.query.loggedUser) {
ctx.state.loggedUser = JSON.parse(ctx.query.loggedUser);
delete ctx.query.loggedUser;
} else if (ctx.request.body && ctx.request.body.loggedUser) {
- 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 serialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static serialize(data, link = null) {
const serializedData = link !== null ? areaSerializer.serialize(data.docs) : areaSerializer.serialize(data);
if (serializedData.data && Array.isArray(serializedData.data)) {
serializedData.data.forEach((el, idx) => {
- 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 getFilters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getFilters(ctx) {
const filter = shouldUseAllFilter(ctx) ? {} : { userId: ctx.state.loggedUser.id };
const { query } = ctx;
if (query.application) {
- 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 serialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static serialize(data, link = null) {
let result;
if (data.docs) {
result = areaSerializer.serialize(data.docs);
} else {
- 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"