scottwillson/racing_on_rails

View on GitHub

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")
Severity: Major
Found in test/models/events/upcoming_test.rb and 1 other location - About 3 days to fix
test/models/events/upcoming_test.rb on lines 194..316

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

Further Reading

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")
Severity: Major
Found in test/models/events/upcoming_test.rb and 1 other location - About 3 days to fix
test/models/events/upcoming_test.rb on lines 320..442

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

Further Reading

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
Severity: Major
Found in test/models/person_test.rb - About 2 days to fix

    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
    
    
    Severity: Minor
    Found in app/models/categories/matching.rb - About 1 day to fix

    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.
    Severity: Major
    Found in test/models/results/results_file_test.rb - About 1 day to fix

      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
      Severity: Major
      Found in test/models/events/multi_day_event_test.rb - About 1 day to fix

        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.
          #
        Severity: Minor
        Found in app/models/competitions/competition.rb - About 7 hrs to fix

          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
          Severity: Major
          Found in app/models/competitions/competition.rb - About 7 hrs to fix

            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
            Severity: Minor
            Found in app/models/mailing_list_mailer.rb - About 7 hrs to fix

            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
            Severity: Minor
            Found in test/models/results/result_test.rb - About 6 hrs to fix

              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 }
              Severity: Minor
              Found in test/models/calculations/v3/bar_test.rb - About 6 hrs to fix

                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 },
                Severity: Major
                Found in test_ruby/models/competitions/calculations/points_test.rb and 1 other location - About 6 hrs to fix
                test_ruby/models/competitions/calculations/points_test.rb on lines 135..155

                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

                Further Reading

                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 },
                Severity: Major
                Found in test_ruby/models/competitions/calculations/points_test.rb and 1 other location - About 6 hrs to fix
                test_ruby/models/competitions/calculations/points_test.rb on lines 112..132

                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

                Further Reading

                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"
                Severity: Minor
                Found in app/models/categories/name_normalization.rb - About 6 hrs to fix

                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
                Severity: Minor
                Found in test/controllers/admin/results_controller_test.rb - About 6 hrs to fix

                  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])
                  Severity: Minor
                  Found in app/controllers/people_controller.rb - About 5 hrs to fix

                  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
                  
                  
                  Severity: Major
                  Found in app/models/categories/matching.rb - About 5 hrs to fix

                    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
                    Severity: Minor
                    Found in test_ruby/models/competitions/calculations/place_test.rb - About 5 hrs to fix

                      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
                      
                      
                      Severity: Minor
                      Found in app/models/people/merge.rb - About 4 hrs to fix

                      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
                      Severity: Minor
                      Found in app/models/race.rb - About 4 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language