Showing 258 of 266 total issues
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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|
- Read upRead up
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
- Read upRead up
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;
- Read upRead up
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,
- Read upRead up
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
- Read upRead up
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 = Colours.chart_green
else
- Read upRead up
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 destroy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def destroy
if (@calendar.school? || @calendar.national?) && @calendar.school?
redirect_to admin_calendars_path, notice: 'Cannot delete national or school calendars'
end
if @calendar.regional? && @calendar.calendars.count.positive?
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
authorize! :show, @school_target
unless @school_target.report_last_generated.nil?
@progress_summary = @school_target.to_progress_summary
- Read upRead up
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
- Read upRead up
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_meter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_meter(school, fuel_type)
return unless SCHOOL_TYPES.include?(school.school_type.to_sym)
meter = school.aggregate_meter(fuel_type)
- Read upRead up
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
- Read upRead up
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] : []
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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 charts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def charts
raise 'Non-public data' unless @school.data_sharing_public?
raise 'Not data enabled' unless @school.data_enabled?
@chart_type = params.require(:chart_type).to_sym
- Read upRead up
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"