resource-watch/dataset

View on GitHub
src/services/dataset.service.js

Summary

Maintainability
F
1 wk
Test Coverage

File dataset.service.js has 724 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const { URL } = require('url');
const { default: logger } = require('logger');
const Dataset = require('models/dataset.model');
const RelationshipsService = require('services/relationships.service');
const { RWAPIMicroservice } = require('rw-api-microservice-node');
Severity: Major
Found in src/services/dataset.service.js - About 1 day to fix

    Function update has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        static async update(id, dataset, user, apiKey) {
            logger.debug(`[DatasetService]: Getting dataset with id:  ${id}`);
            logger.info(`[DBACCESS-FIND]: dataset.id: ${id}`);
    
            const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
    Severity: Minor
    Found in src/services/dataset.service.js - About 6 hrs 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 update has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static async update(id, dataset, user, apiKey) {
            logger.debug(`[DatasetService]: Getting dataset with id:  ${id}`);
            logger.info(`[DBACCESS-FIND]: dataset.id: ${id}`);
    
            const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
    Severity: Major
    Found in src/services/dataset.service.js - About 4 hrs to fix

      Function create has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static async create(dataset, user, apiKey) {
              logger.debug(`[DatasetService]: Getting dataset with name:  ${dataset.name}`);
              logger.info(`[DBACCES-FIND]: dataset.name: ${dataset.name}`);
              const tempSlug = await DatasetService.getSlug(dataset.name);
              // Check if raw dataset
      Severity: Major
      Found in src/services/dataset.service.js - About 3 hrs to fix

        Function create has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            static async create(dataset, user, apiKey) {
                logger.debug(`[DatasetService]: Getting dataset with name:  ${dataset.name}`);
                logger.info(`[DBACCES-FIND]: dataset.name: ${dataset.name}`);
                const tempSlug = await DatasetService.getSlug(dataset.name);
                // Check if raw dataset
        Severity: Minor
        Found in src/services/dataset.service.js - About 3 hrs 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

        DatasetService has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class DatasetService {
        
            // eslint-disable-next-line consistent-return
            static async getSlug(name) {
                const valid = false;
        Severity: Minor
        Found in src/services/dataset.service.js - About 3 hrs to fix

          Function getFilteredQuery has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static getFilteredQuery(query, ids = []) {
                  const { collection, favourite } = query;
                  if (!query.application && query.app) {
                      query.application = query.app;
                      if (favourite) {
          Severity: Major
          Found in src/services/dataset.service.js - About 3 hrs to fix

            Function delete has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static async delete(dataset, user, apiKey, applicationBasedDelete = true) {
                    logger.debug(`[DatasetService]: Getting dataset with id: ${dataset.id}`);
                    logger.info(`[DBACCESS-FIND]: dataset.id: ${dataset.id}`);
                    const id = dataset.id;
                    if (!dataset) {
            Severity: Major
            Found in src/services/dataset.service.js - About 2 hrs to fix

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

                  static async getAll(apiKey, query = {}, isAdmin = false) {
                      logger.debug(`[DatasetService]: Getting all datasets`);
                      const sort = query.sort || '';
                      const page = query['page[number]'] ? parseInt(query['page[number]'], 10) : 1;
                      const limit = query['page[size]'] ? parseInt(query['page[size]'], 10) : 10;
              Severity: Minor
              Found in src/services/dataset.service.js - About 1 hr to fix

                Function clone has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static async clone(id, dataset, user, apiKey, fullCloning = false) {
                        logger.debug(`[DatasetService]: Getting dataset with id:  ${id}`);
                        logger.info(`[DBACCESS-FIND]: dataset.id: ${id}`);
                        const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                            slug: id
                Severity: Minor
                Found in src/services/dataset.service.js - About 1 hr to fix

                  Function checkSecureDeleteResources has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      static async checkSecureDeleteResources(id, apiKey) {
                          logger.info('Checking if it is safe to delete the associated resources (layer, widget) of the dataset');
                          try {
                              const layers = await RWAPIMicroservice.requestToMicroservice({
                                  uri: `/v1/dataset/${id}/layer?protected=true`,
                  Severity: Minor
                  Found in src/services/dataset.service.js - About 1 hr to fix

                    Function updateEnv has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static async updateEnv(datasetId, env, apiKey) {
                            logger.debug('Updating env of all resources of dataset', datasetId, 'with env ', env);
                            try {
                                logger.debug('Updating widgets');
                                await RWAPIMicroservice.requestToMicroservice({
                    Severity: Minor
                    Found in src/services/dataset.service.js - About 1 hr to fix

                      Function delete has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static async delete(dataset, user, apiKey, applicationBasedDelete = true) {
                              logger.debug(`[DatasetService]: Getting dataset with id: ${dataset.id}`);
                              logger.info(`[DBACCESS-FIND]: dataset.id: ${dataset.id}`);
                              const id = dataset.id;
                              if (!dataset) {
                      Severity: Minor
                      Found in src/services/dataset.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 getTableName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static getTableName(dataset) {
                              try {
                                  if (dataset.provider === 'cartodb' && dataset.connectorUrl) {
                                      if (dataset.connectorUrl.indexOf('/tables/') >= 0) {
                                          return new URL(dataset.connectorUrl).pathname.split('/tables/')[1].split('/')[0];
                      Severity: Minor
                      Found in src/services/dataset.service.js - About 45 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

                      Function getAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static async getAll(apiKey, query = {}, isAdmin = false) {
                              logger.debug(`[DatasetService]: Getting all datasets`);
                              const sort = query.sort || '';
                              const page = query['page[number]'] ? parseInt(query['page[number]'], 10) : 1;
                              const limit = query['page[size]'] ? parseInt(query['page[size]'], 10) : 10;
                      Severity: Minor
                      Found in src/services/dataset.service.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

                      Avoid too many return statements within this function.
                      Open

                                  return dataset.tableName;
                      Severity: Major
                      Found in src/services/dataset.service.js - About 30 mins to fix

                        Function getFilteredQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            static getFilteredQuery(query, ids = []) {
                                const { collection, favourite } = query;
                                if (!query.application && query.app) {
                                    query.application = query.app;
                                    if (favourite) {
                        Severity: Minor
                        Found in src/services/dataset.service.js - About 25 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

                                if (dataset.sync && dataset.connectorType === 'document') {
                                    try {
                                        await SyncService.create(Object.assign(newDataset, dataset), apiKey);
                                    } catch (err) {
                                        if (err instanceof SyncError) {
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 5 hrs to fix
                        src/services/dataset.service.js on lines 468..481

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

                        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

                                if (dataset.sync && newDataset.connectorType === 'document') {
                                    try {
                                        await SyncService.update(Object.assign(newDataset, dataset), apiKey);
                                    } catch (err) {
                                        if (err instanceof SyncError) {
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 5 hrs to fix
                        src/services/dataset.service.js on lines 324..337

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

                        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

                                try {
                                    logger.debug('Updating widgets');
                                    await RWAPIMicroservice.requestToMicroservice({
                                        uri: `/v1/widget/change-environment/${datasetId}/${env}`,
                                        method: 'PATCH',
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 2 hrs to fix
                        src/services/dataset.service.js on lines 356..368

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

                        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

                                try {
                                    logger.debug('Updating layers');
                                    await RWAPIMicroservice.requestToMicroservice({
                                        uri: `/v1/layer/change-environment/${datasetId}/${env}`,
                                        method: 'PATCH',
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 2 hrs to fix
                        src/services/dataset.service.js on lines 343..355

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

                        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 deleteWidgets(datasetId, apiKey) {
                                logger.info('Deleting widgets of dataset', datasetId);
                                await RWAPIMicroservice.requestToMicroservice({
                                    uri: `/v1/dataset/${datasetId}/widget`,
                                    method: 'DELETE',
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 1 hr to fix
                        src/services/dataset.service.js on lines 496..505
                        src/services/dataset.service.js on lines 507..516
                        src/services/dataset.service.js on lines 518..527

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

                        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 deleteMetadata(datasetId, apiKey) {
                                logger.info('Deleting metadata of dataset', datasetId);
                                await RWAPIMicroservice.requestToMicroservice({
                                    uri: `/v1/dataset/${datasetId}/metadata`,
                                    method: 'DELETE',
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 1 hr to fix
                        src/services/dataset.service.js on lines 485..494
                        src/services/dataset.service.js on lines 496..505
                        src/services/dataset.service.js on lines 518..527

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

                        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 deleteVocabularies(datasetId, apiKey) {
                                logger.info('Deleting vocabularies of dataset', datasetId);
                                await RWAPIMicroservice.requestToMicroservice({
                                    uri: `/v1/dataset/${datasetId}/vocabulary`,
                                    method: 'DELETE',
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 1 hr to fix
                        src/services/dataset.service.js on lines 485..494
                        src/services/dataset.service.js on lines 496..505
                        src/services/dataset.service.js on lines 507..516

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

                        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 deleteLayers(datasetId, apiKey) {
                                logger.info('Deleting layers of dataset', datasetId);
                                await RWAPIMicroservice.requestToMicroservice({
                                    uri: `/v1/dataset/${datasetId}/layer`,
                                    method: 'DELETE',
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 1 hr to fix
                        src/services/dataset.service.js on lines 485..494
                        src/services/dataset.service.js on lines 507..516
                        src/services/dataset.service.js on lines 518..527

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

                        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

                                        try {
                                            logger.debug('[DatasetService]: Creating relations in graph');
                                            await GraphService.associateTags(newDataset._id, dataset.vocabularies, apiKey);
                                        } catch (err) {
                                            newDataset.errorMessage = err.message;
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 1 hr to fix
                        src/services/dataset.service.js on lines 314..322

                        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 (
                                    sort.indexOf('most-favorited') >= 0
                                    || sort.indexOf('most-viewed') >= 0
                                    || sort.indexOf('relevance') >= 0
                                    || sort.indexOf('metadata') >= 0
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 1 hr to fix
                        src/services/dataset.service.js on lines 685..693

                        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

                                    try {
                                        await RelationshipsService.createVocabularies(newDataset._id, dataset.vocabularies, apiKey);
                                    } catch (err) {
                                        newDataset.errorMessage = err.message;
                                        const result = await DatasetService.update(newDataset._id, newDataset, {
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 1 hr to fix
                        src/services/dataset.service.js on lines 303..312

                        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 (
                                    sort.indexOf('most-favorited') >= 0
                                    || sort.indexOf('most-viewed') >= 0
                                    || sort.indexOf('relevance') >= 0
                                    || sort.indexOf('metadata') >= 0
                        Severity: Major
                        Found in src/services/dataset.service.js and 1 other location - About 1 hr to fix
                        src/services/dataset.service.js on lines 697..710

                        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

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

                                    const widgets = await RWAPIMicroservice.requestToMicroservice({
                                        uri: `/v1/dataset/${id}/widget?protected=true`,
                                        method: 'GET',
                                        json: true,
                                        headers: {
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 55 mins to fix
                        src/services/dataset.service.js on lines 543..550
                        src/services/relationships.service.js on lines 197..204
                        src/services/sync.service.js on lines 62..69

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

                        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

                                    const layers = await RWAPIMicroservice.requestToMicroservice({
                                        uri: `/v1/dataset/${id}/layer?protected=true`,
                                        method: 'GET',
                                        json: true,
                                        headers: {
                        Severity: Major
                        Found in src/services/dataset.service.js and 3 other locations - About 55 mins to fix
                        src/services/dataset.service.js on lines 560..567
                        src/services/relationships.service.js on lines 197..204
                        src/services/sync.service.js on lines 62..69

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

                        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

                                                if (query[param].indexOf('@') >= 0) {
                                                    query[param] = {
                                                        $all: query[param].split('@').map((elem) => elem.trim())
                                                    };
                                                } else {
                        Severity: Minor
                        Found in src/services/dataset.service.js and 1 other location - About 50 mins to fix
                        src/services/dataset.service.js on lines 135..139

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

                        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

                                let dataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                                    slug: id
                                }).exec();
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 50 mins to fix
                        src/services/dataset.service.js on lines 375..377
                        src/services/dataset.service.js on lines 578..580
                        src/services/dataset.service.js on lines 720..722
                        src/services/dataset.service.js on lines 789..791

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

                        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

                                const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                                    slug: id
                                }).exec();
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 50 mins to fix
                        src/services/dataset.service.js on lines 235..237
                        src/services/dataset.service.js on lines 375..377
                        src/services/dataset.service.js on lines 720..722
                        src/services/dataset.service.js on lines 789..791

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

                        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

                                const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                                    slug: id
                                }).exec();
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 50 mins to fix
                        src/services/dataset.service.js on lines 235..237
                        src/services/dataset.service.js on lines 375..377
                        src/services/dataset.service.js on lines 578..580
                        src/services/dataset.service.js on lines 720..722

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

                        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 {
                                                    query[param] = {
                                                        $in: query[param].split(',').map((elem) => elem.trim())
                                                    };
                                                }
                        Severity: Minor
                        Found in src/services/dataset.service.js and 1 other location - About 50 mins to fix
                        src/services/dataset.service.js on lines 131..135

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

                        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

                                const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                                    slug: id
                                }).exec();
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 50 mins to fix
                        src/services/dataset.service.js on lines 235..237
                        src/services/dataset.service.js on lines 578..580
                        src/services/dataset.service.js on lines 720..722
                        src/services/dataset.service.js on lines 789..791

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

                        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

                                const currentDataset = await Dataset.findById(id).exec() || await Dataset.findOne({
                                    slug: id
                                }).exec();
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 50 mins to fix
                        src/services/dataset.service.js on lines 235..237
                        src/services/dataset.service.js on lines 375..377
                        src/services/dataset.service.js on lines 578..580
                        src/services/dataset.service.js on lines 789..791

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

                        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

                                const includes = query.includes ? query.includes.split(',').map((elem) => elem.trim()) : [];
                        Severity: Major
                        Found in src/services/dataset.service.js and 2 other locations - About 40 mins to fix
                        src/services/dataset.service.js on lines 238..238
                        src/services/dataset.service.js on lines 676..676

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

                        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

                                const ids = query.ids ? query.ids.split(',').map((elem) => elem.trim()) : [];
                        Severity: Major
                        Found in src/services/dataset.service.js and 2 other locations - About 40 mins to fix
                        src/services/dataset.service.js on lines 238..238
                        src/services/dataset.service.js on lines 677..677

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

                        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

                                const includes = query.includes ? query.includes.split(',').map((elem) => elem.trim()) : [];
                        Severity: Major
                        Found in src/services/dataset.service.js and 2 other locations - About 40 mins to fix
                        src/services/dataset.service.js on lines 676..676
                        src/services/dataset.service.js on lines 677..677

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

                        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

                                if (!currentDataset) {
                                    logger.error(`[DatasetService]: Dataset with id ${id} doesn't exist`);
                                    throw new DatasetNotFound(`Dataset with id '${id}' doesn't exist`);
                                }
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 30 mins to fix
                        src/services/dataset.service.js on lines 239..242
                        src/services/dataset.service.js on lines 378..381
                        src/services/dataset.service.js on lines 588..591
                        src/services/dataset.service.js on lines 792..795

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

                                if (!currentDataset) {
                                    logger.error(`[DatasetService]: Dataset with id ${id} doesn't exist`);
                                    throw new DatasetNotFound(`Dataset with id '${id}' doesn't exist`);
                                }
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 30 mins to fix
                        src/services/dataset.service.js on lines 239..242
                        src/services/dataset.service.js on lines 378..381
                        src/services/dataset.service.js on lines 588..591
                        src/services/dataset.service.js on lines 723..726

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

                                if (!dataset) {
                                    logger.error(`[DatasetService]: Dataset with id ${id} doesn't exist`);
                                    throw new DatasetNotFound(`Dataset with id '${id}' doesn't exist`);
                                }
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 30 mins to fix
                        src/services/dataset.service.js on lines 239..242
                        src/services/dataset.service.js on lines 378..381
                        src/services/dataset.service.js on lines 723..726
                        src/services/dataset.service.js on lines 792..795

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

                                if (!dataset) {
                                    logger.info(`[DatasetService]: Dataset with id ${id} doesn't exist`);
                                    throw new DatasetNotFound(`Dataset with id '${id}' doesn't exist`);
                                }
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 30 mins to fix
                        src/services/dataset.service.js on lines 378..381
                        src/services/dataset.service.js on lines 588..591
                        src/services/dataset.service.js on lines 723..726
                        src/services/dataset.service.js on lines 792..795

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

                                if (!currentDataset) {
                                    logger.error(`[DatasetService]: Dataset with id ${id} doesn't exist`);
                                    throw new DatasetNotFound(`Dataset with id '${id}' doesn't exist`);
                                }
                        Severity: Major
                        Found in src/services/dataset.service.js and 4 other locations - About 30 mins to fix
                        src/services/dataset.service.js on lines 239..242
                        src/services/dataset.service.js on lines 588..591
                        src/services/dataset.service.js on lines 723..726
                        src/services/dataset.service.js on lines 792..795

                        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