resource-watch/graph-client

View on GitHub

Showing 62 of 62 total issues

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

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

            if (application) {
                logger.debug(DELETE_RELATION.replace('{resourceType}', resourceType));
                await QueryService.run(DELETE_RELATION.replace('{resourceType}', resourceType), {
                    resourceId,
                    application
    Severity: Major
    Found in app/src/services/query.service.js and 1 other location - About 1 hr to fix
    app/src/services/query.service.js on lines 288..294

    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 57.

    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

            } else {
                logger.debug(DELETE_RELATION_ALL_APPS.replace('{resourceType}', resourceType));
                await QueryService.run(DELETE_RELATION_ALL_APPS.replace('{resourceType}', resourceType), {
                    resourceId,
                    application
    Severity: Major
    Found in app/src/services/query.service.js and 1 other location - About 1 hr to fix
    app/src/services/query.service.js on lines 282..288

    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 57.

    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

    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

      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

      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

      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

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

          static async createUserNodeAndRelation(idDataset, idWidget) {
              logger.debug('Creating user and relation with id ', idWidget, '; id dataset', idDataset);
              return QueryService.run(CREATE_WIDGET_AND_RELATION, {
                  idWidget,
                  idDataset
      Severity: Major
      Found in app/src/services/query.service.js and 3 other locations - About 35 mins to fix
      app/src/services/query.service.js on lines 369..375
      app/src/services/query.service.js on lines 392..398
      app/src/services/query.service.js on lines 453..459

      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 47.

      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 4 locations. Consider refactoring.
      Open

          static async createWidgetNodeAndRelation(idDataset, idWidget) {
              logger.debug('Creating widget and relation with id ', idWidget, '; id dataset', idDataset);
              return QueryService.run(CREATE_WIDGET_AND_RELATION, {
                  idWidget,
                  idDataset
      Severity: Major
      Found in app/src/services/query.service.js and 3 other locations - About 35 mins to fix
      app/src/services/query.service.js on lines 377..383
      app/src/services/query.service.js on lines 392..398
      app/src/services/query.service.js on lines 453..459

      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 47.

      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 4 locations. Consider refactoring.
      Open

          static async createLayerNodeAndRelation(idDataset, idLayer) {
              logger.debug('Creating layer and relation with id ', idLayer, '; id dataset', idDataset);
              return QueryService.run(CREATE_LAYER_AND_RELATION, {
                  idLayer,
                  idDataset
      Severity: Major
      Found in app/src/services/query.service.js and 3 other locations - About 35 mins to fix
      app/src/services/query.service.js on lines 369..375
      app/src/services/query.service.js on lines 377..383
      app/src/services/query.service.js on lines 453..459

      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 47.

      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 4 locations. Consider refactoring.
      Open

          static async querySearchByLabelSynonymons(search, application) {
              logger.debug('Obtaining dataset by search ', search, 'and application ', application);
              return QueryService.run(QUERY_SEARCH_BY_LABEL_SYNONYMONS, {
                  search,
                  application
      Severity: Major
      Found in app/src/services/query.service.js and 3 other locations - About 35 mins to fix
      app/src/services/query.service.js on lines 369..375
      app/src/services/query.service.js on lines 377..383
      app/src/services/query.service.js on lines 392..398

      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 47.

      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

      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

      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

      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

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

          static async queryMostViewedByUser(userId, application) {
              logger.debug('Obtaining dataset most viewed by user ', userId);
              return QueryService.run(QUERY_MOST_VIEWED_BY_USER, {
                  userId,
                  application
      Severity: Minor
      Found in app/src/services/query.service.js and 2 other locations - About 30 mins to fix
      app/src/services/query.service.js on lines 422..428
      app/src/services/query.service.js on lines 430..436

      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 3 locations. Consider refactoring.
      Open

          static async querySimilarDatasets(datasets, application) {
              logger.debug('Obtaining similar datasets of ', datasets);
              return QueryService.run(QUERY_SIMILAR_DATASET, {
                  datasets,
                  application
      Severity: Minor
      Found in app/src/services/query.service.js and 2 other locations - About 30 mins to fix
      app/src/services/query.service.js on lines 430..436
      app/src/services/query.service.js on lines 445..451

      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

      Severity
      Category
      Status
      Source
      Language