HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

Method perform has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    alerts = ThresholdAlert.all
    Sidekiq.logger.info "[TRSHLD] #{alerts.count} alerts found: #{alerts.inspect}"

    alerts.each do |alert|
Severity: Minor
Found in app/workers/threshold_alerts_worker.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function StreamMarkers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

const StreamMarkers = ({ sessions, unitSymbol }: Props) => {
  const dispatch = useAppDispatch();
  const map = useMap();
  const markersRef = useRef<Map<string, CustomMarker>>(new Map());
  const thresholds = useSelector(selectThresholds);
Severity: Minor
Found in app/javascript/react/components/Map/Markers/StreamMarkers.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

Function ControlPanel has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

const ControlPanel: React.FC = () => {
  const { mapTypeId, searchParams } = useMapParams();
  const navigate = useNavigate();
  const isFirstRender = useRef(true);
  const { t } = useTranslation();
Severity: Minor
Found in app/javascript/react/components/Map/ControlPanel/ControlPanel.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

Function SessionsListView has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

const SessionsListView: React.FC<SessionsListViewProps> = ({
  sessions,
  onCellClick,
  onCellMouseEnter,
  onCellMouseLeave,

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

    def index
      GoogleAnalyticsWorker::RegisterEvent.async_call('Mobile sessions#index')
      q = ActiveSupport::JSON.decode(params.to_unsafe_hash[:q]).symbolize_keys
      q[:time_from] = Time.strptime(q[:time_from].to_s, '%s')
      q[:time_to] = Time.strptime(q[:time_to].to_s, '%s')
Severity: Major
Found in app/controllers/api/mobile/sessions_controller.rb and 1 other location - About 1 hr to fix
app/controllers/api/fixed/dormant/sessions_controller.rb on lines 7..29

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

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

        def index
          GoogleAnalyticsWorker::RegisterEvent.async_call(
            'Fixed dormant sessions#index'
          )
          q =
Severity: Major
Found in app/controllers/api/fixed/dormant/sessions_controller.rb and 1 other location - About 1 hr to fix
app/controllers/api/mobile/sessions_controller.rb on lines 5..23

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

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 ThresholdContainer = styled.div<{ $isMobile: boolean }>`
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
app/javascript/react/pages/CalendarPage/CalendarPage.style.tsx on lines 126..145

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

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 {
      usernames,
      tags,
      west,
      east,
Severity: Major
Found in app/javascript/react/api/apiEndpoints.ts and 1 other location - About 1 hr to fix
app/javascript/react/api/apiEndpoints.ts on lines 118..132

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

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 {
      tags,
      west,
      east,
      south,
Severity: Major
Found in app/javascript/react/api/apiEndpoints.ts and 1 other location - About 1 hr to fix
app/javascript/react/api/apiEndpoints.ts on lines 54..68

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

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 GraphContainer = styled.div<{ $isMobile: boolean }>`
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
app/javascript/react/pages/CalendarPage/CalendarPage.style.tsx on lines 71..89

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

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

    calculateChosenLabel: function () {
      var customRange = true;
      var i = 0;
      for (var range in this.ranges) {
        if (this.timePicker) {
Severity: Minor
Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

    Function IndoorOutdoorSwitch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const IndoorOutdoorSwitch = () => {
      const { t } = useTranslation();
      const { isIndoor, updateIndoorFilters, setFilter } = useMapParams();
      const dispatch = useAppDispatch();
    
    

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

        const handleLabelsChange = (isChecked: boolean) => {
          const newMapTypeId = isChecked ? MapTypeId.HYBRID : MapTypeId.SATELLITE;
          setIsLabelsChecked(isChecked);
          if (viewMode === ViewMode.SATELLITE) {
            updateURLParams(UrlParamsTypes.mapType, newMapTypeId);
      app/javascript/react/components/Map/ControlPanel/ControlPanel.tsx on lines 79..85

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

        const handleTerrainChange = (isChecked: boolean) => {
          const newMapTypeId = isChecked ? MapTypeId.TERRAIN : MapTypeId.ROADMAP;
          setIsTerrainChecked(isChecked);
          if (viewMode === ViewMode.MAP) {
            updateURLParams(UrlParamsTypes.mapType, newMapTypeId);
      app/javascript/react/components/Map/ControlPanel/ControlPanel.tsx on lines 87..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 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

      Function monthOrYearChanged has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          monthOrYearChanged: function (e) {
            var isLeft = $(e.target).closest(".drp-calendar").hasClass("left"),
              leftOrRight = isLeft ? "left" : "right",
              cal = this.container.find(".drp-calendar." + leftOrRight);
      
      
      Severity: Minor
      Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

        Method call has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def call
            {
              title: session.title,
              average: stream.measurements.average(:value),
              id: session.id,
        Severity: Minor
        Found in app/services/api/to_session_hash2.rb - About 1 hr to fix

          Function extraReducers has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            extraReducers: (builder) => {
              builder
                .addCase(fetchUsernames.pending, (state) => {
                  state.fetchUsernamesStatus = StatusEnum.Pending;
                  state.usernamesError = null;
          Severity: Minor
          Found in app/javascript/react/store/sessionFiltersSlice.ts - About 1 hr to fix

            Function newRectangles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  const newRectangles = crowdMapRectangles.map((rectangle) => {
                    const newRectangle = new google.maps.Rectangle({
                      bounds: new google.maps.LatLngBounds(
                        new google.maps.LatLng(rectangle.south, rectangle.west),
                        new google.maps.LatLng(rectangle.north, rectangle.east)
            Severity: Minor
            Found in app/javascript/react/components/Map/Markers/CrowdMapMarkers.tsx - About 1 hr to fix

              Method build_json_output has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def build_json_output(anonymous = false)
                  sessions = formatted_sessions
                  streams = Stream.where(session_id: sessions.pluck('sessions.id'))
                  selected_sensor_streams =
                    streams.select do |stream|
              Severity: Minor
              Found in app/services/api/to_active_sessions_json.rb - About 1 hr to fix

                Function createMarkerIcon has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

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

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Severity
                Category
                Status
                Source
                Language