BathHacked/energy-sparks

View on GitHub
app/services/calculate_average_school.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method group_by_half_hour has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def group_by_half_hour(school_data_array)
    by_half_hour = Hash.new do |h1, day_type|
      h1[day_type] = Hash.new do |h2, month|
        h2[month] = Hash.new do |h3, half_hour|
          h3[half_hour] = []
Severity: Minor
Found in app/services/calculate_average_school.rb - About 1 hr 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_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)

Severity: Minor
Found in app/services/calculate_average_school.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 average_by_type_within_rank_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def average_by_type_within_rank_range(by_school_type, rank_range, fuel_type)
    averages = Hash.new do |h1, school_type|
      h1[school_type] = Hash.new do |h2, day_type|
        h2[day_type] = Hash.new do |h3, month|
          h3[month] = []
Severity: Minor
Found in app/services/calculate_average_school.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

There are no issues that match your filters.

Category
Status