Vizzuality/landgriffon

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

Summary

Maintainability
F
1 wk
Test Coverage

Function EUDRBasemapControl has 280 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const EUDRBasemapControl = () => {
  const currentDate = useMemo(() => new Date(), []);
  const dispatch = useAppDispatch();
  const { basemap, planetLayer, planetCompareLayer } = useAppSelector((state) => state.eudr);
  const basemapData = LayersData.find((layer) => layer.id === 'planet-data');
Severity: Major
Found in client/src/containers/analysis-eudr/map/basemap/component.tsx - About 1 day to fix

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

    import { useCallback, useEffect, useMemo } from 'react';
    import Image from 'next/image';
    import { format } from 'date-fns';
    
    import LayersData from '../layers.json';
    Severity: Minor
    Found in client/src/containers/analysis-eudr/map/basemap/component.tsx - About 3 hrs to fix

      Function EUDRBasemapControl has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      const EUDRBasemapControl = () => {
        const currentDate = useMemo(() => new Date(), []);
        const dispatch = useAppDispatch();
        const { basemap, planetLayer, planetCompareLayer } = useAppSelector((state) => state.eudr);
        const basemapData = LayersData.find((layer) => layer.id === 'planet-data');
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx - 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

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

                  <div className="flex items-start space-x-2 p-4">
                    <div className="aspect-square shrink-0 cursor-pointer rounded-lg border border-white bg-white shadow-lg transition-colors duration-200 ease-in-out hover:border-navy-400 hover:bg-green-50">
                      <div className="pointer-events-none h-full w-full p-px">
                        <div className="h-full w-full overflow-hidden rounded-md">
                          <Image width={40} height={40} src={SatelliteImage} alt="Change of basemap" />
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx and 1 other location - About 4 days to fix
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 236..314

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

      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

                  <div className="flex items-start space-x-2">
                    <div className="aspect-square shrink-0 cursor-pointer rounded-lg border border-white bg-white shadow-lg transition-colors duration-200 ease-in-out hover:border-navy-400 hover:bg-green-50">
                      <div className="pointer-events-none h-full w-full p-px">
                        <div className="h-full w-full overflow-hidden rounded-md">
                          <Image width={40} height={40} src={SatelliteImage} alt="Change of basemap" />
      Severity: Major
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx and 1 other location - About 4 days to fix
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 154..229

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

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

        const handlePlanetCompareLayerYear = useCallback(
          (year: string) => {
            dispatch(setPlanetCompareLayer({ year: Number(year) }));
          },
          [dispatch],
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx and 2 other locations - About 30 mins to fix
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 69..74
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 83..88

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

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

        const handlePlanetCompareLayerMonth = useCallback(
          (month: string) => {
            dispatch(setPlanetCompareLayer({ month: Number(month) }));
          },
          [dispatch],
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx and 2 other locations - About 30 mins to fix
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 69..74
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 76..81

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

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

        const handlePlanetLayerMonth = useCallback(
          (month: string) => {
            dispatch(setPlanetLayer({ month: Number(month) }));
          },
          [dispatch],
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/basemap/component.tsx and 2 other locations - About 30 mins to fix
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 76..81
      client/src/containers/analysis-eudr/map/basemap/component.tsx on lines 83..88

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

      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