resource-watch/graph-client

View on GitHub

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');
Severity: Minor
Found in app/src/routes/api/v1/graph.router.js - About 7 hrs to fix

    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`;
    Severity: Minor
    Found in app/src/services/query.service.js - About 7 hrs to fix

      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);
      Severity: Minor
      Found in app/src/services/query.service.js - About 3 hrs to fix

        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`);
        Severity: Minor
        Found in app/src/routes/api/v1/graph.router.js - About 3 hrs to fix

          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);
          Severity: Major
          Found in app/Gruntfile.js - About 2 hrs to fix

            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
            Severity: Minor
            Found in app/src/services/query.service.js - About 1 hr to fix

              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;
              Severity: Minor
              Found in app/src/loader.js - About 1 hr to fix

                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');
                Severity: Minor
                Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix

                  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;
                  
                  
                  Severity: Minor
                  Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix

                    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;
                    Severity: Minor
                    Found in app/src/loader.js - About 1 hr to fix

                      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 ';
                      Severity: Minor
                      Found in app/src/services/query.service.js - About 1 hr to fix

                      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;
                      Severity: Minor
                      Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix

                        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'];
                        Severity: Minor
                        Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix

                          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;
                          
                          
                          Severity: Minor
                          Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix

                          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 = {
                          Severity: Minor
                          Found in app/src/services/query.service.js - About 1 hr to fix

                            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;
                            Severity: Minor
                            Found in app/src/loader.js - About 55 mins to fix

                            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
                            Severity: Minor
                            Found in app/src/services/query.service.js - About 55 mins to fix

                            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;
                            Severity: Minor
                            Found in app/src/routes/api/v1/graph.router.js - About 45 mins to fix

                            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 = {
                            Severity: Minor
                            Found in app/src/services/query.service.js - About 45 mins to fix

                            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');
                            Severity: Minor
                            Found in app/src/routes/api/v1/graph.router.js - About 35 mins to fix

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language