Vizzuality/landgriffon

View on GitHub
client/src/containers/analysis-eudr/map/component.tsx

Summary

Maintainability
F
1 wk
Test Coverage

Function EUDRMap has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

const EUDRMap: React.FC<{ supplierId?: string }> = ({ supplierId }) => {
  const {
    planetLayer,
    supplierLayer,
    contextualLayers,
Severity: Minor
Found in client/src/containers/analysis-eudr/map/component.tsx - About 1 day 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

File component.tsx has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { useState, useCallback, useEffect, useMemo } from 'react';
import DeckGL from '@deck.gl/react/typed';
import { GeoJsonLayer } from '@deck.gl/layers/typed';
import Map, { Source, Layer } from 'react-map-gl/maplibre';
import { WebMercatorViewport } from '@deck.gl/core/typed';
Severity: Minor
Found in client/src/containers/analysis-eudr/map/component.tsx - About 3 hrs to fix

    Function eudrSupplierLayer has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const eudrSupplierLayer = useMemo(() => {
        if (!filteredGeometries?.features || !data) return null;
    
        return new GeoJsonLayer<(typeof filteredGeometries)['features'][number]>({
          id: 'full-plots-layer',
    Severity: Minor
    Found in client/src/containers/analysis-eudr/map/component.tsx - About 1 hr to fix

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

        const { data } = useEUDRData(
          {
            startAlertDate: dates.from,
            endAlertDate: dates.to,
            producerIds: suppliers?.map(({ value }) => value),
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 2 days to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 55..93

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

      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 eudrSupplierLayer = useMemo(() => {
          if (!filteredGeometries?.features || !data) return null;
      
          return new GeoJsonLayer<(typeof filteredGeometries)['features'][number]>({
            id: 'full-plots-layer',
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 2 days to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 121..163

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

      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

            {hoverInfo?.object && (
              <div
                className="pointer-events-none absolute z-10 max-w-32 rounded-md bg-white p-2 text-2xs shadow-md"
                style={{
                  left: hoverInfo?.x + 10,
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 1 day to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 331..356

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

      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 raddLayer = new CartoLayer({
          id: 'real-time-deforestation-alerts-since-2020-radd',
          type: MAP_TYPES.QUERY,
          connection: 'eudr',
          data: 'SELECT * FROM `cartobq.eudr.RADD_date_confidence_3` WHERE date BETWEEN ? AND ?',
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 7 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 200..223

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

      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

              <DeckGL
                id="anotherDeckMap"
                viewState={{ ...viewState }}
                onViewStateChange={({ viewState }) => {
                  viewState.longitude = Math.min(
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 6 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 268..329

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

      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 deforestationLayer = new CartoLayer({
          id: 'full-deforestation-alerts-2020-2022-hansen',
          type: MAP_TYPES.QUERY,
          connection: 'eudr',
          data: 'SELECT * FROM `cartobq.eudr.TCL_hansen_year` WHERE year<=?',
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 4 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 182..198

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

      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 plotGeometries = usePlotGeometries({
          producerIds: params?.supplierId
            ? [params.supplierId as string]
            : suppliers?.map(({ value }) => value),
          materialIds: materials?.map(({ value }) => value),
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 4 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 95..102

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

      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

            features: plotGeometries.data.features?.filter((feature) => {
              if (Object.values(tableFilters).every((filter) => !filter)) return true;
      
              if (tableFilters.dfs && data.dfs.indexOf(feature.properties.id) > -1) return true;
              if (tableFilters.sda && data.sda.indexOf(feature.properties.id) > -1) return true;
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 4 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 111..117

      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

        const forestCoverLayer = new CartoLayer({
          id: 'full-forest-cover-2020-ec-jrc',
          type: MAP_TYPES.TILESET,
          connection: 'eudr',
          data: 'cartobq.eudr.JRC_2020_Forest_d_TILE',
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 3 hrs to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 165..180

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

      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

        const handleZoomIn = useCallback(() => {
          const zoom = viewState.maxZoom === viewState.zoom ? viewState.zoom : viewState.zoom + 1;
          setViewState({ ...viewState, zoom });
        }, [viewState]);
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 3 other locations - About 1 hr to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 225..228
      client/src/containers/analysis-eudr/map/compare.tsx on lines 230..233
      client/src/containers/analysis-eudr/map/component.tsx on lines 225..228

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

      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

        const handleZoomOut = useCallback(() => {
          const zoom = viewState.maxZoom === viewState.zoom ? viewState.zoom : viewState.zoom - 1;
          setViewState({ ...viewState, zoom });
        }, [viewState]);
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 3 other locations - About 1 hr to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 225..228
      client/src/containers/analysis-eudr/map/compare.tsx on lines 230..233
      client/src/containers/analysis-eudr/map/component.tsx on lines 220..223

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

      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

            <div className="absolute bottom-10 right-6 z-10 w-10 space-y-2">
              <BasemapControl />
              <ZoomControl viewState={viewState} onZoomIn={handleZoomIn} onZoomOut={handleZoomOut} />
              <LegendControl />
            </div>
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 1 hr to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 357..361

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

      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 newViewState = newViewport.fitBounds(
              [
                [dataBounds[0], dataBounds[1]],
                [dataBounds[2], dataBounds[3]],
              ],
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 35 mins to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 242..250

      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 DEFAULT_VIEW_STATE: MapViewState = {
        ...INITIAL_VIEW_STATE,
        latitude: -8.461844239054608,
        longitude: -74.96226240479487,
        zoom: 9,
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/component.tsx and 1 other location - About 35 mins to fix
      client/src/containers/analysis-eudr/map/compare.tsx on lines 29..36

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

      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