gfw-api/gfw-quicc-alerts-api

View on GitHub

Showing 12 of 12 total issues

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

            if (data.rows && data.rows.length > 0) {
                const result: Record<string, any> = data.rows[0];
                result.period = getPeriodText(period);
                result.downloadUrls = this.getDownloadUrls(WORLD, params);
                return result;
Severity: Major
Found in src/services/cartoDBService.ts and 4 other locations - About 2 hrs to fix
src/services/cartoDBService.ts on lines 157..162
src/services/cartoDBService.ts on lines 179..184
src/services/cartoDBService.ts on lines 202..207
src/services/cartoDBService.ts on lines 223..228

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

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 (data.rows && data.rows.length > 0) {
            const result: Record<string, any> = data.rows[0];
            result.period = getPeriodText(period);
            result.downloadUrls = this.getDownloadUrls(WDPA, params);
            return result;
Severity: Major
Found in src/services/cartoDBService.ts and 4 other locations - About 2 hrs to fix
src/services/cartoDBService.ts on lines 157..162
src/services/cartoDBService.ts on lines 179..184
src/services/cartoDBService.ts on lines 202..207
src/services/cartoDBService.ts on lines 269..274

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

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 (data.rows && data.rows.length > 0) {
            const result: Record<string, any> = data.rows[0];
            result.period = getPeriodText(period);
            result.downloadUrls = this.getDownloadUrls(ISO, params);
            return result;
Severity: Major
Found in src/services/cartoDBService.ts and 4 other locations - About 2 hrs to fix
src/services/cartoDBService.ts on lines 179..184
src/services/cartoDBService.ts on lines 202..207
src/services/cartoDBService.ts on lines 223..228
src/services/cartoDBService.ts on lines 269..274

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

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 (data.rows && data.rows.length > 0) {
            const result: Record<string, any> = data.rows[0];
            result.period = getPeriodText(period);
            result.downloadUrls = this.getDownloadUrls(ID1, params);
            return result;
Severity: Major
Found in src/services/cartoDBService.ts and 4 other locations - About 2 hrs to fix
src/services/cartoDBService.ts on lines 157..162
src/services/cartoDBService.ts on lines 202..207
src/services/cartoDBService.ts on lines 223..228
src/services/cartoDBService.ts on lines 269..274

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

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 (data.rows && data.rows.length > 0) {
            const result: Record<string, any> = data.rows[0];
            result.period = getPeriodText(period);
            result.downloadUrls = this.getDownloadUrls(USE, params);
            return result;
Severity: Major
Found in src/services/cartoDBService.ts and 4 other locations - About 2 hrs to fix
src/services/cartoDBService.ts on lines 157..162
src/services/cartoDBService.ts on lines 179..184
src/services/cartoDBService.ts on lines 223..228
src/services/cartoDBService.ts on lines 269..274

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

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

const init: () => Promise<IInit> = async (): Promise<IInit> => {
    return new Promise((resolve: (value: IInit | PromiseLike<IInit>) => void
    ) => {

        const app: Koa = new Koa();
Severity: Major
Found in src/app.ts - About 2 hrs to fix

    File cartoDBService.ts has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import config from 'config';
    import logger from 'logger';
    import Mustache from 'mustache';
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    Severity: Minor
    Found in src/services/cartoDBService.ts - About 2 hrs to fix

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

              const data: Record<string, any> | void = await CartoDBService.getNational(
                  ctx.params.iso,
                  ctx.request.query.alertQuery as string,
                  ctx.request.query.period as string
              );
      Severity: Major
      Found in src/routes/quiccAlerts.router.ts and 1 other location - About 2 hrs to fix
      src/routes/quiccAlerts.router.ts on lines 76..80

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

      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

              const data: Record<string, any> | void = await CartoDBService.getWdpa(
                  ctx.params.id,
                  ctx.request.query.alertQuery as string,
                  ctx.request.query.period as string
              );
      Severity: Major
      Found in src/routes/quiccAlerts.router.ts and 1 other location - About 2 hrs to fix
      src/routes/quiccAlerts.router.ts on lines 17..21

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

      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

          return `${today.getFullYear().toString()}-${(today.getMonth() + 1).toString()}-${today.getDate().toString()}`;
      Severity: Major
      Found in src/services/cartoDBService.ts and 1 other location - About 1 hr to fix
      src/services/cartoDBService.ts on lines 83..83

      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

          return `${yesterday.getFullYear().toString()}-${(yesterday.getMonth() + 1).toString()}-${yesterday.getDate().toString()}`;
      Severity: Major
      Found in src/services/cartoDBService.ts and 1 other location - About 1 hr to fix
      src/services/cartoDBService.ts on lines 78..78

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

          static async use(ctx: Context): Promise<void> {
              logger.info('Obtaining use data with name %s and id %s', ctx.params.name, ctx.params.id);
              let useTable: string = null;
              switch (ctx.params.name) {
      
      
      Severity: Minor
      Found in src/routes/quiccAlerts.router.ts - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language