BathHacked/energy-sparks

View on GitHub

Showing 151 of 266 total issues

Method resource_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def resource_data(name, slug, project_id, categories, priority)
      {
        "data": {
          "attributes": {
            "accept_translations": true,
Severity: Minor
Found in lib/transifex/client.rb - About 1 hr to fix

    Function initChart has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function initChart(chartDiv) {
    
        var supply = $(chartDiv).find("input[name='supply']").val();
        var period = $(chartDiv).find("input[name='period']").val();
    
    
    Severity: Minor
    Found in app/assets/javascripts/usage_charts.js - About 1 hr to fix

      Method with_neighbour_updates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def with_neighbour_updates(calendar_event, attributes)
          managing_state(calendar_event) do |pre_save, post_save|
            calendar_event.attributes = attributes
            reset_parent(calendar_event)
            if calendar_event.calendar_event_type.term_time || calendar_event.calendar_event_type.holiday
      Severity: Minor
      Found in app/services/holiday_factory.rb - About 55 mins 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 check_operations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def check_operations(chart_config)
          allowed_operations = {}
          OPERATIONS.each do |operation_type|
            manipulator = ChartManagerTimescaleManipulation.factory(operation_type, chart_config, @aggregated_school)
            allowed_operations[operation_type] = if manipulator.chart_suitable_for_timescale_manipulation?
      Severity: Minor
      Found in app/models/chart_data.rb - About 55 mins 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 country has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def country
            scotland_postcodes = %w[AB DD DG EH FK G HS IV KA KW KY ML PA PH TD ZE]
            wales_postcodes    = %w[CF CH GL HR LD LL NP SA SY]
            postcode_prefix = @school.postcode.upcase[/^[[:alpha:]]+/]
      
      
      Severity: Minor
      Found in app/services/schools/country_lookup.rb - About 55 mins 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 export has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def export
            CSV.generate(headers: true) do |csv|
              csv << headers
              @total_savings.each do |alert_type_rating, _savings| # rubocop:disable Style/HashEachMethods - not a hash
                next unless @alert_type_rating_ids.map(&:to_i).include?(alert_type_rating.id)
      Severity: Minor
      Found in app/services/school_groups/schools_priority_action_csv_generator.rb - About 55 mins 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 process_area has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_area(area)
            gsp_area_id = gsp_area_id(area)
            solar_pv_data, _missing_date_times, _whole_day_substitutes = @solar_pv_tuos_interface.historic_solar_pv_data(
              gsp_area_id,
              area.latitude,
      Severity: Minor
      Found in lib/data_feeds/solar_pv_tuos_loader.rb - About 55 mins 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 subscribe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def subscribe(user)
          list = @mailchimp_api.list_with_interests
          if list
            config = mailchimp_signup_params(user, list)
            if config.valid?
      Severity: Minor
      Found in app/services/mailchimp_subscriber.rb - About 45 mins 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 no_overlaps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def no_overlaps
          if start_date && end_date && calendar_event_type
            overlap_types = if calendar_event_type.term_time || calendar_event_type.holiday
                              (CalendarEventType.holiday + CalendarEventType.term)
                            else
      Severity: Minor
      Found in app/models/calendar_event.rb - About 45 mins 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 bill_component_row has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def bill_component_row(component:)
          # early return if we don't have any of these components
          return unless bill_component?(component: component)
      
          total = 0.0
      Severity: Minor
      Found in app/components/meter_costs_table_component.rb - About 45 mins 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 issue_type_icons has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def issue_type_icons(issues, hide_empty: false, label: '')
          counts = []
          icons = []
          Issue.issue_types.each_key do |issue_type|
            count = issues.for_issue_types(issue_type).status_open.count
      Severity: Minor
      Found in app/helpers/issues_helper.rb - About 45 mins 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 up_downify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def up_downify(text, sanitize: true)
          return if text.nil? || text == '-'
          icon = if text.match?(/^\+/)
                   fa_icon('arrow-circle-up')
                 elsif text.match?(/increased/)
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 45 mins 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 add_user_to_csv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_user_to_csv(csv, school_group, school, user)
              csv << [
                school_group.name,
                school.present? ? school.name : 'N/A',
                user.name,
      Severity: Minor
      Found in app/controllers/admin/school_groups/users_controller.rb - About 45 mins 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 find_interests has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_interests(user, list)
          ret = {}
          items = []
          items << user.default_school_group_name if user.default_school_group_name
          items << user.staff_role.title if user.staff_role
      Severity: Minor
      Found in app/services/mailchimp_subscriber.rb - About 45 mins 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 select_y_axis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def select_y_axis
            choices = y1_axis_choices
            return nil if choices.nil?
            case @school.chart_preference.to_sym
            when :default
      Severity: Minor
      Found in app/services/charts/y_axis_selection_service.rb - About 45 mins 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 benchmark_colour has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def benchmark_colour(data_type, category)
          # this has multiple fuel types
          if [:benchmark, :benchmark_one_year].include?(@chart_type)
            return colours_for_multiple_fuel_type_benchmark(data_type, category)
          end
      Severity: Minor
      Found in app/models/chart_data_values.rb - About 45 mins 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 columns_for_usage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def columns_for_usage(recent_usage)
            columns = []
            fuel_types.each do |fuel_type|
              # loop first to add all metrics for last week, then last year
              # rubocop:disable Style/CombinableLoops
      Severity: Minor
      Found in app/services/school_groups/recent_usage_csv_generator.rb - About 45 mins 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 format_for_order has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def format_for_order
            case @unit
            when :date, :date_mmm_yyyy, :datetime
              if @val.is_a?(Date) || @val.is_a?(DateTime)
                @val.iso8601
      Severity: Minor
      Found in app/components/comparison_table_component.rb - About 45 mins 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 parse_tariff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_tariff(response)
            # Ignore if response isn't as expected
            return nil unless valid_response?(response)
            # Ignore if no tariffs stored on meter
            return nil unless tariffs_for_meter?(response)
      Severity: Minor
      Found in app/services/amr/n3rgy_tariff_downloader.rb - About 45 mins 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 processAnalysisOperations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function processAnalysisOperations(chartConfig, chart, operations, drilldownAvailable, parentTimescaleDescription){
        var chartContainer = $(chart.renderTo);
        var controls = $(chartContainer).parent().find('.analysis-controls');
        var anyOperations = false;
        if(controls.length){
      Severity: Minor
      Found in app/assets/javascripts/analysis.js - About 45 mins 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