Showing 76 of 129 total issues
Function runSubscriptionQuery
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
static async runSubscriptionQuery(subscription, queryType) {
logger.info('Iterate over datasetsQuery of each subs');
const queryData = [];
for (let j = 0; j < subscription.datasetsQuery.length; j++) {
try {
- 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
File subscription.router.js
has 384 lines of code (exceeds 250 allowed). Consider refactoring. Open
const Router = require('koa-router');
const UrlService = require('services/urlService');
const logger = require('logger');
const moment = require('moment');
const mongoose = require('mongoose');
Function transformAndSaveData
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
const transformAndSaveData = async (data) => {
logger.info('Saving data');
if (data) {
for (let i = 0, { length } = data; i < length; i++) {
if (data[i].confirmed) {
- 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 runSubscriptionQuery
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async runSubscriptionQuery(subscription, queryType) {
logger.info('Iterate over datasetsQuery of each subs');
const queryData = [];
for (let j = 0; j < subscription.datasetsQuery.length; j++) {
try {
Function init
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function init() {
return new Promise((resolve, reject) => {
async function onDbReady(mongoConnectionError) {
if (mongoConnectionError) {
if (retries >= 0) {
File datasetService.js
has 311 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-continue */
const Subscription = require('models/subscription');
const ctRegisterMicroservice = require('ct-register-microservice-node');
const MailService = require('services/mailService');
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;
Function pathFor
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
static pathFor(subscription, layerSlug) {
const params = subscription.params || {};
if (layerSlug === 'story') {
if (params.iso && 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 onDbReady
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function onDbReady(mongoConnectionError) {
if (mongoConnectionError) {
if (retries >= 0) {
retries--;
logger.error(`Failed to connect to MongoDB uri ${mongoUri}, retrying...`);
Function infoGroupSubscriptions
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async infoGroupSubscriptions(startDate, endDate, application) {
logger.debug(`Obtaining group subscriptions with startDate ${startDate}, endDate ${endDate} and application ${application}`);
const filter = {
createdAt: { $gte: startDate, $lt: endDate },
datasets: { $ne: [] },
Function exports
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path = routersPath, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
routesFiles.forEach((file) => {
Function transformAndSaveData
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
const transformAndSaveData = async (data) => {
logger.info('Saving data');
if (data) {
for (let i = 0, { length } = data; i < length; i++) {
if (data[i].confirmed) {
Function transform
has 58 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 processMessage
has 54 lines of code (exceeds 25 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') {
Function exports
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (grunt) => {
grunt.file.setBase('..');
// eslint-disable-next-line import/no-extraneous-dependencies
require('load-grunt-tasks')(grunt);
Consider simplifying this complex logical expression. Open
if (data[i].confirmed) {
// logger.debug('Saving data', data[i]);
let userId = null;
if (data[i].user_id) {
userId = await obtainNewUserId(data[i].user_id);
Function getGeostoreIdByArea
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getGeostoreIdByArea(idArea) {
try {
logger.info('Obtaining area with id: ', idArea);
const areaResult = await ctRegisterMicroservice.requestToMicroservice({
uri: `/area/${idArea}`,
Function getBBoxQuery
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getBBoxQuery(client, subscription) {
if (subscription.params.iso && subscription.params.iso.country) {
if (!subscription.params.iso.region) {
const data = await executeThunk(client, geoQuery.ISO_BBOX, {
Function translateFrequency
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
static translateFrequency(status, lang = 'en') {
const translationsMap = {
en: {
'unusually high': 'unusually high',
high: 'high',
Function getQuery
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getQuery(subscription) {
if (subscription.params.iso && subscription.params.iso.country) {
if (!subscription.params.iso.region) {
return Mustache.render(geoQuery.ISO, {
iso: subscription.params.iso.country
Function getGeostoreIdByArea
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static async getGeostoreIdByArea(idArea) {
try {
logger.info('Obtaining area with id: ', idArea);
const areaResult = await ctRegisterMicroservice.requestToMicroservice({
uri: `/area/${idArea}`,
- 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"