Showing 76 of 129 total issues
Function getTask
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getTask = async (task) => {
logger.info(`[cronLoader] Publishing ${task.dataset}`);
if (task.dataset === 'dataset') {
redisClient.publish(CHANNEL, JSON.stringify({
layer_slug: task.dataset
Function getTopSubscriptions
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getTopSubscriptions(startDate, endDate, application) {
logger.debug(`Obtaining getTopSubscriptions with startDate ${startDate}, endDate ${endDate} and application ${application}`);
const topSubs = {};
const defaultFilter = {
createdAt: { $gte: startDate, $lt: endDate },
Function pathFor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static pathFor(subscription, layerSlug) {
const params = subscription.params || {};
if (layerSlug === 'story') {
if (params.iso && params.iso.country) {
Function getGeostoreIdByParams
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getGeostoreIdByParams(params) {
try {
let uri = '/geostore';
if (params.use && params.useid) {
uri += `/use/${params.use}/${params.useid}`;
Function checkUpdated
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async checkUpdated(dataset) {
logger.info(`Checking if dataset ${dataset} was updated`);
try {
const result = await ctRegisterMicroservice.requestToMicroservice({
uri: `/${dataset}/latest`,
Function getGeostoreIdByParams
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
static async getGeostoreIdByParams(params) {
try {
let uri = '/geostore';
if (params.use && params.useid) {
uri += `/use/${params.use}/${params.useid}`;
- 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 execute
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async execute(subscription, layerSlug, begin, end, forSubscription) {
logger.info('Executing analysis for', layerSlug, begin, end);
const period = `${formatDate(begin)},${formatDate(end)}`;
Function generate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
static generate(subscription, layer, begin, end) {
const diffInDays = moment(begin).diff(moment(end), 'days');
const queryForUrl = {
lang: subscription.language || 'en',
Function infoSubscriptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async infoSubscriptions(startDate, endDate, application) {
logger.debug(`Obtaining infoSubscriptions with startDate ${startDate}, endDate ${endDate} and application ${application}`);
const info = {};
const defaultFilter = {
Consider simplifying this complex logical expression. Open
if (
!data[i].params.iso
&& !data[i].params.id1
&& !data[i].params.wdpaid
&& !data[i].params.use
Function transform
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async transform(results, layer, subscription, begin, end) {
EmailHelpersService.updateMonthTranslations();
moment.locale(subscription.language || 'en');
try {
Function transform
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async transform(results, layer, subscription, begin, end) {
EmailHelpersService.updateMonthTranslations();
moment.locale(subscription.language || 'en');
try {
Function loadAPI
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const loadAPI = (app, path = routersPath, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
routesFiles.forEach((file) => {
const newPath = path ? (`${path}/${file}`) : file;
Function overviewImage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async overviewImage(subscription, slug, begin, end) {
const query = await getQuery(subscription);
if (!query) {
return null;
}
Function processMessage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static async processMessage(channel, message) {
logger.info('[AlertQueue] Processing alert message');
logger.debug(`[AlertQueue] Processing alert message: ${message}`);
if (JSON.parse(message).layer_slug === '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 decorateWithArea
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const decorateWithArea = (results, subscription) => {
const params = subscription.params || {};
if (params.iso && params.iso.country) {
results.selected_area = `ISO Code: ${params.iso.country}`;
- 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 transform
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async transform(results) {
results.alert_count = results.value;
let uri = `/query${results.downloadUrls.csv.split('download')[1]}`;
uri = uri.replace('ORDER BY year, day', ' ORDER BY day DESC, year DESC LIMIT 10').replace(/&format=(csv|json|xml)/g, '');
Function findAllSubscriptions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async findAllSubscriptions(ctx) {
logger.info(`[SubscriptionsRouter] Getting ALL subscriptions`);
const page = ctx.query.page && ctx.query.page.number ? parseInt(ctx.query.page.number, 10) : 1;
const limit = ctx.query.page && ctx.query.page.size ? parseInt(ctx.query.page.size, 10) : 10;
Function transform
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async transform(results, layer, subscription, begin, end) {
const alerts = await analysisService.execute(subscription, layer.slug, begin, end, true);
if (alerts && alerts.length && alerts.length > 0) {
const alertsFormat = [];
let length = 10;
Function getBBoxOfGeojson
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function getBBoxOfGeojson(geojson) {
const points = explode(geojson);
let minx = 360;
let
miny = 360;
- 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"