gfw-api/gfw-geostore-api

View on GitHub

Showing 114 of 114 total issues

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

        if (process.env.NODE_ENV !== 'test' || geoStore.geojson.length < 2000) {
            logger.debug('Repaired geometry', 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 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

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

    static async getNewHash(hash) {
        const idCon = await IdConnection.findOne({ oldId: hash }).exec();
        if (!idCon) {
            return hash;
        }
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 105..111

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

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 async getNewHash(hash) {
        const idCon = await IdConnection.findOne({ oldId: hash }).exec();
        if (!idCon) {
            return hash;
        }
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 96..102

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

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

    static async repairGeometry(geojson) {

        if (process.env.NODE_ENV !== 'test' || geojson.length < 2000) {
            logger.debug('GeoJSON: %s', JSON.stringify(geojson));
        }
Severity: Minor
Found in app/src/services/geoStoreServiceV2.js - About 1 hr to fix

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

        async getNational(iso) {
            logger.debug('Obtaining national of iso %s', iso);
            const params = {
                iso: iso.toUpperCase(),
                id1: null,
    Severity: Minor
    Found in app/src/services/cartoDBService.js - About 1 hr to fix

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

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

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

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

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

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

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

                static async calculateBBox(geoStore) {
                    logger.debug('Calculating bbox');
                    geoStore.bbox = GeoStoreService.swapBBox(geoStore);
                    await geoStore.save();
                    return geoStore;
            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 280..285

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

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

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

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

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

            Refactorings

            Further Reading

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

                static async calculateBBox(geoStore) {
                    logger.debug('Calculating bbox');
                    geoStore.bbox = GeoStoreServiceV2.swapBBox(geoStore);
                    await geoStore.save();
                    return geoStore;
            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 288..293

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

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

                static async createGeoStore(ctx) {
                    logger.info('Saving GeoStore');
                    try {
                        const data = {
                            provider: ctx.request.body.provider,
            Severity: Minor
            Found in app/src/routes/api/v2/geoStore.router.js - About 1 hr to fix

              Function getArea has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static async getArea(ctx) {
                      logger.info('Retrieving Polygon Area');
                      try {
                          const data = {
                              provider: ctx.request.body.provider,
              Severity: Minor
              Found in app/src/routes/api/v1/geoStore.router.js - About 1 hr to fix

                Function getArea has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static async getArea(ctx) {
                        logger.info('Retrieving Polygon Area');
                        try {
                            const data = {
                                provider: ctx.request.body.provider,
                Severity: Minor
                Found in app/src/routes/api/v2/geoStore.router.js - About 1 hr to fix

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

                      client.execute(sql, params).done((data) => {
                          resolve(data);
                      }).error((err) => {
                          reject(err);
                      });
                  Severity: Minor
                  Found in app/src/services/cartoDBService.js and 1 other location - About 55 mins to fix
                  app/src/services/cartoDBServiceV2.js on lines 55..59

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

                  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

                      client.execute(sql, params).done((data) => {
                          resolve(data);
                      }).error((err) => {
                          reject(err);
                      });
                  Severity: Minor
                  Found in app/src/services/cartoDBServiceV2.js and 1 other location - About 55 mins to fix
                  app/src/services/cartoDBService.js on lines 44..48

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

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

                      static async getArea(ctx) {
                          logger.info('Retrieving Polygon Area');
                          try {
                              const data = {
                                  provider: ctx.request.body.provider,
                  Severity: Minor
                  Found in app/src/routes/api/v2/geoStore.router.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 exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

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

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      static async createGeoStore(ctx) {
                          logger.info('Saving GeoStore');
                          try {
                              const data = {
                                  provider: ctx.request.body.provider,
                  Severity: Minor
                  Found in app/src/routes/api/v2/geoStore.router.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 getArea has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async getArea(ctx) {
                          logger.info('Retrieving Polygon Area');
                          try {
                              const data = {
                                  provider: ctx.request.body.provider,
                  Severity: Minor
                  Found in app/src/routes/api/v1/geoStore.router.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 repairGeometry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async repairGeometry(geojson) {
                  
                          if (process.env.NODE_ENV !== 'test' || geojson.length < 2000) {
                              logger.debug('GeoJSON: %s', JSON.stringify(geojson));
                          }
                  Severity: Minor
                  Found in app/src/services/geoStoreServiceV2.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

                  Severity
                  Category
                  Status
                  Source
                  Language