Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

Function prepareLayersData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  prepareLayersData(state: FlowMapState, props: FlowMapData<L, F>): LayersData {
    const locations = this.getLocationsForFlowMapLayer(state, props) || [];
    const flows = this.getFlowsForFlowMapLayer(state, props) || [];
    const { getFlowOriginId, getFlowDestId, getFlowMagnitude, getLocationId, getLocationCentroid } =
      this.accessors;
Severity: Minor
Found in cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.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 ModeControl has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ModeControl: React.FC = () => {
  const { visualizationMode } = useAppSelector(analysisUI);
  const { query } = useRouter();
  const [syncedIndicators] = useSyncIndicators();
  const { detail, ...restQuery } = query;
Severity: Minor
Found in client/src/containers/mode-control/component.tsx - About 1 hr to fix

    Function AdminDataUploader has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const AdminDataUploader: React.FC = () => {
      const { data: lastTask } = useLasTask();
    
      return (
        <div className="flex h-full w-full items-center justify-center">
    Severity: Minor
    Found in client/src/containers/admin/data-uploader/index.tsx - About 1 hr to fix

      Function saveChunks has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async saveChunks<IndicatorRecord>(
          entities: IndicatorRecord[],
          options?: SaveOptions,
        ): Promise<IndicatorRecord[]> {
          const queryRunner: QueryRunner = this.dataSource.createQueryRunner();
      Severity: Minor
      Found in api/src/modules/indicator-records/indicator-record.repository.ts - About 1 hr to fix

        Function generateNewSourcingLocation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          generateNewSourcingLocation(
            dto: CreateScenarioInterventionDto,
            sourcingData: SourcingLocation[],
            locationData: {
              adminRegionId: string;

          Function getImpactMapByResolution has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async getImpactMapByResolution(
              getImpactMapDto:
                | GetImpactMapDto
                | GetActualVsScenarioImpactMapDto
                | GetScenarioVsScenarioImpactMapDto,
          Severity: Minor
          Found in api/src/modules/h3-data/h3-data-map.service.ts - About 1 hr to fix

            Function aggregateAndCalculatePercentage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const aggregateAndCalculatePercentage = (
              records: any[],
            ): AggregatedVoumeAndPlotByYear[] => {
              const withGeoRegion: VolumeAndPlotByYear[] = records.filter(
                (record: VolumeAndPlotByYear) => record.geoRegionId !== null,
            Severity: Minor
            Found in api/src/modules/eudr-alerts/dashboard/dashboard-utils.ts - About 1 hr to fix

              Function validateCleanData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private async validateCleanData(nonEmptyData: SourcingData[]): Promise<void> {
                  const excelErrors: {
                    line: number;
                    column: string;
                    errors: { [type: string]: string } | undefined;
              Severity: Minor
              Found in api/src/modules/import-data/eudr/eudr.dto-processor.service.ts - About 1 hr to fix

                Function relateSourcingDataWithOrganizationalEntities has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async relateSourcingDataWithOrganizationalEntities(
                    suppliers: Supplier[],
                    businessUnits: Record<string, any>[],
                    materials: Material[],
                    sourcingData: SourcingData[],

                  Function getFlowAndCircleColors has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function getFlowAndCircleColors(
                    inputColors: FlowAndCircleColors | undefined,
                    defaultFlowColorScheme: string[],
                    darkMode: boolean,
                  ): FlowAndCircleColorsRGBA {
                  Severity: Minor
                  Found in cookie-traceability/src/lib/flowmap/data/colors.ts - About 1 hr to fix

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

                      @ApiProperty({
                        description: `The sort order for the resulting entities. Can be 'ASC' (Ascendant) or 'DES' (Descendent), with the default being 'DES'`,
                      })
                      @Type(() => String)
                      @IsString()
                    Severity: Major
                    Found in api/src/modules/impact/dto/impact-table.dto.ts and 1 other location - About 1 hr to fix
                    api/src/modules/suppliers/dto/get-supplier-by-type.dto.ts on lines 28..37

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

                    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

                      @ApiProperty({
                        description: `The sort order by Name for the resulting entities. Can be 'ASC' (Ascendant) or 'DESC' (Descendent). Defaults to ASC`,
                      })
                      @Type(() => String)
                      @IsString()
                    Severity: Major
                    Found in api/src/modules/suppliers/dto/get-supplier-by-type.dto.ts and 1 other location - About 1 hr to fix
                    api/src/modules/impact/dto/impact-table.dto.ts on lines 223..232

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

                    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

                                <Button
                                  variant="ghost"
                                  type="button"
                                  className={cn(
                                    'h-[22px] rounded-none rounded-bl-md rounded-tl-md border border-gray-300 text-gray-300',
                    client/src/containers/analysis-eudr-detail/sourcing-info/chart/index.tsx on lines 114..128

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

                    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

                                <Button
                                  variant="ghost"
                                  type="button"
                                  className={cn(
                                    'h-[22px] rounded-none rounded-br-md rounded-tr-md border border-gray-300 text-gray-300',
                    client/src/containers/analysis-eudr-detail/sourcing-info/chart/index.tsx on lines 99..113

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

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

                      const chartData = useMemo<ChartData>(() => {
                        const { indicatorShortName, yearSum, metadata } = data?.data?.impactTable?.[0] || {};
                        const nonProjectedData = (yearSum?.filter(({ isProjected }) => !isProjected) || []).sort(
                          ({ year }) => year,
                        );
                    Severity: Minor
                    Found in client/src/containers/analysis-chart/comparison-chart/component.tsx - About 1 hr to fix

                      Function getScenarioInterventionsByScenarioId has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async getScenarioInterventionsByScenarioId(
                          scenarioId: string,
                        ): Promise<ScenarioIntervention[]> {
                          // TODO: Join with suppliers and selecting supplier field commented out due to performance issues
                          //       This needs to be restored

                        Function calculateIndicatorSumByYear has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private calculateIndicatorSumByYear(
                            entityMap: Map<string, Map<number, ActualVsScenarioImpactTableRowsValues>>,
                            rangeOfYears: number[],
                            lastYearWithData: number,
                          ): ActualVsScenarioIndicatorSumByYear[] {
                        Severity: Minor
                        Found in api/src/modules/impact/comparison/actual-vs-scenario.service.ts - About 1 hr to fix

                          Function saveChunks has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async saveChunks(
                              entities: SourcingLocation[],
                              options?: SaveOptions,
                            ): Promise<SourcingLocation[]> {
                              const queryRunner: QueryRunner = this.dataSource.createQueryRunner();
                          Severity: Minor
                          Found in api/src/modules/sourcing-locations/sourcing-location.repository.ts - About 1 hr to fix

                            Function Hero has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const Hero: React.FC = () => {
                              return (
                                <section className="relative z-10 bg-white">
                                  <Wrapper>
                                    <motion.div
                            Severity: Minor
                            Found in marketing/src/containers/the-service/hero/component.tsx - About 1 hr to fix

                              Function FAQs has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const FAQs: React.FC = () => {
                                return (
                                  <section className="bg-white">
                                    <div className="relative z-10">
                                      <Wrapper>
                              Severity: Minor
                              Found in marketing/src/containers/faqs/component.tsx - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language