BathHacked/energy-sparks

View on GitHub

Showing 159 of 283 total issues

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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def show
        @electricity_service = @school.has_electricity? ? ::TargetsService.new(aggregate_school, :electricity) : nil
        @gas_service = @school.has_gas? ? ::TargetsService.new(aggregate_school, :gas) : nil
        @storage_heater_service = @school.has_storage_heaters? ? ::TargetsService.new(aggregate_school, :storage_heaters) : nil
      end
Severity: Minor
Found in app/controllers/admin/schools/target_data_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 set_n3rgy_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def set_n3rgy_status
      return unless can?(:view_dcc_data, @school)
      service = Meters::N3rgyMeteringService.new(@meter)
      @known_to_n3rgy = service.available?
      if @known_to_n3rgy && @meter.dcc_meter
Severity: Minor
Found in app/controllers/schools/meters_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 analysis_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.analysis_date(meter_collection, fuel_type)
    return Time.zone.today unless fuel_type
    fuel_type = fuel_type.to_sym
    if fuel_type == :gas
      meter_collection.aggregated_heat_meters.amr_data.end_date
Severity: Minor
Found in app/services/aggregate_school_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 series_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def series_data
    return @series_data unless @series_data.is_a? Array

    # Temporary TOFIX TODO as analytics should not return negative values
    @series_data.map do |series|
Severity: Minor
Found in app/models/chart_data_values.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 comparison_report_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def comparison_report_path(report, params)
    if report.reporting_period == 'custom'
      # it seems since the route doesn't use a resource polymorphic_path doesn't work
      comparisons_configurable_period_path(key: report.key, params: params)
    else
Severity: Minor
Found in app/helpers/comparisons_helper.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 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 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 tariff_changed? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def tariff_changed?
      return true unless same_tariff_type?
      return true unless same_standing_charge?
      return true unless same_prices?
      false
Severity: Minor
Found in app/services/amr/n3rgy_tariff_manager.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 update_meters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def update_meters
      redirect_back fallback_location: school_energy_tariffs_path(@tariff_holder), notice: I18n.t('schools.user_tariffs.choose_meters.missing_meters') and return if require_meters?

      @energy_tariff.meter_ids = energy_tariff_params[:meter_ids]
      @energy_tariff.applies_to = energy_tariff_params[:applies_to].present? ? energy_tariff_params[:applies_to] : :both
Severity: Minor
Found in app/controllers/energy_tariffs/energy_tariffs_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 passing? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def passing?(fuel_progress, check_recent = true)
      return false unless fuel_progress.present? && fuel_progress.achieving_target?
      return true unless check_recent
      return true if fuel_progress.recent_data?
      false
Severity: Minor
Found in app/classes/targets/progress_summary.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(school_group_ids: [], scoreboard_ids: [], school_types: [], school_type: nil, country: nil, funder: nil, include_invisible: false)
    @school_group_ids = school_group_ids.reject(&:blank?)
    @scoreboard_ids = scoreboard_ids.reject(&:blank?)
    @school_types = school_type.present? ? [school_type] : school_types
    @funders = funder.present? ? [funder] : []
Severity: Minor
Found in app/services/school_filter.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 label_point_and_max_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def label_point_and_max_for(y2_data_title)
    if y2_is_temperature?(y2_data_title)
      ['°C', '{point.y:.2f} °C',]
    elsif y2_is_degree_days?(y2_data_title)
      [
Severity: Minor
Found in app/models/chart_data_values.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 report has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def report(alert_configuration: nil)
        # debugger
        analysis_object = alert_class.new(@aggregate_school)
        if analysis_object.respond_to?(:comparison_configuration=)
          analysis_object.comparison_configuration = alert_configuration
Severity: Minor
Found in app/services/alerts/adapters/analytics_adapter.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 add_progress_report_fuel_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_progress_report_fuel_type(row, fuel_target, fuel_progress)
      if fuel_target.present?
        row += [
          format_percent_reduction(fuel_target),
          fuel_progress.present? && fuel_progress.progress.present? ? format_target(fuel_progress.progress) : nil
Severity: Minor
Found in app/services/targets/admin_report_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 check_response_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_response_status(response)
      raise BadRequest.new(error_message(response)) if response.status == 400
      raise NotAuthorised.new(error_message(response)) if response.status == 401
      raise NotAllowed.new(error_message(response)) if response.status == 403
      raise NotFound.new(error_message(response)) if response.status == 404
Severity: Minor
Found in lib/transifex/client.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 percent_change has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.percent_change(base, new_val, to_nil_if_sum_zero = false)
      return nil if to_nil_if_sum_zero && sum_data(base) == 0.0
      return 0.0 if sum_data(base) == 0.0

      change = (sum_data(new_val) - sum_data(base)) / sum_data(base)
Severity: Minor
Found in lib/energy_sparks/calculator.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