scottwillson/racing_on_rails

View on GitHub

Showing 331 of 1,265 total issues

File calculator_test.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "../../../../app/models/competitions/calculations/calculator"
require_relative "calculations_test"

# :stopdoc:
# TODO remove noisy member setup
Severity: Minor
Found in test_ruby/models/competitions/calculations/calculator_test.rb - About 4 hrs to fix

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

        def categories_for(race)
          categories = super(race)
    
          if year < 2016
            categories << Category.find_or_create_by(name: "Masters Men A 40+") if race.name == "Masters 35+ A"
    Severity: Minor
    Found in app/models/competitions/cross_crusade_callups.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

    File upcoming_test.rb has 332 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require File.expand_path("../../test_helper", __dir__)
    
    # :stopdoc:
    class UpcomingTest < ActiveSupport::TestCase
      test "different dates" do
    Severity: Minor
    Found in test/models/events/upcoming_test.rb - About 4 hrs to fix

      Method import has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def import(update_membership, year = nil)
          ActiveSupport::Notifications.instrument(
            "import.people_file.racing_on_rails", update_membership: update_membership, import_file: import_file, rows: table.rows.size
          ) do
            @update_membership = update_membership
      Severity: Minor
      Found in app/models/people_file.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

      Class Result has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Result < ApplicationRecord
        UNPLACED = 999_999
      
        before_save :set_associated_records
      
      
      Severity: Minor
      Found in app/models/result.rb - About 3 hrs to fix

        Method normalize_spelling has 92 lines of code (exceeds 25 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: Major
        Found in app/models/categories/name_normalization.rb - About 3 hrs to fix

          File set_associations_test.rb has 320 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "test_helper"
          
          # :stopdoc:
          class SetAssociationsTest < ActiveSupport::TestCase
            setup :number_issuer
          Severity: Minor
          Found in test/models/results/set_associations_test.rb - About 3 hrs to fix

            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

                    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

                          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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language