Showing 333 of 1,278 total issues
Method index
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if params[:key]
year = params[:year] || Time.zone.today.year
calculation = Calculations::V3::Calculation.find_by(key: params[:key], year: year)
Method test_place_many
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_place_many
category = Models::Category.new("Masters Men")
rules = Rules.new(category_rules: [Models::CategoryRule.new(category)])
calculator = Calculator.new(rules: rules, source_results: [])
event_category = calculator.event_categories.first
Method test_calculate_team_results_best_3_for_event
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_calculate_team_results_best_3_for_event
source_results = [
{ event_id: 1, race_id: 1, participant_id: 1, place: 107 },
{ event_id: 1, race_id: 1, participant_id: 1, place: 7 },
{ event_id: 1, race_id: 1, participant_id: 2, place: 1 },
Method test_fewest_points_wins
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_fewest_points_wins
category = Models::Category.new("Masters Men")
rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], place_by: "fewest_points")
calculator = Calculator.new(rules: rules, source_results: [])
event_category = calculator.event_categories.first
Method best_match_by_age_in
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def best_match_by_age_in(event_categories, result_age = nil)
debug "Category#best_match_by_age_in for #{name}, #{result_age} in #{event_categories.map(&:name).join(', ')}"
candidate_categories = event_categories.dup
Method test_calculate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_calculate
category = Models::Category.new("Masters Men")
rules = Rules.new
calculator = Calculator.new(rules: rules, source_results: [])
event_category = calculator.event_categories.first
Method test_merge_sort_preserves_order
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_merge_sort_preserves_order
king_hearts = Card.new("king", "hearts")
king_diamonds = Card.new("king", "diamonds")
king_spades = Card.new("king", "spades")
king_clubs = Card.new("king", "clubs")
Method test_remove_results_from_other_calculations
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_remove_results_from_other_calculations
category = Models::Category.new("Women")
rules = Rules.new(
category_rules: [Models::CategoryRule.new(category)],
disciplines: [Models::Discipline.new("Road")]
Method mtb_categories_for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mtb_categories_for(race)
return [] unless race.category
case race.category.name
when "Senior Men"
Method date_of_birth=
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def date_of_birth=(value)
value = case value
when String
if value[%r{^\d\d/\d\d/\d\d$}]
value.gsub %r{(\d+)/(\d+)/(\d+)}, '19\3/\1/\2'
Method category_names
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def category_names
[
"Athena",
"Category 1/2 35+ Men",
"Category 1/2 35+ Women",
Method test_missing_result_penalty
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_missing_result_penalty
source_results = [
{ event_id: 1, participant_id: 10, place: 2, race_id: 100 },
{ event_id: 1, participant_id: 10, place: 4, race_id: 100 },
{ event_id: 1, participant_id: 20, place: 5, race_id: 100 },
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
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.find(params)
query = if RacingAssociation.current.include_multiday_events_on_schedule?
Event.where(parent_id: nil).where.not(type: "Event")
else
Event.where(type: "SingleDayEvent")
Method categories_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def categories_for(race)
# Really should remove all other top-level categories and their descendants?
cats = [race.category] + race.category.descendants
if race.category.name == "Masters Men"
- 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 adjust_times
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def adjust_times
races_created_for_competition.each do |race|
next if race.event.discipline != "Time Trial"
distances = race.results.map(&:distance).compact.select(&: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 date_range_s
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def date_range_s(format = :short)
return date.year if all_year?
if format == :long
if start_date == end_date
- 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 <=>
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def <=>(other)
# Respect eql?
return 0 if id.present? && (id == other&.id)
# Figure out the major position by place first, then break it down further if needed
- 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 team_name=
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def team_name=(value)
if value.blank? || value == "N/A"
self.team = nil
else
self.team = Team.find_by_name_or_alias(value)
- 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 map_source_results_to_results
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def map_source_results_to_results(source_results)
source_results.each do |source_result|
source_result.reject("not_calculation_category") unless in_calculation_category?(source_result.category, source_result.age)
event_category = find_or_create_event_category(source_result)
- 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"