Vizzuality/landgriffon

View on GitHub
api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts

Summary

Maintainability
F
5 days
Test Coverage

Function buildDashboard has 301 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async buildDashboard(dto: GetDashBoardDTO): Promise<EUDRDashboard> {
    if (dto.originIds) {
      dto.originIds = await this.adminRegionService.getAdminRegionDescendants(
        dto.originIds,
      );
Severity: Major
Found in api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts - About 1 day to fix

    File eudr-dashboard.service.ts has 583 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Inject, Injectable, NotFoundException } from '@nestjs/common';
    import { DataSource, EntityManager, SelectQueryBuilder } from 'typeorm';
    import {
      AlertedGeoregionsBySupplier,
      IEUDRAlertsRepository,
    Severity: Major
    Found in api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts - About 1 day to fix

      Function buildDashboardDetail has 173 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async buildDashboardDetail(
          supplierId: string,
          dto?: GetEUDRAlertDatesDto,
        ): Promise<EUDRDashBoardDetail> {
          const result: any = {};
      Severity: Major
      Found in api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts - About 6 hrs to fix

        Function getEntityMetadata has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async getEntityMetadata(dto: GetDashBoardDTO): Promise<EntityMetadata[]> {
            const queryBuilder: SelectQueryBuilder<EntityMetadata> =
              this.datasource.createQueryBuilder();
            queryBuilder
              .select('s.id', 'supplierId')
        Severity: Minor
        Found in api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts - About 1 hr to fix

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

              const materials: Record<any, { totalPercentage: number; detail: any[] }> = {
                [EUDRDashBoardFields.DEFORASTATION_FREE_SUPPLIERS]: {
                  totalPercentage: 0,
                  detail: [],
                },
          api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts on lines 68..81

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

          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 origins: Record<any, { totalPercentage: number; detail: any[] }> = {
                [EUDRDashBoardFields.DEFORASTATION_FREE_SUPPLIERS]: {
                  totalPercentage: 0,
                  detail: [],
                },
          api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts on lines 53..66

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

          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 totalPercentage: number =
                  materials[key].detail.reduce(
                    (acc: number, cur: any) => acc + cur.value,
                    0,
                  ) / materials[key].detail.length;
          api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts on lines 339..343

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

          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 totalPercentage: number =
                  origins[key].detail.reduce(
                    (acc: number, cur: any) => acc + cur.value,
                    0,
                  ) / origins[key].detail.length;
          api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts on lines 289..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 65.

          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 {
                  supplierId,
                  materialId,
                  adminRegionId,
                  totalSourcingLocations,
          client/src/store/features/analysis/selector.ts on lines 10..22

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 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

          There are no issues that match your filters.

          Category
          Status