BathHacked/energy-sparks

View on GitHub

Showing 162 of 288 total issues

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

    def perform
      array_of_rows = handle_header(@array_of_rows)
      array_of_rows = sort_out_off_by_one_array(array_of_rows) if @config.handle_off_by_one && array_of_rows.size > 1
      array_of_rows = array_of_rows.reject { |row| invalid_row?(row) }
      array_of_rows = array_of_rows.reject { |row| partial_row?(row) } unless @config.missing_readings_limit.nil?
Severity: Minor
Found in app/services/amr/data_feed_validator.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 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 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 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

Function processAnalysisChartAjax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function processAnalysisChartAjax(chartId, chartConfig, highchartsChart) {
  var chartType = chartConfig.type;
  var yAxisUnits = chartConfig.y_axis_units;
  var mpanMprn = chartConfig.mpan_mprn;
  var seriesBreakdown = chartConfig.series_breakdown;
Severity: Minor
Found in app/assets/javascripts/analysis.js - 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 no_overlaps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def no_overlaps
    return unless self.opening_time.present? && self.closing_time.present?
    errors.add(:overlapping_time, 'Community use periods cannot overlap the school day') if usage_type == 'community_use' && overlaps_school_day?
    errors.add(:overlapping_time, 'Periods cannot overlap each other') if overlaps_other?
  end
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 to_progress_summary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def to_progress_summary
    Targets::ProgressSummary.new(
      school_target: self,
      electricity: electricity_progress.any? ? Targets::FuelProgress.new(**electricity_progress.symbolize_keys!) : nil,
      gas: gas_progress.any? ? Targets::FuelProgress.new(**gas_progress.symbolize_keys!) : nil,
Severity: Minor
Found in app/models/school_target.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 failing? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

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

    def handle_header(array_of_rows)
      if array_of_rows.first.join(',') == @config.header_example
        array_of_rows[1, array_of_rows.length]
      elsif @config.number_of_header_rows
        if @config.number_of_header_rows > array_of_rows.length
Severity: Minor
Found in app/services/amr/data_feed_validator.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 help_page_for_feature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def help_page_for_feature(feature)
    help_page = HelpPage.find_by_feature(feature)
    return help_page if help_page.present? && (help_page.published? || current_user && current_user.admin?)
  rescue ActiveRecord::StatementInvalid
    # feature not yet added to enum in HelpPage model
Severity: Minor
Found in app/helpers/help_page_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 group_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def group_content(content)
    benchmarks = []
    i = -1
    content.each do |fragment|
      if select_fragment?(fragment)
Severity: Minor
Found in app/services/benchmark_content_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 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 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

Severity
Category
Status
Source
Language