Showing 151 of 266 total issues
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"
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 }
- 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 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|
- 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 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)
[
- 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 handle_response
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_response(response)
raise NotAuthorised, error_message(response) if response.status == 401
raise NotAllowed, error_message(response) if response.status == 403
raise NotFound, error_message(response) if response.status == 404
raise ApiFailure, error_message(response) unless response.success?
- 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"