gfw-api/gfw-geostore-api

View on GitHub

Showing 114 of 114 total issues

Function getRegional has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async getRegional(iso, id1, id2, thresh) {
        logger.debug('Obtaining admin2 of iso %s, id1 and id2', iso, id1, id2);
        const params = {
            id2: `${iso.toUpperCase()}.${parseInt(id1, 10)}.${parseInt(id2, 10)}_1`
        };
Severity: Minor
Found in app/src/services/cartoDBServiceV2.js - About 1 hr to fix

    Function getSubnational has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async getSubnational(iso, id1, thresh) {
            logger.debug('Obtaining subnational of iso %s and id1', iso, id1);
            const params = {
                id1: `${iso.toUpperCase()}.${parseInt(id1, 10)}_1`
            };
    Severity: Minor
    Found in app/src/services/cartoDBServiceV2.js - About 1 hr to fix

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

              if (data && data.provider) {
                  const geoJsonObtained = await GeoStoreService.obtainGeoJSON(data.provider);
                  geoStore.geojson = geoJsonObtained.geojson;
                  geoStore.areaHa = geoJsonObtained.area_ha;
              }
      Severity: Major
      Found in app/src/services/geoStoreService.js and 1 other location - About 1 hr to fix
      app/src/services/geoStoreServiceV2.js on lines 378..382

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

              if (data && data.provider) {
                  const geoJsonObtained = await GeoStoreServiceV2.obtainGeoJSON(data.provider);
                  geoStore.geojson = geoJsonObtained.geojson;
                  geoStore.areaHa = geoJsonObtained.area_ha;
              }
      Severity: Major
      Found in app/src/services/geoStoreServiceV2.js and 1 other location - About 1 hr to fix
      app/src/services/geoStoreService.js on lines 376..380

      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

      Function getNational has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async getNational(iso, thresh) {
              logger.info(`[CartoDBServiceV2 - getNational] Requesting ISO ${iso} from carto`);
              const params = {
                  iso: iso.toUpperCase()
              };
      Severity: Minor
      Found in app/src/services/cartoDBServiceV2.js - About 1 hr to fix

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

                if (ctx.errors) {
                    logger.debug('errors ', ctx.errors);
                    ctx.body = ErrorSerializer.serializeValidationBodyErrors(ctx.errors);
                    ctx.status = 400;
                    return;
        Severity: Major
        Found in app/src/validators/coverageValidator.js and 2 other locations - About 1 hr to fix
        app/src/validators/coverageValidator.js on lines 27..32
        app/src/validators/geoStoreValidator.js on lines 10..15

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

                if (ctx.errors) {
                    logger.debug('errors ', ctx.errors);
                    ctx.body = ErrorSerializer.serializeValidationBodyErrors(ctx.errors);
                    ctx.status = 400;
                    return;
        Severity: Major
        Found in app/src/validators/coverageValidator.js and 2 other locations - About 1 hr to fix
        app/src/validators/coverageValidator.js on lines 12..17
        app/src/validators/geoStoreValidator.js on lines 10..15

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

                if (ctx.errors) {
                    logger.debug('errors ', ctx.errors);
                    ctx.body = ErrorSerializer.serializeValidationBodyErrors(ctx.errors);
                    ctx.status = 400;
                    return;
        Severity: Major
        Found in app/src/validators/geoStoreValidator.js and 2 other locations - About 1 hr to fix
        app/src/validators/coverageValidator.js on lines 12..17
        app/src/validators/coverageValidator.js on lines 27..32

        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 use has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static async use(ctx) {
                logger.info('Obtaining use data with name %s and id %s', ctx.params.name, ctx.params.id);
                const thresh = ctx.query.simplify ? JSON.parse(ctx.query.simplify.toLowerCase()) : null;
                if (thresh && typeof thresh === Boolean && thresh !== true) {
                    ctx.throw(404, 'Bad syntax for simplify. Must be "true".');
        Severity: Minor
        Found in app/src/routes/api/v2/geoStore.router.js - About 1 hr to fix

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

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

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

                static async use(ctx) {
                    logger.info('Obtaining use data with name %s and id %s', ctx.params.name, ctx.params.id);
                    let useTable = null;
                    switch (ctx.params.name) {
            
            
            Severity: Minor
            Found in app/src/routes/api/v1/geoStore.router.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 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

              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

                  static translateBBox(bbox) {
                      logger.debug('Converting bbox from [-180,180] to [0,360] for representation');
                      return [bbox[0], bbox[1], 360 - Math.abs(bbox[2]), bbox[3]];
                  }
              Severity: Major
              Found in app/src/services/geoStoreService.js and 1 other location - About 1 hr to fix
              app/src/services/geoStoreServiceV2.js on lines 246..249

              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

                  static translateBBox(bbox) {
                      logger.debug('Converting bbox from [-180,180] to [0,360] for representation');
                      return [bbox[0], bbox[1], 360 - Math.abs(bbox[2]), bbox[3]];
                  }
              Severity: Major
              Found in app/src/services/geoStoreServiceV2.js and 1 other location - About 1 hr to fix
              app/src/services/geoStoreService.js on lines 254..257

              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

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

                      if (process.env.NODE_ENV !== 'test' || geoStore.geojson.length < 2000) {
                          logger.debug('Result', JSON.stringify(geoStore.geojson));
                      }
              Severity: Major
              Found in app/src/services/geoStoreServiceV2.js and 2 other locations - About 1 hr to fix
              app/src/services/geoStoreServiceV2.js on lines 323..325
              app/src/services/geoStoreServiceV2.js on lines 338..340

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

              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

                      if (process.env.NODE_ENV !== 'test' || geoStore.geojson.length < 2000) {
                          logger.debug('Converting', JSON.stringify(geoStore.geojson));
                      }
              Severity: Major
              Found in app/src/services/geoStoreServiceV2.js and 2 other locations - About 1 hr to fix
              app/src/services/geoStoreServiceV2.js on lines 338..340
              app/src/services/geoStoreServiceV2.js on lines 343..345

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

              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 crossAntimeridian has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static crossAntimeridian(feature, bbox) {
                      logger.info('Checking antimeridian');
              
                      const geomTypes = ['Point', 'MultiPoint'];
                      const bboxTotal = bbox || turf.bbox(feature);
              Severity: Minor
              Found in app/src/services/geoStoreServiceV2.js - About 1 hr to fix

                Function getUse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async getUse(use, id, thresh) {
                        logger.debug('Obtaining use with id %s', id);
                        const params = {
                            use,
                            id: parseInt(id, 10)
                Severity: Minor
                Found in app/src/services/cartoDBServiceV2.js - About 1 hr to fix

                  Function crossAntimeridian has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      static crossAntimeridian(feature, bbox) {
                          logger.info('Checking antimeridian');
                  
                          const geomTypes = ['Point', 'MultiPoint'];
                          const bboxTotal = bbox || turf.bbox(feature);
                  Severity: Minor
                  Found in app/src/services/geoStoreService.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language