Showing 19 of 42 total issues
Function init
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function init() {
return new Promise((resolve, reject) => {
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
Function onDbReady
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function onDbReady(err) {
if (err) {
if (retries >= 0) {
retries -= 1;
logger.error(`Failed to connect to MongoDB uri ${mongoUri}, retrying...`);
File status-queue.service.js
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
const logger = require('logger');
const QueueService = require('services/queue.service');
const TaskService = require('services/task.service');
const DatasetService = require('services/dataset.service');
const { execution, status, task } = require('rw-doc-importer-messages');
Function exports
has 64 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);
Function getFilteredQuery
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
static getFilteredQuery(query) {
const allowedSearchFields = {
type: 'type',
status: 'status',
datasetId: 'datasetId',
Function serialize
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
static serialize(data, link = null, skipLogs = false) {
const result = {};
if (data && Array.isArray(data) && data.length === 0) {
result.data = [];
return result;
- 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 processMessage
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async processMessage() {
switch (this.statusMsg.type) {
case status.MESSAGE_TYPES.STATUS_INDEX_DEACTIVATED:
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 consume
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async consume(msg) {
logger.info(`Message received in ${config.get('queues.tasks')}`);
this.taskMsg = JSON.parse(msg.content.toString());
// check if any task is currently running for this dataset
Function indexCreated
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async indexCreated() {
const dataset = await DatasetService.get(this.currentTask.datasetId);
const { connectorUrl, sources } = dataset.data.attributes;
const datasetProps = {
Function serialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
static serialize(data, link = null, skipLogs = false) {
const result = {};
if (data && Array.isArray(data) && data.length === 0) {
result.data = [];
return result;
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 importConfirmed
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async importConfirmed() {
switch (this.currentTask.type) {
case task.MESSAGE_TYPES.TASK_OVERWRITE:
await this.sendExecutionTask(execution.MESSAGE_TYPES.EXECUTION_DELETE_INDEX, [{ index: 'message.index' }]);
Function processMessage
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async processMessage() {
// Create the message
let executorTaskMessage;
// Adding taskId
this.taskMsg.taskId = this.taskMsg.id;
Function getAll
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getAll(query = {}) {
logger.debug(`[TaskService]: Getting all tasks`);
const page = query['page[number]'] ? parseInt(query['page[number]'], 10) : 1;
const limit = query['page[size]'] ? parseInt(query['page[size]'], 10) : 10;
Function consume
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async consume(msg) {
logger.info(`Message received in ${config.get('queues.tasks')}`);
this.taskMsg = JSON.parse(msg.content.toString());
// check if any task is currently running for this 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 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 indexCreated
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async indexCreated() {
const dataset = await DatasetService.get(this.currentTask.datasetId);
const { connectorUrl, sources } = dataset.data.attributes;
const datasetProps = {
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
async init(consume) {
let conn = null;
while (connectAttempts >= 0 && conn === null) {
try {
// eslint-disable-next-line no-await-in-loop
- 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"