resource-watch/graph-client

View on GitHub

Showing 62 of 62 total issues

Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (grunt) => {

    grunt.file.setBase('..');
    // eslint-disable-next-line import/no-extraneous-dependencies
    require('load-grunt-tasks')(grunt);
Severity: Major
Found in app/Gruntfile.js - About 2 hrs to fix

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

                this.init().then(() => {
                    this.driver.onCompleted = () => {
                        logger.info('[Neo4JService] Connected');
                    };
    
    
    Severity: Major
    Found in app/src/services/neo4j.service.js and 1 other location - About 2 hrs to fix
    app/src/services/neo4j.service.js on lines 14..22

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

    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

                this.init().then(() => {
                    this.driver.onCompleted = () => {
                        logger.info('[Neo4JService] Connected');
                    };
    
    
    Severity: Major
    Found in app/src/services/neo4j.service.js and 1 other location - About 2 hrs to fix
    app/src/services/neo4j.service.js on lines 33..41

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

    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

    Function sortDatasets has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static async sortDatasets(sort = '', datasets = null) {
            let query;
            let dir = 'ASC';
            if (sort.startsWith('-')) {
                // eslint-disable-next-line no-param-reassign
    Severity: Minor
    Found in app/src/services/query.service.js - About 1 hr to fix

      Function exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = (() => {
      
          const loadAPI = (app, path, pathApi) => {
              const routesFiles = fs.readdirSync(path);
              let existIndexRouter = false;
      Severity: Minor
      Found in app/src/loader.js - About 1 hr to fix

        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

        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

          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

                  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

          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

            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

                    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

            Function loadAPI has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const loadAPI = (app, path, pathApi) => {
                    const routesFiles = fs.readdirSync(path);
                    let existIndexRouter = false;
                    routesFiles.forEach((file) => {
                        const newPath = path ? (`${path}/${file}`) : file;
            Severity: Minor
            Found in app/src/loader.js - About 1 hr to fix

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

                                      if (pathApi) {
                                          app.use(mount(pathApi, require(newPath).middleware()));
                                      } else {
                                          app.use(require(newPath).middleware());
                                      }
              Severity: Major
              Found in app/src/loader.js and 1 other location - About 1 hr to fix
              app/src/loader.js on lines 42..46

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

              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 (pathApi) {
                              app.use(mount(pathApi, require(newPath).middleware()));
                          } else {
                              app.use(require(newPath).middleware());
                          }
              Severity: Major
              Found in app/src/loader.js and 1 other location - About 1 hr to fix
              app/src/loader.js on lines 25..29

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

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

                  static async getListConcepts(application, includes = null, search = null) {
                      logger.debug('Getting list concepts');
                      let query = QUERY_GET_LIST_CONCEPTS[0];
                      if ((includes && includes.length > 0) || (search && search.length > 0)) {
                          query += ' WHERE ';
              Severity: Minor
              Found in app/src/services/query.service.js - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function queryMostViewedByUser has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static async queryMostViewedByUser(ctx) {
                      logger.info('Returning datasets most viewed by user');
                      if (!ctx.query.loggedUser) {
                          ctx.throw(401, 'Not authenticated');
                          return;
              Severity: Minor
              Found in app/src/routes/api/v1/graph.router.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language