Showing 21 of 62 total issues
File graph.router.js
has 475 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-underscore-dangle */
const logger = require('logger');
const Router = require('koa-router');
const QueryService = require('services/query.service');
const datasetService = require('services/dataset.service');
File query.service.js
has 469 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-underscore-dangle */
const logger = require('logger');
const Neo4JService = require('services/neo4j.service');
const CREATE_DATASET = `MERGE (dataset:DATASET {id: {id}, views: 0}) RETURN dataset`;
QueryService
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class QueryService {
static async run(query, params) {
logger.info('Doing query ONLY READ ', query);
const data = await Neo4JService.query(query, params);
GraphRouter
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class GraphRouter {
static async createDataset(ctx) {
logger.info('Creating dataset node with id ', ctx.params.id);
ctx.set('uncache', `graph-dataset dataset-graph ${ctx.params.id}-graph`);
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 sortDatasets
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async sortDatasets(sort = '', datasets = null) {
let query;
let dir = 'ASC';
if (sort.startsWith('-')) {
// eslint-disable-next-line no-param-reassign
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 querySearchDatasets
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async querySearchDatasets(ctx) {
let concepts = null;
const application = ctx.query.application || ctx.query.app || 'rw';
if (ctx.method === 'GET') {
ctx.assert(ctx.query.concepts, 400, 'Concepts query params is required');
Function querySearchDatasetsIds
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async querySearchDatasetsIds(ctx) {
const { query } = ctx;
const application = query.application || query.app || 'rw';
const { sort, concepts } = query;
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 getListConcepts
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static async getListConcepts(application, includes = null, search = null) {
logger.debug('Getting list concepts');
let query = QUERY_GET_LIST_CONCEPTS[0];
if ((includes && includes.length > 0) || (search && search.length > 0)) {
query += ' WHERE ';
- 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 queryMostViewedByUser
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async queryMostViewedByUser(ctx) {
logger.info('Returning datasets most viewed by user');
if (!ctx.query.loggedUser) {
ctx.throw(401, 'Not authenticated');
return;
Function listConcepts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async listConcepts(ctx) {
logger.info('Getting list concepts ');
const application = ctx.query.application || ctx.query.app || 'rw';
const includes = ctx.query.includes ? ctx.query.includes.split(',') : null;
const defaultIncludes = ['TOPIC', 'DATA_TYPE', 'TIME_PERIOD', 'FREQUENCY'];
Function querySearchDatasetsIds
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static async querySearchDatasetsIds(ctx) {
const { query } = ctx;
const application = query.application || query.app || 'rw';
const { sort, concepts } = query;
- 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 querySearchDatasets
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async querySearchDatasets(concepts, application, depth) {
logger.debug('Searching datasets with concepts ', concepts);
let query = '';
const params = {
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 sortDatasets
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async sortDatasets(sort = '', datasets = null) {
let query;
let dir = 'ASC';
if (sort.startsWith('-')) {
// eslint-disable-next-line no-param-reassign
- 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 queryMostViewedByUser
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static async queryMostViewedByUser(ctx) {
logger.info('Returning datasets most viewed by user');
if (!ctx.query.loggedUser) {
ctx.throw(401, 'Not authenticated');
return;
- 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 querySearchDatasets
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static async querySearchDatasets(concepts, application, depth) {
logger.debug('Searching datasets with concepts ', concepts);
let query = '';
const params = {
- 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 querySearchDatasets
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async querySearchDatasets(ctx) {
let concepts = null;
const application = ctx.query.application || ctx.query.app || 'rw';
if (ctx.method === 'GET') {
ctx.assert(ctx.query.concepts, 400, 'Concepts query params is required');
- 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"