HabitatMap/AirCasting

View on GitHub

Showing 239 of 667 total issues

Function setFilter has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    (key: UrlParamsTypes, value: string) => {
      if (isMobile) {
        setUrlParams([
          {
            key: key,
Severity: Minor
Found in app/javascript/react/utils/mapParamsHandler.ts - About 1 hr to fix

    Function updateIsActive has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        (newIsActive: boolean) => {
          if (sessionType === SessionTypes.MOBILE) {
            newIsActive = true;
          }
          setUrlParams([
    Severity: Minor
    Found in app/javascript/react/utils/mapParamsHandler.ts - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if lat.nil? || lng.nil? || lat.zero? || lng.zero? || lat > 90 ||
               lat < -90 || lng > 180 || lng < -180
            return 'UTC'
          end
      Severity: Critical
      Found in app/services/time_zone_finder_wrapper.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if lat.nil? || lng.nil? || lat.zero? || lng.zero? || lat > 90 ||
                 lat < -90 || lng > 180 || lng < -180
              return 'UTC'
            end
        Severity: Critical
        Found in app/services/time_zone_builder.rb - About 1 hr to fix

          Method session_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def session_data(attributes)
              "[
              {\"calibration\":0,
                \"contribute\":true,
                \"drawable\":2131165435,
          Severity: Minor
          Found in spec/controllers/api/user_sessions_controller_spec.rb - About 1 hr to fix

            Function sensors has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const sensors = (params) => {
              var Sensors = function () {
                this.sensors = {};
              };
            
            
            Severity: Minor
            Found in app/javascript/javascript/sensors.js - About 1 hr to fix

              Function hoverDate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  hoverDate: function (e) {
                    //ignore dates that can't be selected
                    if (!$(e.target).hasClass("available")) return;
              
                    var title = $(e.target).attr("data-title");
              Severity: Minor
              Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

                Function createObserver has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const createObserver = (config) => {
                  const {
                    observerConfig = DEFAULT_OBSERVER_CONFIG,
                    rootElement = DEFAULT_ROOT_ELEMENT,
                    selector,
                Severity: Minor
                Found in app/javascript/createObserver.js - About 1 hr to fix

                  Function setPreviousZoomInTheURL has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const setPreviousZoomInTheURL = () => {
                      const desktopCondition: boolean =
                        !isMobile &&
                        currentUserSettings !== UserSettings.ModalView &&
                        previousUserSettings !== UserSettings.CalendarView;
                  Severity: Minor
                  Found in app/javascript/react/components/Map/Map.tsx - About 1 hr to fix

                    Method generate_link has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def generate_link(stream)
                        threshold_min = stream.threshold_set.threshold_very_low.to_i
                        threshold_low = stream.threshold_set.threshold_low.to_i
                        threshold_middle = stream.threshold_set.threshold_medium.to_i
                        threshold_high = stream.threshold_set.threshold_high.to_i
                    Severity: Minor
                    Found in app/models/session.rb - About 1 hr to fix

                      Method filter_ has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.filter_(data = {})
                          sessions =
                            order('sessions.start_time_local DESC')
                              .where(contribute: true)
                              .joins(:user)
                      Severity: Minor
                      Found in app/models/session.rb - About 1 hr to fix

                        Function setEndDate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            setEndDate: function (endDate) {
                              if (typeof endDate === "string")
                                this.endDate = moment(endDate, this.locale.format);
                        
                              if (typeof endDate === "object") this.endDate = moment(endDate);
                        Severity: Minor
                        Found in app/javascript/jquery.ui.daterangepicker.js - About 1 hr to fix

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

                            def call
                              {
                                id: session.id,
                                title: session.title,
                                username: session.is_indoor ? 'anonymous' : session.user.username,
                          Severity: Minor
                          Found in app/services/api/to_fixed_session_with_streams_hash.rb - About 1 hr to fix

                            Method as_json has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def as_json(opts = nil)
                                opts ||= {}
                            
                                methods = opts[:methods] || %i[notes]
                                methods << :type
                            Severity: Minor
                            Found in app/models/session.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 buildQueryParamsForCrowdMapLayer_ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const buildQueryParamsForCrowdMapLayer_ = (gridSizeX, params, sensors) => ({
                              call: (streamIds, bounds) => {
                                if (!sensors.selected()) return false;
                                if (!hasTruthyValues(bounds)) return false;
                                const data = params().data;
                            Severity: Minor
                            Found in app/javascript/javascript/buildQueryParamsForCrowdMapLayer.js - 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 createObserver has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export const createObserver = (config) => {
                              const {
                                observerConfig = DEFAULT_OBSERVER_CONFIG,
                                rootElement = DEFAULT_ROOT_ELEMENT,
                                selector,
                            Severity: Minor
                            Found in app/javascript/createObserver.js - 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

                            Method filter_ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def self.filter_(data = {})
                                sessions =
                                  order('sessions.start_time_local DESC')
                                    .where(contribute: true)
                                    .joins(:user)
                            Severity: Minor
                            Found in app/models/session.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

                            Method fixed_active_government_sessions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def fixed_active_government_sessions(sensor_name:, west:, east:, north:, south:)
                                sensor_name = ActiveRecord::Base.connection.quote(sensor_name)
                            
                                sql = <<-SQL
                                  WITH recent_sessions AS (
                            Severity: Minor
                            Found in app/repositories/sessions_repository.rb - About 1 hr to fix

                              Function RealtimeMapUpdatesButton has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const RealtimeMapUpdatesButton = () => {
                                const { t } = useTranslation();
                                const isMobile = useScreenSizeDetection(screenSizes.mobile);
                              
                                const dispatch = useAppDispatch();

                                Function selectMobileStreamShortInfo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  (mobileStreamData, mobileSessionState): MobileStreamShortInfo => {
                                    const maxMeasurementValue = Math.max(
                                      ...mobileStreamData.measurements.map((m) => m.value)
                                    );
                                    const minMeasurementValue = Math.min(
                                Severity: Minor
                                Found in app/javascript/react/store/mobileStreamSelectors.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language