HabitatMap/AirCasting

View on GitHub

Showing 667 of 667 total issues

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

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

                  <S.TimeRangeButton
                    $isActive={timeRange === TimeRanges.DAYS_3}
                    onClick={() => onSelectTimeRange(TimeRanges.DAYS_3)}
                  >
                    {t("timelapse.timeRange.3days")}
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 21..26
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 33..38

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

            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

                  <S.TimeRangeButton
                    $isActive={timeRange === TimeRanges.DAYS_7}
                    onClick={() => onSelectTimeRange(TimeRanges.DAYS_7)}
                  >
                    {t("timelapse.timeRange.7days")}
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 21..26
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 27..32

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

            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

                  <S.TimeRangeButton
                    $isActive={timeRange === TimeRanges.HOURS_24}
                    onClick={() => onSelectTimeRange(TimeRanges.HOURS_24)}
                  >
                    {t("timelapse.timeRange.24hours")}
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 27..32
            app/javascript/react/components/Modals/TimelapseModal/TimeRangeButtons.tsx on lines 33..38

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

            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

              context 'with multiple correct measurements in the same location' do
                let!(:measurements_data) do
                  ["03/25/24|07:00|000020104|measurement-location|-4|PM2.5|PPB|0.3|attribution\n" +
                  "03/25/24|07:00|000020104|measurement-location|-4|NO2|PPB|0.3|attribution"]
                end
            Severity: Major
            Found in spec/services/air_now/import_measurements_spec.rb and 1 other location - About 1 hr to fix
            spec/services/air_now/import_measurements_spec.rb on lines 64..79

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

            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

              context 'with unwanted parameters' do
                let!(:measurements_data) do
                  ["03/25/24|07:00|000020104|measurement-location|-4|SO2|PPB|0.3|attribution\n" +
                  "03/25/24|07:00|000020104|measurement-location|-4|NO2|PPB|0.3|attribution"]
                end
            Severity: Major
            Found in spec/services/air_now/import_measurements_spec.rb and 1 other location - About 1 hr to fix
            spec/services/air_now/import_measurements_spec.rb on lines 83..98

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

            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

            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

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

                        context 'when time passed since last email < frequency' do
                          let!(:alert) do
                            ThresholdAlert.create(
                              user: user,
                              session_uuid: session.uuid,
                    Severity: Major
                    Found in spec/workers/threshold_alerts_worker_spec.rb and 1 other location - About 1 hr to fix
                    spec/workers/threshold_alerts_worker_spec.rb on lines 12..35

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

                    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

                        context 'when time passed since last email > frequency' do
                          let!(:alert) do
                            ThresholdAlert.create(
                              user: user,
                              session_uuid: session.uuid,
                    Severity: Major
                    Found in spec/workers/threshold_alerts_worker_spec.rb and 1 other location - About 1 hr to fix
                    spec/workers/threshold_alerts_worker_spec.rb on lines 40..63

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

                    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