scottwillson/racing_on_rails

View on GitHub

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
Severity: Minor
Found in test/models/categories/best_match_in_test.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in test/models/events/event_test.rb - About 3 hrs to fix

      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?
      Severity: Minor
      Found in app/models/events/defaults.rb - About 3 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 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
      Severity: Major
      Found in test_ruby/models/calculations/v3/steps/place_by_place_test.rb - About 3 hrs to fix

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

          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+")
          Severity: Major
          Found in app/models/competitions/cross_crusade_callups.rb and 1 other location - About 3 hrs to fix
          app/models/competitions/cross_crusade_callups.rb on lines 38..55

          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

          Further Reading

          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+")
          Severity: Major
          Found in app/models/competitions/cross_crusade_callups.rb and 1 other location - About 3 hrs to fix
          app/models/competitions/cross_crusade_callups.rb on lines 19..36

          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

          Further Reading

          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,
          Severity: Major
          Found in test_ruby/models/categories/ability_test.rb - About 3 hrs to fix

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

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

                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)
                test_ruby/models/calculations/v3/steps/reject_more_than_maximum_events_test.rb on lines 206..221

                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

                Further Reading

                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)
                test_ruby/models/calculations/v3/steps/reject_more_than_maximum_events_test.rb on lines 168..183

                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

                Further Reading

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

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

                        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"),
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 41..51
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 86..96

                        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

                        Further Reading

                        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"),
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 66..76
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 86..96

                        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

                        Further Reading

                        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"),
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 41..51
                        test_ruby/models/competitions/calculations/select_results_test.rb on lines 66..76

                        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

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language