Class Race
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class Race < ApplicationRecord
include Calculations::V3::Rejection
include Comparable
include Export::Races
include RacingOnRails::PaperTrail::Versions
File race.rb
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Race < ApplicationRecord
include Calculations::V3::Rejection
include Comparable
include Export::Races
include RacingOnRails::PaperTrail::Versions
Method place_results_by_time
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def place_results_by_time
_results = results.to_a.sort do |x, y|
if x.laps && y.laps && x.laps != y.laps
y.laps <=> x.laps
elsif x.time
- 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 calculate_members_only_places!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def calculate_members_only_places!
# count up from zero
last_members_only_place = 0
# assuming first result starting at zero+one (better than sorting results twice?)
last_result_place = 0
- 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 place_results_by_time
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def place_results_by_time
_results = results.to_a.sort do |x, y|
if x.laps && y.laps && x.laps != y.laps
y.laps <=> x.laps
elsif x.time
Method find_associated_records
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_associated_records
if category && (category.new_record? || category.changed?)
if category.name.blank?
self.category = nil
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 create_result_before
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def create_result_before(result_id)
return results.create(place: "1") if results.empty?
if result_id
_results = results.sort
- 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
FIXME found Open
# FIXME Handle people with only a number
- Exclude checks