HabitatMap/AirCasting

View on GitHub
app/javascript/react/components/Map/Markers/FixedMarkers.tsx

Summary

Maintainability
F
1 wk
Test Coverage

File FixedMarkers.tsx has 629 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  Cluster,
  MarkerClusterer,
  SuperClusterAlgorithm,
} from "@googlemaps/markerclusterer";
Severity: Major
Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 1 day to fix

    Function FixedMarkers has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

    export function FixedMarkers({
      sessions,
      onMarkerClick,
      selectedStreamId,
      pulsatingSessionId,
    Severity: Minor
    Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 7 hrs 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 handleSelectedStreamId has 108 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const handleSelectedStreamId = (streamId: number | null) => {
          if (fixedStreamStatus === StatusEnum.Pending) return;
          if (streamId) {
            const { latitude, longitude } = fixedStreamData?.stream ?? {};
    
    
    Severity: Major
    Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 4 hrs to fix

      Function updateMarkerOverlays has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const updateMarkerOverlays = useCallback(() => {
          markerRefs.current.forEach((marker, streamId) => {
            const isSelected =
              marker.userData?.streamId === selectedStreamId?.toString();
            const shouldPulse =
      Severity: Major
      Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 2 hrs to fix

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

          const handleClusteringEnd = useCallback(() => {
            const currentZoom = map?.getZoom() ?? null;
        
            if (currentZoom === previousZoomRef.current) {
              return;
        Severity: Minor
        Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx - About 1 hr to fix

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

                  clusters.forEach((cluster) => {
                    if (cluster.markers && cluster.markers.length > 1) {
                      cluster.markers.forEach((marker) => {
                        (marker as CustomMarker).clustered = true;
                      });
          Severity: Major
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 1 day to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 159..188

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

          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

              clusters.forEach((cluster) => {
                if (cluster.markers && cluster.markers.length > 1) {
                  cluster.markers.forEach((marker) => {
                    (marker as CustomMarker).clustered = true;
                  });
          Severity: Major
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 1 day to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 460..489

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

          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

              memoizedSessions.forEach((session) => {
                let marker = markerRefs.current.get(session.point.streamId);
                if (!marker) {
                  marker = createMarker(session);
                  markerRefs.current.set(session.point.streamId, marker);
          Severity: Major
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 5 hrs to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 669..680

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

          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

                  memoizedSessions.forEach((session) => {
                    let marker = markerRefs.current.get(session.point.streamId);
                    if (!marker) {
                      marker = createMarker(session);
                      markerRefs.current.set(session.point.streamId, marker);
          Severity: Major
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 5 hrs to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 388..399

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

          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

            useEffect(() => {
              if (hoverStreamId) {
                const hoveredSession = memoizedSessions.find(
                  (session) => Number(session.point.streamId) === hoverStreamId
                );
          Severity: Major
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 2 hrs to fix
          app/javascript/react/components/Map/Markers/DormantMarkers.tsx on lines 167..178

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

          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

                    markerRefs.current.forEach((marker, streamIdKey) => {
                      if (streamIdKey !== streamId.toString()) {
                        marker.setMap(null);
                        markerRefs.current.delete(streamIdKey);
                      }
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 586..591
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 594..599

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

          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

                    labelOverlays.current.forEach((overlay, streamIdKey) => {
                      if (streamIdKey !== streamId.toString()) {
                        overlay.setMap(null);
                        labelOverlays.current.delete(streamIdKey);
                      }
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 578..583
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 586..591

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

          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

                    markerOverlays.current.forEach((overlay, streamIdKey) => {
                      if (streamIdKey !== streamId.toString()) {
                        overlay.setMap(null);
                        markerOverlays.current.delete(streamIdKey);
                      }
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 578..583
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 594..599

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

          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

            useEffect(() => {
              if (markerRefs.current.size >= memoizedSessions.length) {
                dispatch(setMarkersLoading(false));
              }
            }, [dispatch, sessions.length]);
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 55 mins to fix
          app/javascript/react/components/Map/Markers/DormantMarkers.tsx on lines 180..184

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

          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

                clustererRef.current = new MarkerClusterer({
                  map,
                  markers: [],
                  renderer: customRenderer,
                  algorithm: new SuperClusterAlgorithm({
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 50 mins to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 651..659

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

          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

                    clustererRef.current = new MarkerClusterer({
                      map,
                      markers: [],
                      renderer: customRenderer,
                      algorithm: new SuperClusterAlgorithm({
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 50 mins to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 526..534

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

          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 (!existingOverlay) {
                    const overlay = new CustomMarkerOverlay(
                      position!,
                      newColor,
                      isSelected,
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 35 mins to fix
          app/javascript/react/components/Map/Markers/MobileMarkers.tsx on lines 183..197

          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

                if (map) {
                  const pixelPosition = getClusterPixelPosition(map, cluster.position);
                  setClusterPosition({ top: pixelPosition.y, left: pixelPosition.x });
                }
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 35 mins to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 238..244

          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

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

              if (selectedCluster && map) {
                const pixelPosition = getClusterPixelPosition(
                  map,
                  selectedCluster.position
                );
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 35 mins to fix
          app/javascript/react/components/Map/Markers/FixedMarkers.tsx on lines 124..127

          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

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

                marker.addListener("click", () => {
                  onMarkerClick(Number(session.point.streamId), Number(session.id));
                  centerMapOnMarker(session.point);
                });
          Severity: Minor
          Found in app/javascript/react/components/Map/Markers/FixedMarkers.tsx and 1 other location - About 30 mins to fix
          app/javascript/react/components/Map/Markers/MobileMarkers.tsx on lines 133..136

          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