Showing 333 of 1,278 total issues
Method compare_by_most_recent_result
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def compare_by_most_recent_result(x, y)
return 0 if none?(x.scores, y.scores)
# Sort scores by most recent date, lowest place
# "Best" scores last because #pop returns the last item
- 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!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.calculate!(year = Time.zone.today.year)
ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
transaction do
series = Series.where(name: parent_event_name).year(year).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 calculate!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.calculate!(year = Time.zone.today.year)
ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
transaction do
parent = ::WeeklySeries.year(year).where(name: parent_event_name).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 categories_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def categories_for(race)
categories = [race.category] + race.category.descendants
if race.category.name == "Masters Men"
masters_men_4_5 = ::Category.find_by(name: "Masters Men 4/5")
- 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 compare_by_most_recent_place
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def compare_by_most_recent_place(other)
dates = Set.new(scores + other.scores) { |score| score.source_result.date }.to_a
dates.sort!.reverse!
dates.each do |date|
score = scores.detect { |s| s.source_result.event.date == 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 hometown
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def hometown
if city.blank?
if state.blank?
""
elsif state == RacingAssociation.current.state
- 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!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.calculate!(year = Time.zone.today.year)
ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
transaction do
year = year.to_i if year.is_a?(String)
date = Date.new(year, 1, 1)
- 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 points_for_place
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.points_for_place(source_result, points_for_place, place_by, result_place, results_size)
return 0 unless source_result.placed?
if place_by == "place"
return 0 if result_place == Float::INFINITY
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update
@person.password = params[:person][:password]
if @person.password.blank?
flash[:warn] = "Please provide a new password"
- 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 normalize_ability_punctuation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.normalize_ability_punctuation(name)
# Don't combine Junior Men 9-12 3/4/5
return name if name[%r{\d-1\d \d/\d/\d}]
5.downto(2).each do |length|
- 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 set_membership_dates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_membership_dates
if member_from && member_to.nil?
self.member_to = Time.zone.local(member_from.year).end_of_year
elsif member_from.nil? && member_to
self.member_from = Time.zone.today if member_from.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 results_table
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def results_table(event, race, results = nil)
return "" unless race
table = Tabular::Table.new
- 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 labelled_text
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def labelled_text(object_name, method, label_text = nil, text = nil, label_options = {}, _text_class = nil)
Method upload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def upload
uploaded_file = params[:results_file]
path = "#{Dir.tmpdir}/#{uploaded_file.original_filename}"
File.open(path, "wb") do |f|
- 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 assert_equal_dates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def assert_equal_dates(expected, actual, message = nil, format = "%Y-%m-%d")
expected = expected.strftime(format) if !expected.nil? && (expected.is_a?(Date) || expected.is_a?(DateTime) || expected.is_a?(Time))
formatted_actual = actual
formatted_actual = actual.strftime(format) if !actual.nil? && (actual.is_a?(Date) || actual.is_a?(DateTime) || actual.is_a?(Time))
flunk("#{message} \nExpected #{expected} \nbut was #{formatted_actual}") unless expected == formatted_actual
- 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
Consider simplifying this complex logical expression. Open
if frozen?
self[:team_competition_result] ||
event.is_a?(::Competitions::TeamBar) ||
event.is_a?(::Competitions::CrossCrusadeTeamCompetition) ||
event.is_a?(::Competitions::MbraTeamBar)
Consider simplifying this complex logical expression. Open
if !new_record? &&
previous_name.present? &&
name.present? &&
previous_name.casecmp(name) != 0 &&
!Alias.exists?(name: previous_name, aliasable_id: id, aliasable_type: "Team") &&
Consider simplifying this complex logical expression. Open
next if !weekday?(source_result.event) ||
(calculator.calculations_events.include?(source_result.event) && source_result.event.points?) ||
omnium_or_stage_race?(source_result.event.parent) ||
omnium_or_stage_race?(source_result.event) ||
series_overall?(source_result.event)
Consider simplifying this complex logical expression. Open
if !new_record? &&
previous_name.present? &&
name.present? &&
previous_name.casecmp(name) != 0 &&
!Alias.exists?(name: previous_name, aliasable_id: id, aliasable_type: "Person") &&
Consider simplifying this complex logical expression. Open
elsif token[/\Abeg?\.?\z/i] || token[/\Abg\.?\z/i] || token[/\Abegin?\.?\z/i] || token[/\Abeginners\z/i] || token[/\Abeg:\z/i] ||
token[/\ABeginning\z/i]
"Beginner"
elsif token[/\A(exp|expt|ex|exeprt|exb|exper|exprert)\.?\z/i]