Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

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

export class ActualVsScenarioImpactTableRowsValues extends ImpactTableBaseRowsValues {
  @ApiProperty()
  value: number;
  @ApiProperty()
  comparedScenarioValue: number;
Severity: Major
Found in api/src/modules/impact/dto/response-actual-scenario.dto.ts and 3 other locations - About 1 hr to fix
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 74..83
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 74..83
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 85..94

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

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

export class ScenarioVsScenarioIndicatorSumByYearData extends BaseIndicatorSumByYearData {
  @ApiProperty()
  baseScenarioValue: number;
  @ApiProperty()
  comparedScenarioValue: number;
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 74..83
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 85..94
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 85..94

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

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

  async addEudrImportJob(
    xlsxFileData: Express.Multer.File,
    taskId: string,
  ): Promise<void> {
    await this.eudrQueue.add('eudr', {
Severity: Major
Found in api/src/modules/import-data/workers/import-data.producer.ts and 1 other location - About 1 hr to fix
api/src/modules/import-data/workers/import-data.producer.ts on lines 23..31

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

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

export class ActualVsScenarioIndicatorSumByYear extends BaseIndicatorSumByYearData {
  @ApiProperty()
  value: number;
  @ApiProperty()
  comparedScenarioValue: number;
Severity: Major
Found in api/src/modules/impact/dto/response-actual-scenario.dto.ts and 3 other locations - About 1 hr to fix
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 85..94
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 74..83
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 85..94

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

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

export class ScenarioVsScenarioImpactTableRowsValues extends ImpactTableBaseRowsValues {
  @ApiProperty()
  baseScenarioValue: number;
  @ApiProperty()
  comparedScenarioValue: number;
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 74..83
api/src/modules/impact/dto/response-actual-scenario.dto.ts on lines 85..94
api/src/modules/impact/dto/response-scenario-scenario.dto.ts on lines 74..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 67.

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

  async addExcelImportJob(
    xlsxFileData: Express.Multer.File,
    taskId: string,
  ): Promise<void> {
    await this.importQueue.add('excel-import-job', {
Severity: Major
Found in api/src/modules/import-data/workers/import-data.producer.ts and 1 other location - About 1 hr to fix
api/src/modules/import-data/workers/import-data.producer.ts on lines 33..41

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

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

  async geoCodePointOfProduction(sourcingData: SourcingData): Promise<any> {
    if (!sourcingData.locationCountryInput)
      throw new Error(
        'A country must be provided for Point of Production location type',
      );

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

export const useAllContextualLayersData = <T = { layerId: Layer['id'] } & H3APIResponse>(
  options?: Omit<
    UseQueryOptions<
      { layerId: Layer['id'] } & H3APIResponse,
      ErrorResponse,
Severity: Minor
Found in client/src/hooks/h3-data/contextual.ts - About 1 hr to fix

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

      parseNode(
        node: AnyImpactTableRows,
        indicatorName:
          | Pick<ImpactTableDataByIndicator, 'indicatorShortName'>
          | string,
    Severity: Minor
    Found in api/src/modules/impact/reports/impact-report.parser.ts - About 1 hr to fix

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

        getTotalPurchasedVolumeByYear(
          rangeOfYears: number[],
          dataForImpactTable: ImpactTableData[],
          lastYearWithData: number,
          scenarioId?: string,
      Severity: Minor
      Found in api/src/modules/impact/base-impact.service.ts - About 1 hr to fix

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

        async function bootstrap(): Promise<void> {
          const logger: Logger = new Logger('bootstrap');
          const serverConfig: any = config.get('server');
          const app: INestApplication = await NestFactory.create(AppModule, {
            logger: serverConfig.loggerLevel,
        Severity: Minor
        Found in api/src/main.ts - About 1 hr to fix

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

            async geoCodeSourcingLocation(
              locationInfo: locationInfo,
            ): Promise<SourcingLocation> {
              let geoCodedSourcingLocation: Partial<SourcingData> = {};
              if (locationInfo.locationType === LOCATION_TYPES.UNKNOWN) {
          Severity: Minor
          Found in api/src/modules/geo-coding/geo-coding.service.ts - About 1 hr to fix

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

              private getAggregatedValuedByH3IndexAndResolution(
                baseMapQuery: SelectQueryBuilder<any>,
                resolution: number,
                mapType: IMPACT_MAP_TYPE,
              ): SelectQueryBuilder<any> {
            Severity: Minor
            Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                private async getAdminRegionByIntersection(
                  queryRunner: QueryRunner,
                  geometry: string,
                ): Promise<string> {
                  this.logger.log(`Intersecting EUDR geometry...`);
              Severity: Minor
              Found in api/src/modules/import-data/eudr/eudr.dto-processor.service.ts - About 1 hr to fix

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

                  async activateMaterials(
                    materialsFromSheet: CreateMaterialDto[],
                  ): Promise<Material[]> {
                    const hsCodeToActivateMaterialsBy: string[] = materialsFromSheet
                      .filter((i: CreateMaterialDto) => i.status === MATERIALS_STATUS.ACTIVE)
                Severity: Minor
                Found in api/src/modules/materials/materials.service.ts - About 1 hr to fix

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

                    private async createSourcingLocationDTOFromData(
                      sourcingLocationData: Record<string, any>,
                      sourcingLocationGroupId?: string,
                    ): Promise<CreateSourcingLocationDto> {
                      const sourcingLocationDto: CreateSourcingLocationDto =
                  Severity: Minor
                  Found in api/src/modules/import-data/sourcing-data/dto-processor.service.ts - About 1 hr to fix

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

                      const renderTooltip = useCallback((props) => {
                        if (props && props.active && props.payload && props.payload.length) {
                          return <CustomTooltip {...props} />;
                        }
                      }, []);
                    client/src/containers/analysis-chart/impact-chart/component.tsx on lines 236..240

                    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

                      const renderTooltip = useCallback((props) => {
                        if (props && props.active && props.payload && props.payload.length) {
                          return <CustomTooltip {...props} />;
                        }
                      }, []);
                    client/src/containers/analysis-chart/comparison-chart/component.tsx on lines 151..155

                    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

                      it('unknown => city, address, coordinates is not required', () => {
                        cy.get('[data-testid="select-newLocationType"]')
                          .click()
                          .find('input:visible')
                          .type('Unknown{enter}');
                    Severity: Major
                    Found in client/cypress/e2e/intervention-creation.cy.ts and 1 other location - About 1 hr to fix
                    client/cypress/e2e/intervention-creation.cy.ts on lines 210..217

                    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

                      it('country of production => city, address, coordinates is not required', () => {
                        cy.get('[data-testid="select-newLocationType"]')
                          .click()
                          .find('input:visible')
                          .type('Country of production{enter}');
                    Severity: Major
                    Found in client/cypress/e2e/intervention-creation.cy.ts and 1 other location - About 1 hr to fix
                    client/cypress/e2e/intervention-creation.cy.ts on lines 289..296

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language