Showing 333 of 1,278 total issues
Method member=
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def member=(value)
if value
self.member_from = Time.zone.today if member_from.nil? || member_from.to_date >= Time.zone.today.to_date
unless member_to && (member_to.to_date >= Time.zone.local(RacingAssociation.current.effective_year).end_of_year.to_date)
self.member_to = Time.zone.local(RacingAssociation.current.effective_year).end_of_year.to_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 compare_by_most_recent_result
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.compare_by_most_recent_result(x, y, place_by)
x_source_results = source_results(x, place_by)
y_source_results = source_results(y, place_by)
return 0 if none?(x_source_results, y_source_results)
- 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 stable_sort_by
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def stable_sort_by(method, order = :asc)
case order
when :asc
merge_sort do |x, y|
if x.send(method).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 test_by_place
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_by_place
category = Models::Category.new("Masters Men")
rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], place_by: "place")
calculator = Calculator.new(rules: rules, source_results: [])
event_category = calculator.event_categories.first
Method upload
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload
uploaded_file = params[:results_file]
path = "#{Dir.tmpdir}/#{uploaded_file.original_filename}"
File.open(path, "wb") do |f|
Method test_calculate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_calculate
rules = Rules.new(
points_for_place: [100, 75, 50, 20, 10],
results_per_event: 3,
team: true
Method test_group_by_participant_id
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_group_by_participant_id
source_results = []
category = Models::Category.new("Masters Men")
participant_1 = Models::Participant.new(0)
Method test_match_equivalent_categories
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_match_equivalent_categories
source_results = []
masters_men = Models::Category.new("Masters Men")
masters_30 = Models::Category.new("Masters 30+")
junior_women = Models::Category.new("Junior Women")
Method category_names
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def category_names
[
"Athenas",
"Category 1/2 Masters 35+ Men",
"Category 1/2 Masters 35+ Women",
Method results_table
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def results_table(event, race, results = nil)
return "" unless race
table = Tabular::Table.new
Method show
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
discipline = Discipline[params["discipline"]]
if discipline.nil?
flash.now[:warn] = "Could not find discipline \'#{params['discipline']}\'"
return render(:show)
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 member=
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def member=(value)
if value
self.member_from = RacingAssociation.current.effective_year
self.member_to = RacingAssociation.current.effective_year
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 table
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def table(options = {}, &block)
# TODO: Use merge or something
options[:caption] = nil unless options[:caption]
options[:new_action] = nil unless options[:new_action]
options[:id] = nil unless options[:id]
- 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
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create
@editor = Person.find(params[:editor_id])
return redirect_to(unauthorized_path) unless @editor.administrator? || (@editor && current_person == @editor)
if @person.editors.include?(@editor)
- 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 test_apply_results_per_event_to_oldest_results_first
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_apply_results_per_event_to_oldest_results_first
scores = [
score(numeric_place: 1, points: 30, participant_id: 1, date: Date.new(2015, 9, 13), event_id: 1),
score(numeric_place: 2, points: 29, participant_id: 1, date: Date.new(2015, 9, 13), event_id: 1),
score(numeric_place: 2, points: 29, participant_id: 1, date: Date.new(2015, 9, 13), event_id: 1),
Method test_split_points_across_teams
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_split_points_across_teams
category = Models::Category.new("Masters Men")
rules = Rules.new(
category_rules: [Models::CategoryRule.new(category)],
points_for_place: [100, 75, 50, 20, 10]
Method ages_from_name
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ages_from_name(name)
if name[/\d{3}-\d{3}/]
age_range_match = /(\d{3})-(\d{3})/.match(name)
ages_begin = age_range_match[1].to_i / team_size(name)
ages_end = ((age_range_match[2].to_i + 1) / team_size(name)) - 1
Method import
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import(update_membership, year = nil)
ActiveSupport::Notifications.instrument(
"import.people_file.racing_on_rails", update_membership: update_membership, import_file: import_file, rows: table.rows.size
) do
@update_membership = update_membership
Method test_include_specific_events
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_include_specific_events
category = Models::Category.new("Women")
rules = Rules.new(
category_rules: [Models::CategoryRule.new(category)],
weekday_events: false