HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

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

    if (hasMoreDormantSessions) {
      const newOffset = offset + listSessions.length;
      updateOffset(newOffset);

      const updatedFilters = {
Severity: Major
Found in app/javascript/react/utils/scrollEnd.ts and 1 other location - About 4 hrs to fix
app/javascript/react/utils/scrollEnd.ts on lines 24..45

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

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

const addNavigationArrows = (
  chart: Highcharts.Chart,
  isCalendarPage: boolean,
  isMobile: boolean
) => {
Severity: Major
Found in app/javascript/react/components/Graph/chartEvents.ts - About 4 hrs to fix

    Function ThresholdSlider has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    const ThresholdSlider: React.FC<ThresholdSliderProps> = ({
      isMobileOldStyle,
      useColorBoxStyle,
      setErrorMessage,
    }) => {

    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

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

    describe CrowdmapAverages::ForMobile do
      it 'returns average from requested time range when no session_ids provided' do
        user = create_user!(username: 'name')
        session1 = create_session!(id: 1, user: user)
        stream = create_stream!(session: session1)
    Severity: Major
    Found in spec/services/crowdmap_averages_spec.rb and 1 other location - About 4 hrs to fix
    spec/services/average_info_spec.rb on lines 35..83

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

    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

    describe CrowdmapAverages::ForMobile do
      it 'returns average from requested time range when no session_ids provided' do
        user = create_user!(username: 'name')
        session1 = create_session!(id: 1, user: user)
        stream = create_stream!(session: session1)
    Severity: Major
    Found in spec/services/average_info_spec.rb and 1 other location - About 4 hrs to fix
    spec/services/crowdmap_averages_spec.rb on lines 35..83

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

    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

              <S.ToggleWrapper onClick={handleToggleClick}>
                <Toggle
                  isChecked={isCrowdMapActive}
                  onChange={handleToggleClick}
                  variant="toggle"
    app/javascript/react/components/SessionFilters/DormantToggle.tsx on lines 66..80

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

    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

              <S.ToggleWrapper onClick={handleToggleClick}>
                <Toggle
                  isChecked={isDormant}
                  onChange={handleToggleClick}
                  variant="toggle"
    app/javascript/react/components/SessionFilters/CrowdmapToggle.tsx on lines 94..108

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

    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

          {decodedTagsArray && decodedTagsArray.length > 0 && (
            <S.SelectedItemsWrapper>
              {decodedTagsArray.map((item, index) => (
                <S.SelectedItemTile key={index}>
                  <S.SelectedItem>{item}</S.SelectedItem>
    Severity: Major
    Found in app/javascript/react/components/SessionFilters/TagsInput.tsx and 1 other location - About 4 hrs to fix
    app/javascript/react/components/SessionFilters/ProfileNamesInput.tsx on lines 145..154

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

    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

          {decodedUsernamesArray && decodedUsernamesArray.length > 0 && (
            <S.SelectedItemsWrapper>
              {decodedUsernamesArray.map((item, index) => (
                <S.SelectedItemTile key={index}>
                  <S.SelectedItem>{item}</S.SelectedItem>
    app/javascript/react/components/SessionFilters/TagsInput.tsx on lines 143..152

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

    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

      try {
        const response: AxiosResponse<Sensor[]> = await oldApiClient.get(
          API_ENDPOINTS.fetchSensors(sessionTypeCapitalized)
        );
        return response.data;
    Severity: Major
    Found in app/javascript/react/store/sensorsSlice.ts and 1 other location - About 4 hrs to fix
    app/javascript/react/store/crowdMapSlice.ts on lines 37..56

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

    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

      try {
        const response: AxiosResponse<RectangleData[]> = await oldApiClient.get(
          API_ENDPOINTS.fetchCrowdMap(filters)
        );
        return response.data;
    Severity: Major
    Found in app/javascript/react/store/crowdMapSlice.ts and 1 other location - About 4 hrs to fix
    app/javascript/react/store/sensorsSlice.ts on lines 36..55

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

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

    export const createMarkerIcon = (
      color: string,
      value: string,
      isSelected: boolean = false,
      shouldPulse: boolean
    Severity: Major
    Found in app/javascript/react/components/Map/Markers/createMarkerIcon.ts - About 4 hrs to fix

      File TimelapseComponent.style.tsx has 359 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import Popup from "reactjs-popup";
      import styled from "styled-components";
      
      import {
        acBlue,

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

          } else {
            return [
              { url: assets.clusterTheme1Level1Path, anchor: new google.maps.Point(15, 15) },
              { url: assets.clusterTheme1Level2Path, anchor: new google.maps.Point(15, 15) },
              { url: assets.clusterTheme1Level3Path, anchor: new google.maps.Point(15, 15) },
        Severity: Major
        Found in app/javascript/javascript/theme.js and 1 other location - About 4 hrs to fix
        app/javascript/javascript/theme.js on lines 35..42

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

        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 (getParams().theme === BLUE_THEME) {
            return [
              { url: assets.clusterTheme2Level1Path, anchor: new google.maps.Point(15, 15) },
              { url: assets.clusterTheme2Level2Path, anchor: new google.maps.Point(15, 15) },
              { url: assets.clusterTheme2Level3Path, anchor: new google.maps.Point(15, 15) },
        Severity: Major
        Found in app/javascript/javascript/theme.js and 1 other location - About 4 hrs to fix
        app/javascript/javascript/theme.js on lines 42..49

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

        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 getQueryParams = (tags: string): ParamsType => {
            return {
              tags: tags,
              west: boundWest.toString(),
              east: boundEast.toString(),
        Severity: Major
        Found in app/javascript/react/components/SessionFilters/TagsInput.tsx and 1 other location - About 4 hrs to fix
        app/javascript/react/components/SessionFilters/ProfileNamesInput.tsx on lines 51..67

        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

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

          const getQueryParams = (usernames: string): ParamsType => {
            return {
              tags: tagsDecoded,
              west: boundWest.toString(),
              east: boundEast.toString(),
        app/javascript/react/components/SessionFilters/TagsInput.tsx on lines 50..66

        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

        Function addNavigationArrows has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

        const addNavigationArrows = (
          chart: Highcharts.Chart,
          isCalendarPage: boolean,
          isMobile: boolean
        ) => {
        Severity: Minor
        Found in app/javascript/react/components/Graph/chartEvents.ts - About 4 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 MobileSessionFilters has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

        const MobileSessionFilters = ({
          onClose,
          fetchableSessionsCount,
        }: MobileSessionFiltersProps) => {
          const indoorSessionsState = useAppSelector(selectIndoorSessionsState);

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

              case "high":
                if (
                  currentValue <= thresholdValues.middle &&
                  thresholdValues.middle !== thresholdValues.min
                ) {
        Severity: Major
        Found in app/javascript/react/utils/thresholdGestureHandlers.ts and 2 other locations - About 4 hrs to fix
        app/javascript/react/utils/thresholdGestureHandlers.ts on lines 48..64
        app/javascript/react/utils/thresholdGestureHandlers.ts on lines 65..78

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

        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

        Severity
        Category
        Status
        Source
        Language