Vizzuality/landgriffon

View on GitHub
api/src/modules/h3-data/h3-data.repository.ts

Summary

Maintainability
F
1 wk
Test Coverage
A
95%

File h3-data.repository.ts has 679 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  Brackets,
  DataSource,
  ObjectLiteral,
  Repository,
Severity: Major
Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 day to fix

    Function baseGetImpactMap has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private async baseGetImpactMap(
        baseImpactMap: BaseImpactMap,
      ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
        let baseMapQuery: SelectQueryBuilder<any> = this.baseMapQuery(
          baseImpactMap.indicatorId,
    Severity: Major
    Found in api/src/modules/h3-data/h3-data.repository.ts - About 2 hrs to fix

      H3DataRepository has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Injectable()
      export class H3DataRepository extends Repository<H3Data> {
        constructor(private dataSource: DataSource) {
          super(H3Data, dataSource.createEntityManager());
        }
      Severity: Minor
      Found in api/src/modules/h3-data/h3-data.repository.ts - About 2 hrs to fix

        Function baseGetImpactMap has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          private async baseGetImpactMap(
            baseImpactMap: BaseImpactMap,
          ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
            let baseMapQuery: SelectQueryBuilder<any> = this.baseMapQuery(
              baseImpactMap.indicatorId,
        Severity: Minor
        Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr 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 getActualVsScenarioImpactMap has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async getActualVsScenarioImpactMap(
            dto: GetActualVsScenarioImpactMapDto,
          ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
            const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
              //Add selection criteria to also select both comparedScenario in the select statement
        Severity: Minor
        Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

          Function getImpactMap has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async getImpactMap(
              dto: GetImpactMapDto,
            ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
              const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
                //Having a scenarioId present as an argument, will change the query to include
          Severity: Minor
          Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

            Function getScenarioVsScenarioImpactMap has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async getScenarioVsScenarioImpactMap(
                dto: GetScenarioVsScenarioImpactMapDto,
              ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
                const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
                  //Add selection criteria to also select both baseScenario and comparedScenario in the select statement
            Severity: Minor
            Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                private addOrganisationalEntityFilters(
                  baseImpactMapFilters: BaseImpactMapFiltersType,
                  queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
                ): SelectQueryBuilder<any> {
                  const {
              Severity: Minor
              Found in api/src/modules/h3-data/h3-data.repository.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 calculateScenarioComparisonQuantiles has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private async calculateScenarioComparisonQuantiles(
                      tmpTableName: string,
                    ): Promise<number[]> {
                      try {
                        // due to the inner workings of the pg driver and the way it parses different number types
                  Severity: Minor
                  Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

                    Function getMaterialMapByResolution has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async getMaterialMapByResolution(
                        materialH3Data: H3Data,
                        resolution: number,
                      ): Promise<{ materialMap: H3IndexValueData[]; quantiles: number[] }> {
                        const tmpTableName: string = H3DataRepository.generateRandomTableName();
                    Severity: Minor
                    Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                        async getAvailableYearsForContextualLayer(yearsRequestParams: {
                          layerType: LAYER_TYPES;
                          h3DataIds?: string[] | null;
                          indicatorId?: string;
                        }): Promise<number[]> {
                      Severity: Minor
                      Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                          async getYears(yearsRequestParams: {
                            layerType: LAYER_TYPES;
                            h3DataIds?: string[] | null;
                            indicatorId?: string;
                          }): Promise<number[]> {
                        Severity: Minor
                        Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                              const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
                                //Add selection criteria to also select both comparedScenario in the select statement
                                baseQuery
                                  .leftJoin(
                                    ScenarioIntervention,
                          Severity: Minor
                          Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

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

                                const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
                                  //Having a scenarioId present as an argument, will change the query to include
                                  // *all* indicator records of the interventions pertaining to that scenario (both
                                  // the CANCELLED and REPLACING records)
                                  if (dto.scenarioId) {
                            Severity: Minor
                            Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

                              Function addOrganisationalEntityFilters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                private addOrganisationalEntityFilters(
                                  baseImpactMapFilters: BaseImpactMapFiltersType,
                                  queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
                                ): SelectQueryBuilder<any> {
                                  const {
                              Severity: Minor
                              Found in api/src/modules/h3-data/h3-data.repository.ts - About 25 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

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

                                async getAvailableYearsForContextualLayer(yearsRequestParams: {
                                  layerType: LAYER_TYPES;
                                  h3DataIds?: string[] | null;
                                  indicatorId?: string;
                                }): Promise<number[]> {
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 day to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 270..307

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

                              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 getYears(yearsRequestParams: {
                                  layerType: LAYER_TYPES;
                                  h3DataIds?: string[] | null;
                                  indicatorId?: string;
                                }): Promise<number[]> {
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 day to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 130..167

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

                              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 (dto.scenarioId) {
                                      baseQuery
                                        .leftJoin(
                                          ScenarioIntervention,
                                          'si',
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 4 hrs to fix
                              api/src/modules/impact/impact.repository.ts on lines 309..334

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

                              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 this.baseGetImpactMap({
                                    indicatorId: dto.indicatorId,
                                    resolution: dto.resolution,
                                    year: dto.year,
                                    mapType: IMPACT_MAP_TYPE.SCENARIO_VS_SCENARIO,
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 4 hrs to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 441..455

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

                              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 this.baseGetImpactMap({
                                    indicatorId: dto.indicatorId,
                                    resolution: dto.resolution,
                                    year: dto.year,
                                    mapType: IMPACT_MAP_TYPE.ACTUAL_VS_SCENARIO,
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 4 hrs to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 496..510

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

                              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 queryBuilder: SelectQueryBuilder<H3Data> = this.dataSource
                                    .createQueryBuilder()
                                    .select(' h3data.*')
                                    .from(H3Data, 'h3data')
                                    .leftJoin('indicator', 'indicator', 'h3data.indicatorId = indicator.id')
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 hr to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 207..219

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

                                  const queryBuilder: SelectQueryBuilder<H3Data> = this.dataSource
                                    .createQueryBuilder()
                                    .select('h3data.*')
                                    .from(H3Data, 'h3data')
                                    .leftJoin(
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 hr to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 236..242

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

                                    if (baseImpactMap.mapType === IMPACT_MAP_TYPE.SCENARIO_VS_SCENARIO) {
                                      if (baseImpactMap.isRelative) {
                                        finalQueryBuiler.select(
                                          '100 * (ABS(q.aggregated_compared) - ABS(q.aggregated_base)) / NULLIF(((ABS(q.aggregated_compared) + ABS(q.aggregated_base)) / 2), 0)',
                                          'v',
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 hr to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 547..559

                              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

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

                                    if (baseImpactMap.mapType === IMPACT_MAP_TYPE.ACTUAL_VS_SCENARIO) {
                                      if (baseImpactMap.isRelative) {
                                        finalQueryBuiler.select(
                                          '100 * (ABS(q.aggregated_scenario_data) - ABS(q.aggregated_actual_data)) / NULLIF(((ABS(q.aggregated_scenario_data) + ABS(q.aggregated_actual_data)) / 2), 0)',
                                          'v',
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 hr to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 560..572

                              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

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

                                    {
                                      materialIds: baseImpactMap.materialIds,
                                      originIds: baseImpactMap.originIds,
                                      t1SupplierIds: baseImpactMap.t1SupplierIds,
                                      producerIds: baseImpactMap.producerIds,
                              Severity: Major
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 1 hr to fix
                              api/src/modules/scenario-interventions/scenario-interventions.service.ts on lines 366..373

                              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

                                  const years: { year: number }[] = await this.createQueryBuilder('h3data')
                                    .select('year')
                                    .leftJoin('material_to_h3', 'mth', 'h3data.id = mth.h3DataId')
                                    .where('mth.materialId = :materialId', { materialId })
                                    .andWhere('mth.type = :materialType', { materialType })
                              Severity: Minor
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 35 mins to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 186..190

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

                              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 years: { year: number }[] = await this.createQueryBuilder('h3data')
                                    .select('year')
                                    .leftJoin('indicator', 'i', 'h3data.indicatorId = i.id')
                                    .where('h3data.indicatorId = :indicatorId', { indicatorId })
                                    .orderBy('year', 'DESC')
                              Severity: Minor
                              Found in api/src/modules/h3-data/h3-data.repository.ts and 1 other location - About 35 mins to fix
                              api/src/modules/h3-data/h3-data.repository.ts on lines 173..177

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

                              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