BathHacked/energy-sparks

View on GitHub

Showing 162 of 288 total issues

Method find_and_mirror_entry_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def find_and_mirror_entry_for(key, options)
        entry = lookup('en', key, options[:scope], options)
        entry = entry.dup if entry.is_a?(String)

        entry = pluralize('en', entry, options[:count]) if options[:count]
Severity: Minor
Found in app/services/i18n/backend/mirror.rb - About 35 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 include_fuel_type_in_suggestions? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def include_fuel_type_in_suggestions?(fuel_type)
      return false unless school_target
      return false unless @school.configuration.suggest_annual_estimate_for_fuel_type?(fuel_type)
      target_start_date = school_target.start_date
      fuel_type_start = @school.configuration.meter_start_date(fuel_type)
Severity: Minor
Found in app/services/targets/suggest_estimates_service.rb - About 35 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 resolve_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def resolve_value(record, value)
    case value
    when Proc
      if value.arity == 0
        value.call
Severity: Minor
Found in app/validators/comparison_validator.rb - About 35 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

Avoid too many return statements within this method.
Open

      return alert_type_rating.email_active?
Severity: Major
Found in app/models/alert_type_rating_content_version.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return alert_type_rating.sms_active?
    Severity: Major
    Found in app/models/alert_type_rating_content_version.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return series_key_as_string unless i18n_key
      Severity: Major
      Found in app/models/chart_data_values.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return translate_bill_component_series(series_key_as_string) if I18n.t('advice_pages.tables.labels.bill_components').keys.map(&:to_s).include?(series_key_as_string)
        Severity: Major
        Found in app/models/chart_data_values.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return :£ if choices.include?(:£)
          Severity: Major
          Found in app/services/charts/y_axis_selection_service.rb - About 30 mins to fix

            Method for_storage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              private_class_method def self.for_storage(val)
                return val if val.nil? || !needs_conversion?(val)
                if val.infinite? == 1
                  '.inf'
                elsif val.infinite? == -1
            Severity: Minor
            Found in app/models/benchmark_result.rb - About 25 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 overlapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def overlapping(usage_type)
                day = overlapping_days
                calendar_period = overlapping_calendar_periods
                overlapping = false
                school.school_times.each do |other|
            Severity: Minor
            Found in app/models/school_time.rb - About 25 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 produce_csv_row_automatic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def produce_csv_row_automatic(school_onboarding, state)
                    last_event = school_onboarding.events.order(event: :desc).first
                    [
                      school_onboarding.school_name,
                      state,
            Severity: Minor
            Found in app/controllers/admin/school_groups/school_onboardings_controller.rb - About 25 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 customise_y_axis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def customise_y_axis(new_config, overrides)
                if overrides[:y_axis_units]
                  overrides[:y_axis_units] = :£ if overrides[:y_axis_units] == :gb_pounds
                  # not using service here as we're applying the users direct selection of axis
                  valid_choices = ChartYAxisManipulation.new.y1_axis_choices(@original_config)
            Severity: Minor
            Found in app/models/customised_chart_config.rb - About 25 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 summary_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def summary_hash(status, one_day_kwh)
                    if status == 'ORIG'
                      description = 'ORIG, uncorrected good data'
                      colour = '#5cb85c'
                    else
            Severity: Minor
            Found in app/controllers/admin/reports/amr_validated_readings_controller.rb - About 25 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 full_previous_week? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def full_previous_week?
                    return false unless full_last_week?
                    return false unless previous_week_date_range.any?
                    return false unless aggregate_meter.amr_data.start_date <= previous_week_date_range.first
            
            
            Severity: Minor
            Found in app/services/schools/advice/recent_changes_service.rb - About 25 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 tags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def tags
                ret = []
                if @school.percentage_free_school_meals
                  percent = @school.percentage_free_school_meals
                  if percent >= 30
            Severity: Minor
            Found in app/services/mailchimp_tags.rb - About 25 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 sort_query_results_by has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.sort_query_results_by(mpans, query_results)
                mpans.uniq.each_with_object([]) do |mpan, rows|
                  next if mpan.empty?
            
                  rows_for_mpan = query_results.select { |result| result['mpan_mprn'] == mpan }
            Severity: Minor
            Found in app/models/amr_data_feed_reading.rb - About 25 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_possible_time_range_gaps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.find_possible_time_range_gaps
                existing_time_ranges = all.order(:start_time).map(&:time_range)
                possible_time_range_gaps = []
            
                existing_time_ranges.each_with_index do |time_range, index|
            Severity: Minor
            Found in app/models/energy_tariff_price.rb - About 25 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 get_missing_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_missing_array(first_reading, reading_summary)
                missing_array = (first_reading.at.to_date..Time.zone.today).collect do |day|
                  if ! reading_summary.key?(day)
                    [day, 'No readings']
                  elsif reading_summary.key?(day) && reading_summary[day] < 48
            Severity: Minor
            Found in app/controllers/data_feeds_controller.rb - About 25 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 determine_start_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def determine_start_date
                  return @override_start_date if @override_start_date
                  return nil if available_date_range.empty?
            
                  start = available_date_range.first
            Severity: Minor
            Found in app/services/amr/n3rgy_readings_download_and_upsert.rb - About 25 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 show_data_enabled_features? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def show_data_enabled_features?
                if current_user && current_user.admin?
                  params[:no_data] ? false : true
                else
                  @school.data_enabled?
            Severity: Minor
            Found in app/controllers/concerns/school_aggregation.rb - About 25 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