resource-watch/graph-client

View on GitHub
app/src/routes/api/v1/graph.router.js

Summary

Maintainability
F
2 wks
Test Coverage
D
65%

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

    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 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 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 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 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 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 queryMostViewed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  static async queryMostViewed(ctx) {
                      logger.info('Returning datasets most viewed');
                      const application = ctx.query.application || ctx.query.app || 'rw';
                      const viewsCount = await QueryService.queryMostViewed(application);
                      const datasetIds = [];
              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

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async querySimilarDatasets(ctx) {
                      logger.info('Obtaining similar datasets', ctx.params.dataset);
                      const application = ctx.query.application || ctx.query.app || 'rw';
                      const dataset = ctx.params.dataset || ctx.query.dataset || false;
                      ctx.assert(dataset, 400, 'dataset query param required');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 2 days to fix
              app/src/routes/api/v1/graph.router.js on lines 409..432

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 376.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async querySimilarDatasetsIncludingDescendent(ctx) {
                      logger.info('Obtaining similar datasets with descendent', ctx.params.dataset);
                      const application = ctx.query.application || ctx.query.app || 'rw';
                      const dataset = ctx.params.dataset || ctx.query.dataset || false;
                      ctx.assert(dataset, 400, 'dataset query param required');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 2 days to fix
              app/src/routes/api/v1/graph.router.js on lines 384..407

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 376.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async conceptsInferred(ctx) {
                      let concepts = null;
                      const application = ctx.query.application || ctx.query.app || 'rw';
                      if (ctx.query.concepts) {
                          concepts = ctx.query.concepts.split(',').map((c) => c.trim());
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 day to fix
              app/src/routes/api/v1/graph.router.js on lines 144..169

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 302.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async conceptsAncestors(ctx) {
                      let concepts = null;
                      const application = ctx.query.application || ctx.query.app || 'rw';
                      if (ctx.query.concepts) {
                          concepts = ctx.query.concepts.split(',').map((c) => c.trim());
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 day to fix
              app/src/routes/api/v1/graph.router.js on lines 117..142

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 302.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async createWidgetNodeAndRelation(ctx) {
                      logger.info('Creating widget node and relation with idWidget ', ctx.params.idWidget, ' and dataset ', ctx.params.idDataset);
                      ctx.set('uncache', `graph-widget widget-graph ${ctx.params.idWidget}-graph`);
                      ctx.body = await QueryService.createWidgetNodeAndRelation(ctx.params.idDataset, ctx.params.idWidget);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 3 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 47..51

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async createLayerNodeAndRelation(ctx) {
                      logger.info('Creating layer node and relation with idLayer ', ctx.params.idLayer, ' and dataset ', ctx.params.idDataset);
                      ctx.set('uncache', `graph-layer layer-graph ${ctx.params.idLayer}-graph`);
                      ctx.body = await QueryService.createLayerNodeAndRelation(ctx.params.idDataset, ctx.params.idLayer);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 3 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 41..45

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      const data = results.records ? results.records.map((el) => {
                          datasetIds.push(el._fields[0]);
                          return {
                              dataset: el._fields[0],
                              views: el._fields[1] ? el._fields[1].low : null
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 3 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 330..336

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 103.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      const simplifiedViewsCount = viewsCount.records ? viewsCount.records.map((el) => {
                          datasetIds.push(el._fields[0]);
                          return {
                              dataset: el._fields[0],
                              views: el._fields[1] ? el._fields[1].low : null
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 3 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 363..369

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 103.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                          if (results.records) {
                              results.records.map((el) => {
                                  if (el._fields[0].length > 0) {
                                      datasetIds = datasetIds.concat(el._fields[0]);
                                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 2 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 263..270
              app/src/services/query.service.js on lines 531..538

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 89.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 3 locations. Consider refactoring.
              Open

                      if (results.records) {
                          results.records.map((el) => {
                              if (el._fields[0].length > 0) {
                                  datasetIds = datasetIds.concat(el._fields[0]);
                              }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 2 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 301..308
              app/src/services/query.service.js on lines 531..538

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 89.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 5 locations. Consider refactoring.
              Open

                  static async deleteDataset(ctx) {
                      logger.info('Deleting dataset node with id ', ctx.params.id);
                      ctx.set('uncache', `graph-dataset dataset-graph ${ctx.params.id}-graph`);
                      ctx.body = await QueryService.deleteDatasetNode(ctx.params.id);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 4 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 13..17
              app/src/routes/api/v1/graph.router.js on lines 66..70
              app/src/routes/api/v1/graph.router.js on lines 72..76
              app/src/routes/api/v1/graph.router.js on lines 78..82

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 87.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 5 locations. Consider refactoring.
              Open

                  static async deleteWidgetNodeAndRelation(ctx) {
                      logger.info('Deleting widget node and relation with idWidget ', ctx.params.id);
                      ctx.set('uncache', `graph-widget widget-graph ${ctx.params.id}-graph`);
                      ctx.body = await QueryService.deleteWidgetNodeAndRelation(ctx.params.id);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 4 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 13..17
              app/src/routes/api/v1/graph.router.js on lines 60..64
              app/src/routes/api/v1/graph.router.js on lines 72..76
              app/src/routes/api/v1/graph.router.js on lines 78..82

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 87.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 5 locations. Consider refactoring.
              Open

                  static async deleteMetadata(ctx) {
                      logger.info('Deleting metadata node and relation with idWidget ', ctx.params.id);
                      ctx.set('uncache', `graph-metadata metadata-graph ${ctx.params.id}-graph`);
                      ctx.body = await QueryService.deleteMetadata(ctx.params.id);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 4 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 13..17
              app/src/routes/api/v1/graph.router.js on lines 60..64
              app/src/routes/api/v1/graph.router.js on lines 66..70
              app/src/routes/api/v1/graph.router.js on lines 72..76

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 87.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 5 locations. Consider refactoring.
              Open

                  static async deleteLayerNodeAndRelation(ctx) {
                      logger.info('Deleting layer node and relation with idWidget ', ctx.params.id);
                      ctx.set('uncache', `graph-layer layer-graph ${ctx.params.id}-graph`);
                      ctx.body = await QueryService.deleteLayerNodeAndRelation(ctx.params.id);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 4 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 13..17
              app/src/routes/api/v1/graph.router.js on lines 60..64
              app/src/routes/api/v1/graph.router.js on lines 66..70
              app/src/routes/api/v1/graph.router.js on lines 78..82

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 87.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 5 locations. Consider refactoring.
              Open

                  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`);
                      ctx.body = await QueryService.createDatasetNode(ctx.params.id);
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 4 other locations - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 60..64
              app/src/routes/api/v1/graph.router.js on lines 66..70
              app/src/routes/api/v1/graph.router.js on lines 72..76
              app/src/routes/api/v1/graph.router.js on lines 78..82

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 87.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async createFavouriteRelationWithResource(ctx) {
                      logger.info('Creating favourite relation ');
                      ctx.body = await QueryService.createFavouriteRelationWithResource(ctx.params.userId, ctx.params.resourceType, ctx.params.idResource, ctx.request.body.application || 'rw');
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 89..92

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 84.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  static async deleteFavouriteRelationWithResource(ctx) {
                      logger.info('Creating favourite relation ');
                      ctx.body = await QueryService.deleteFavouriteRelationWithResource(ctx.params.userId, ctx.params.resourceType, ctx.params.idResource, ctx.request.query.application || 'rw');
                  }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 2 hrs to fix
              app/src/routes/api/v1/graph.router.js on lines 84..87

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 84.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.body = await QueryService.createRelationWithConcepts(ctx.params.resourceType, ctx.params.idResource, ctx.request.body.tags, ctx.request.body.application || 'rw');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 23..23

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 68.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.body = await QueryService.createRelationWithConcepts(ctx.params.resourceType, ctx.params.idResource, ctx.request.body.tags, ctx.request.body.application || 'rw');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 31..31

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 68.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (datasetIds.length > 0) {
                          result = await datasetService.checkDatasets(datasetIds, ctx.query, ctx.request.headers['x-api-key']);
                      } else {
                          result = [];
                      }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 273..277

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 62.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (datasetIds.length > 0) {
                          result = await datasetService.checkDatasets(datasetIds, ctx.query, ctx.request.headers['x-api-key']);
                      } else {
                          result = [];
                      }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 371..375

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 62.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.assert(ctx.request.body && ctx.request.body.tags && ctx.request.body.tags.length > 0, 400, 'Tags body param is required');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 20..20

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.assert(ctx.request.body && ctx.request.body.tags && ctx.request.body.tags.length > 0, 400, 'Tags body param is required');
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 27..27

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (ctx.query.limit) {
                          ctx.body.data = ctx.body.data.slice(0, ctx.query.limit);
                      }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 347..349

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      if (ctx.query.limit) {
                          ctx.body.data = ctx.body.data.slice(0, ctx.query.limit);
                      }
              Severity: Major
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 1 hr to fix
              app/src/routes/api/v1/graph.router.js on lines 379..381

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.body = {
                          data: data.filter((el) => result.indexOf(el.dataset) >= 0)
                      };
              Severity: Minor
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 30 mins to fix
              app/src/routes/api/v1/graph.router.js on lines 344..346

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 45.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                      ctx.body = {
                          data: simplifiedViewsCount.filter((el) => datasets.indexOf(el.dataset) >= 0)
                      };
              Severity: Minor
              Found in app/src/routes/api/v1/graph.router.js and 1 other location - About 30 mins to fix
              app/src/routes/api/v1/graph.router.js on lines 376..378

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 45.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status