Vizzuality/landgriffon

View on GitHub

Showing 438 of 1,408 total issues

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

      public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`
        CREATE OR REPLACE FUNCTION get_h3_material_table_column(h3DataId uuid)
        RETURNS TABLE (h3_table_name varchar, h3_column_name varchar) AS
        $$

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

        async extendFindAllQuery(
          query: SelectQueryBuilder<SourcingLocation>,
          fetchSpecification: Record<string, unknown>,
        ): Promise<SelectQueryBuilder<SourcingLocation>> {
          const sortingOrder: 'DESC' | 'ASC' | undefined =

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

            async getAggregatedH3ByNameAndResolution(
              h3TableName: string,
              h3ColumnName: string,
              resolution: number,
              aggregationType: CONTEXTUAL_LAYER_AGG_TYPE,
          Severity: Minor
          Found in api/src/modules/contextual-layers/contextual-layer.repository.ts - About 1 hr to fix

            Function activateIndicators has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async activateIndicators(
                indicatorsFromSheet: CreateIndicatorDto[],
              ): Promise<Indicator[]> {
                const nameCodesToActivateIndicatorsBy: string[] = indicatorsFromSheet
                  .filter((i: CreateIndicatorDto) => i.status === INDICATOR_STATUS.ACTIVE)
            Severity: Minor
            Found in api/src/modules/indicators/indicators.service.ts - About 1 hr to fix

              Function getScenarioVsScenarioImpactTable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async getScenarioVsScenarioImpactTable(
                  dto: GetScenarioVsScenarioImpactTableDto,
                  fetchSpecification: FetchSpecification,
                ): Promise<ScenarioVsScenarioPaginatedImpactTable> {
                  const indicators: Indicator[] =
              Severity: Minor
              Found in api/src/modules/impact/comparison/scenario-vs-scenario.service.ts - About 1 hr to fix

                Function buildQuery has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  buildQuery(): Query {
                    if (this.dto?.supplierIds) {
                      this.queryBuilder.andWhere(
                        `${EUDRAlertsFields.supplierId} IN (:...supplierIds)`,
                        {

                  Function getContextualLayerH3 has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async getContextualLayerH3(
                      contextualLayerId: string,
                      resolution?: number,
                      year?: number,
                    ): Promise<{
                  Severity: Minor
                  Found in api/src/modules/contextual-layers/contextual-layers.service.ts - About 1 hr to fix

                    Function getFlowLineAttributesByIndex has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function getFlowLineAttributesByIndex(
                      lineAttributes: FlowLinesLayerAttributes,
                      index: number,
                    ): FlowLinesLayerAttributes {
                      const {
                    Severity: Minor
                    Found in cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.ts - About 1 hr to fix

                      Function getColors has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function getColors(
                        diffMode: boolean,
                        schemeKey: string | undefined,
                        darkMode: boolean,
                        fadeEnabled: boolean,
                      Severity: Minor
                      Found in cookie-traceability/src/lib/flowmap/data/colors.ts - About 1 hr to fix

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

                        const CreateInterventionPage: React.FC = () => {
                          const { query } = useRouter();
                          const createIntervention = useCreateNewIntervention({
                            onSuccess: (_data, variables) => {
                              toast.success(`Intervention was created successfully`);
                        Severity: Minor
                        Found in client/src/pages/data/scenarios/[scenarioId]/interventions/new.tsx - About 1 hr to fix

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

                          const ChartPage: NextPageWithLayout = () => {
                            const dispatch = useAppDispatch();
                            const [syncedIndicators] = useSyncIndicators();
                          
                            const { data, isLoading } = useIndicators(undefined, {
                          Severity: Minor
                          Found in client/src/pages/analysis/chart.tsx - About 1 hr to fix

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

                              async addReplacingElementsToIntervention(
                                newIntervention: ScenarioIntervention,
                                newSourcingLocations: SourcingData[],
                                type: SCENARIO_INTERVENTION_TYPE,
                              ): Promise<ScenarioIntervention> {

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

                                  private calculateIndicatorSumByYear(
                                    entityMap: Map<
                                      string,
                                      Map<number, ScenarioVsScenarioImpactTableRowsValues>
                                    >,
                                Severity: Minor
                                Found in api/src/modules/impact/comparison/scenario-vs-scenario.service.ts - About 1 hr to fix

                                  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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language