Showing 1,278 of 1,278 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
test "mixed postponed states" do
FactoryBot.create(:discipline, name: "Road")
SingleDayEvent.create!(date: Date.new(2020, 5, 31), name: "single past")
single = SingleDayEvent.create!(date: Date.new(2020, 6, 1), name: "single")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 783.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
test "mixed canceled states" do
FactoryBot.create(:discipline, name: "Road")
SingleDayEvent.create!(date: Date.new(2020, 5, 31), name: "single past")
single = SingleDayEvent.create!(date: Date.new(2020, 6, 1), name: "single")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 783.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File person_test.rb
has 1097 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "test_helper"
# :stopdoc:
class PersonTest < ActiveSupport::TestCase # rubocop:disable Metrics/ClassLength
test "save" do
Method best_match_in
has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring. Open
def best_match_in(event_categories, result_age = nil)
debug "Category#best_match_in for #{name} in #{event_categories.map(&:name).join(', ')}"
candidate_categories = event_categories.dup
- 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
File results_file_test.rb
has 602 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "test_helper"
# :stopdoc:
module Results
# FIXME: DNF's not handled correctly.
File multi_day_event_test.rb
has 579 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.expand_path("../../test_helper", __dir__)
# :stopdoc:
class MultiDayEventTest < ActiveSupport::TestCase
test "start end dates" do
File competition.rb
has 496 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Competitions
# Results that derive their results from other Events. Se TYPES.
# Year-long: BAR, Ironman, WSBA Rider Rankings, Oregon Cup.
# Event-based: Cross Crusade, Mount Tabor Series.
#
Class Competition
has 55 methods (exceeds 20 allowed). Consider refactoring. Open
class Competition < Event
include Competitions::Categories
include Competitions::Dates
include Competitions::Naming
include Competitions::Points
Method receive
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def receive(email)
post = Post.new
# Sometimes we get poorly-encoded data and New Relic chokes
NewRelic::Agent.disable_all_tracing do
- 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
File result_test.rb
has 453 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.expand_path("../../test_helper", __dir__)
# :stopdoc:
class ResultTest < ActiveSupport::TestCase
setup :number_issuer
File bar_test.rb
has 452 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "test_helper"
# :stopdoc:
class Calculations::V3::BarTest < ActiveSupport::TestCase
setup { FactoryBot.create :discipline }
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_double_points_and_maximum_events
rules = { double_points_for_last_event: true, maximum_events: 5, end_date: Date.new(2014, 7, 9), point_schedule: [100, 70, 50, 40, 36, 32, 28, 24, 20, 16, 15, 14, 13, 12, 11], members_only: false }
source_results = [
{ "place" => "10", "date" => Date.new(2014, 6, 4), "event_id" => 1, "race_id" => 1, "participant_id" => 1 },
{ "place" => "9", "date" => Date.new(2014, 6, 11), "event_id" => 2, "race_id" => 2, "participant_id" => 1 },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 220.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_last_event_should_be_more_points
rules = { double_points_for_last_event: true, maximum_events: 5, end_date: Date.new(2014, 7, 9), point_schedule: [100, 70, 50, 40, 36, 32, 28, 24, 20, 16, 15, 14, 13, 12, 11], members_only: false }
source_results = [
{ "place" => "1", "date" => Date.new(2014, 6, 4), "event_id" => 1, "race_id" => 1, "participant_id" => 1 },
{ "place" => "3", "date" => Date.new(2014, 6, 11), "event_id" => 2, "race_id" => 2, "participant_id" => 1 },
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 220.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method normalize_spelling
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def self.normalize_spelling(name)
if name
name = name.split.map do |token|
if token[/\A(cat|caat|categpry|categroy|cateogry|categegory|catgory|caegory|ct)\.?\z/i]
"Category"
- 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
File results_controller_test.rb
has 423 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.expand_path("../../test_helper", __dir__)
module Admin
# :stopdoc:
class ResultsControllerTest < ActionController::TestCase
Method create_login
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def create_login
@return_to = params[:return_to]
if params[:id].present?
@person = Person.find_using_perishable_token(params[: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 best_match_in
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
def best_match_in(event_categories, result_age = nil)
debug "Category#best_match_in for #{name} in #{event_categories.map(&:name).join(', ')}"
candidate_categories = event_categories.dup
File place_test.rb
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative "../../../../app/models/competitions/calculations/calculator"
require_relative "calculations_test"
# :stopdoc:
module Competitions
Method merge
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def merge(other_person, force: false)
# Consider just using straight SQL for this --
# it's not complicated, and the current process generates an
# enormous amount of SQL
- 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
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