Showing 1,265 of 1,265 total issues
File best_match_in_test.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "test_helper"
module Competitions
# :stopdoc:
class BestMatchInTest < ActiveSupport::TestCase
File event_test.rb
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.expand_path("../../test_helper", __dir__)
# :stopdoc:
class EventTest < ActiveSupport::TestCase
test "validate discipline" do
Method set_defaults
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def set_defaults
if new_record?
set_propogated_attributes
self.bar_points = default_bar_points if self[:bar_points].nil?
self.date = default_date if self[:date].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_many_ties
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_many_ties
men_9_18 = Models::Category.new("Men 9-18")
rules = Rules.new(category_rules: [Models::CategoryRule.new(men_9_18)], place_by: "place")
calculator = Calculator.new(rules: rules, source_results: [])
event_category = calculator.event_categories.first
File name_normalization.rb
has 314 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Categories
module NameNormalization
extend ActiveSupport::Concern
RACING_ASSOCIATIONS = %w[ ABA ATRA CBRA GBRA MBRA NABRA OBRA WSBA ].freeze
Similar blocks of code found in 2 locations. Consider refactoring. Open
categories << Category.find_or_create_by(name: "Masters Men A 40+") if race.name == "Masters 35+ A"
categories << Category.find_or_create_by(name: "Masters Men B 40+") if race.name == "Masters 35+ B"
if race.name == "Masters 35+ C"
categories << Category.find_or_create_by(name: "Masters Men C 40+")
categories << Category.find_or_create_by(name: "Men C 35+")
- 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 123.
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
categories << Category.find_or_create_by(name: "Masters Men 1/2 40+") if race.name == "Masters 35+ 1/2"
categories << Category.find_or_create_by(name: "Masters Men 3 40+") if race.name == "Masters 35+ 3"
if race.name == "Masters 35+ 4"
categories << Category.find_or_create_by(name: "Masters Men 4 40+")
categories << Category.find_or_create_by(name: "Men 4 35+")
- 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 123.
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 test_abilities_from_name
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_abilities_from_name
{
"12/24-Hour 2-Person" => 0..999,
"A Group" => 0..999,
"A Group Prime #1" => 0..999,
File people_controller_test.rb
has 307 lines of code (exceeds 250 allowed). Consider refactoring. Open
require File.expand_path("../../test_helper", __dir__)
module Admin
# :stopdoc:
class PeopleControllerTest < ActionController::TestCase
Class Event
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ApplicationRecord
TYPES = %w[ Event SingleDayEvent MultiDayEvent Series WeeklySeries ].freeze unless defined?(TYPES)
include Events::Children
include Events::Comparison
Similar blocks of code found in 2 locations. Consider refactoring. Open
def test_over_maximum
category = Models::Category.new("Women")
source_results = []
source_results << Models::SourceResult.new(id: 0, event_category: Models::EventCategory.new(category), points: 10, place: 7)
source_results << Models::SourceResult.new(id: 1, event_category: Models::EventCategory.new(category), points: 5, place: 9)
- 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 116.
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_points_not_place
category = Models::Category.new("Women")
source_results = []
source_results << Models::SourceResult.new(id: 0, event_category: Models::EventCategory.new(category), points: 10, place: 1)
source_results << Models::SourceResult.new(id: 1, event_category: Models::EventCategory.new(category), points: 50, place: 2)
- 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 116.
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 parse
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.parse(row)
logger.debug(row.inspect) if logger.debug?
row[:instructional] = true if row[:discipline] == "Clinic"
- 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_bar
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_bar
category_pro_1_2 = Models::Category.new("Category Pro/1/2 Women")
category_3 = Models::Category.new("Category 3 Women")
category_rules = [
Models::CategoryRule.new(category_pro_1_2),
Method create_login
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_login
@return_to = params[:return_to]
if params[:id].present?
@person = Person.find_using_perishable_token(params[:id])
Method test_do_not_reject_unplaced
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_do_not_reject_unplaced
category_pro_1_2 = Models::Category.new("Category Pro/1/2 Women")
category_rules = [
Models::CategoryRule.new(category_pro_1_2)
]
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
source_results = [
result(id: 1, event_id: 1, race_id: 1, place: 1),
result(id: 2, event_id: 1, race_id: 1, participant_id: 1, place: nil),
result(id: 3, event_id: 1, race_id: 1, participant_id: 1, place: ""),
result(id: 4, event_id: 1, race_id: 1, participant_id: 1, place: "DQ"),
- 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 108.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
source_results = [
result(id: 1, event_id: 1, race_id: 1, place: 1),
result(id: 2, event_id: 1, race_id: 1, participant_id: 1, place: nil),
result(id: 3, event_id: 1, race_id: 1, participant_id: 1, place: ""),
result(id: 4, event_id: 1, race_id: 1, participant_id: 1, place: "DQ"),
- 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 108.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
source_results = [
result(id: 1, event_id: 1, race_id: 1, place: 1),
result(id: 2, event_id: 1, race_id: 1, participant_id: 1, place: nil),
result(id: 3, event_id: 1, race_id: 1, participant_id: 1, place: ""),
result(id: 4, event_id: 1, race_id: 1, participant_id: 1, place: "DQ"),
- 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 108.
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