scottwillson/racing_on_rails

View on GitHub

Showing 333 of 1,278 total issues

Method index has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def index
      if params[:key]
        year = params[:year] || Time.zone.today.year
        calculation = Calculations::V3::Calculation.find_by(key: params[:key], year: year)

Severity: Minor
Found in app/controllers/calculations/results_controller.rb - About 1 hr to fix

    Method test_place_many has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def test_place_many
              category = Models::Category.new("Masters Men")
              rules = Rules.new(category_rules: [Models::CategoryRule.new(category)])
              calculator = Calculator.new(rules: rules, source_results: [])
              event_category = calculator.event_categories.first
    Severity: Minor
    Found in test_ruby/models/calculations/v3/steps/place_test.rb - About 1 hr to fix

      Method test_calculate_team_results_best_3_for_event has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def test_calculate_team_results_best_3_for_event
              source_results = [
                { event_id: 1, race_id: 1, participant_id: 1, place: 107 },
                { event_id: 1, race_id: 1, participant_id: 1, place: 7 },
                { event_id: 1, race_id: 1, participant_id: 2, place: 1 },
      Severity: Minor
      Found in test_ruby/models/competitions/calculations/calculator_test.rb - About 1 hr to fix

        Method test_fewest_points_wins has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def test_fewest_points_wins
                  category = Models::Category.new("Masters Men")
                  rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], place_by: "fewest_points")
                  calculator = Calculator.new(rules: rules, source_results: [])
                  event_category = calculator.event_categories.first
        Severity: Minor
        Found in test_ruby/models/calculations/v3/steps/place_test.rb - About 1 hr to fix

          Method best_match_by_age_in has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def best_match_by_age_in(event_categories, result_age = nil)
                debug "Category#best_match_by_age_in for #{name}, #{result_age} in #{event_categories.map(&:name).join(', ')}"
          
                candidate_categories = event_categories.dup
          
          
          Severity: Minor
          Found in app/models/categories/matching.rb - About 1 hr to fix

            Method test_calculate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def test_calculate
                      category = Models::Category.new("Masters Men")
                      rules = Rules.new
                      calculator = Calculator.new(rules: rules, source_results: [])
                      event_category = calculator.event_categories.first
            Severity: Minor
            Found in test_ruby/models/calculations/v3/steps/assign_team_sizes_test.rb - About 1 hr to fix

              Method test_merge_sort_preserves_order has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def test_merge_sort_preserves_order
                  king_hearts   = Card.new("king", "hearts")
                  king_diamonds = Card.new("king", "diamonds")
                  king_spades   = Card.new("king", "spades")
                  king_clubs    = Card.new("king", "clubs")
              Severity: Minor
              Found in test_ruby/lib/enumerable_test.rb - About 1 hr to fix

                Method test_remove_results_from_other_calculations has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def test_remove_results_from_other_calculations
                          category = Models::Category.new("Women")
                          rules = Rules.new(
                            category_rules: [Models::CategoryRule.new(category)],
                            disciplines: [Models::Discipline.new("Road")]

                  Method mtb_categories_for has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def mtb_categories_for(race)
                        return [] unless race.category
                  
                        case race.category.name
                        when "Senior Men"
                  Severity: Minor
                  Found in app/models/competitions/overall_bar.rb - About 1 hr to fix

                    Method date_of_birth= has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def date_of_birth=(value)
                          value = case value
                                  when String
                                    if value[%r{^\d\d/\d\d/\d\d$}]
                                      value.gsub %r{(\d+)/(\d+)/(\d+)}, '19\3/\1/\2'
                    Severity: Minor
                    Found in app/models/people/ages.rb - About 1 hr to fix

                      Method category_names has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def category_names
                              [
                                "Athena",
                                "Category 1/2 35+ Men",
                                "Category 1/2 35+ Women",
                      Severity: Minor
                      Found in app/models/competitions/grand_prix_brad_ross/common.rb - About 1 hr to fix

                        Method test_missing_result_penalty has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def test_missing_result_penalty
                                source_results = [
                                  { event_id: 1, participant_id: 10, place: 2, race_id: 100 },
                                  { event_id: 1, participant_id: 10, place: 4, race_id: 100 },
                                  { event_id: 1, participant_id: 20, place: 5, race_id: 100 },
                        Severity: Minor
                        Found in test_ruby/models/competitions/calculations/calculator_test.rb - About 1 hr to fix

                          Method place_results_by_time has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def place_results_by_time
                              _results = results.to_a.sort do |x, y|
                                if x.laps && y.laps && x.laps != y.laps
                                  y.laps <=> x.laps
                                elsif x.time
                          Severity: Minor
                          Found in app/models/race.rb - About 1 hr to fix

                            Method find has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def self.find(params)
                                  query = if RacingAssociation.current.include_multiday_events_on_schedule?
                                            Event.where(parent_id: nil).where.not(type: "Event")
                                          else
                                            Event.where(type: "SingleDayEvent")
                            Severity: Minor
                            Found in app/models/schedule/schedule.rb - About 1 hr to fix

                              Method categories_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def categories_for(race)
                                      # Really should remove all other top-level categories and their descendants?
                                      cats = [race.category] + race.category.descendants
                              
                                      if race.category.name == "Masters Men"
                              Severity: Minor
                              Found in app/models/competitions/bars/categories.rb - About 1 hr 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 adjust_times has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def adjust_times
                                    races_created_for_competition.each do |race|
                                      next if race.event.discipline != "Time Trial"
                              
                                      distances = race.results.map(&:distance).compact.select(&:positive?)
                              Severity: Minor
                              Found in app/models/competitions/races.rb - About 1 hr 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 date_range_s has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def date_range_s(format = :short)
                                  return date.year if all_year?
                              
                                  if format == :long
                                    if start_date == end_date
                              Severity: Minor
                              Found in app/models/multi_day_event.rb - About 1 hr 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 <=> has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def <=>(other)
                                    # Respect eql?
                                    return 0 if id.present? && (id == other&.id)
                              
                                    # Figure out the major position by place first, then break it down further if needed
                              Severity: Minor
                              Found in app/models/results/comparison.rb - About 1 hr 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 team_name= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def team_name=(value)
                                  if value.blank? || value == "N/A"
                                    self.team = nil
                                  else
                                    self.team = Team.find_by_name_or_alias(value)
                              Severity: Minor
                              Found in app/models/person.rb - About 1 hr 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 map_source_results_to_results has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def map_source_results_to_results(source_results)
                                      source_results.each do |source_result|
                                        source_result.reject("not_calculation_category") unless in_calculation_category?(source_result.category, source_result.age)
                              
                                        event_category = find_or_create_event_category(source_result)
                              Severity: Minor
                              Found in app/models/calculations/v3/calculator.rb - About 1 hr 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

                              Severity
                              Category
                              Status
                              Source
                              Language