scottwillson/racing_on_rails

View on GitHub

Showing 331 of 1,265 total issues

Class Person has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class Person < ApplicationRecord
  LOGIN_FORMAT = /\A\w[\w.+\-_@ ]+\z/.freeze

  include Comparable
  include Export::People
Severity: Minor
Found in app/models/person.rb - About 3 hrs to fix

    File schedule_controller_test.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "test_helper"
    
    # :stopdoc:
    class ScheduleControllerTest < ActionController::TestCase #:nodoc: all
      test "index" do
    Severity: Minor
    Found in test/controllers/schedule_controller_test.rb - About 2 hrs to fix

      Method event_params has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def event_params
            _params = params.require(:event).permit(
              :additional_race_price,
              :all_events_discount,
              :atra_points_series,
      Severity: Major
      Found in app/controllers/admin/events_controller.rb - About 2 hrs to fix

        File person.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "sentient_user/sentient_user"
        
        # Someone who either appears in race results or who is added as a member of a racing association
        #
        # Names are _not_ unique. In fact, there are many business rules about names. See Aliases and Names.
        Severity: Minor
        Found in app/models/person.rb - About 2 hrs to fix

          File name_test.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "test_helper"
          
          module Categories
            # :stopdoc:
            class NameTest < ActiveSupport::TestCase
          Severity: Minor
          Found in test/models/categories/name_test.rb - About 2 hrs to fix

            File results_controller_test.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require "test_helper"
            
            # :stopdoc:
            class ResultsControllerTest < ActionController::TestCase
              def setup
            Severity: Minor
            Found in test/controllers/results_controller_test.rb - About 2 hrs to fix

              Method test_group_by_age has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def test_group_by_age
                      source_results = []
                      athena = Models::Category.new("Athena")
                      clydesdale = Models::Category.new("Clydesdale")
                      men_5 = Models::Category.new("Men 5")

                Method receive has 69 lines of code (exceeds 25 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: Major
                Found in app/models/mailing_list_mailer.rb - About 2 hrs to fix

                  File map_source_results_to_results_test.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require_relative "../v3"
                  
                  module Calculations
                    module V3
                      # :stopdoc:

                    Function exports has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports = function(api) {
                      var validEnv = ['development', 'test', 'production']
                      var currentEnv = api.env()
                      var isDevelopmentEnv = api.env('development')
                      var isProductionEnv = api.env('production')
                    Severity: Major
                    Found in babel.config.js - About 2 hrs to fix

                      File events_controller.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Admin
                        # Show Schedule, add and edit Events, edit Results for Events. Promoters can view and edit their own events. Promoters can edit
                        # fewer fields than administrators.
                        class EventsController < Admin::AdminController
                          before_action :assign_event, only: %i[edit update]
                      Severity: Minor
                      Found in app/controllers/admin/events_controller.rb - About 2 hrs to fix

                        Class CalculatorTest has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                            class CalculatorTest < CalculationsTest
                              def test_calculate_with_no_source_results
                                assert_equal [], Calculator.calculate([])
                              end
                        
                        
                        Severity: Minor
                        Found in test_ruby/models/competitions/calculations/calculator_test.rb - About 2 hrs to fix

                          Method test_last_result_should_break_tie_different_dates has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def test_last_result_should_break_tie_different_dates
                                  source_results = [
                                    result(points: 355, participant_id: 1, scores: [
                                             { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                                             { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                          Severity: Major
                          Found in test_ruby/models/competitions/calculations/place_test.rb - About 2 hrs to fix

                            Method merge has 62 lines of code (exceeds 25 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: Major
                            Found in app/models/people/merge.rb - About 2 hrs to fix

                              Method person_params has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def person_params
                                    params.require(:person).permit(
                                      :administrator,
                                      :billing_city,
                                      :billing_country_code,
                              Severity: Major
                              Found in app/controllers/admin/people_controller.rb - About 2 hrs to fix

                                File place_test.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                require_relative "../../v3"
                                
                                module Calculations
                                  module V3
                                    module Steps
                                Severity: Minor
                                Found in test_ruby/models/calculations/v3/steps/place_test.rb - About 2 hrs to fix

                                  Method update_people has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def update_people
                                        expir_date = Date.new(Time.zone.today.year, 12, 31)
                                        people_updated = []
                                        @members_list.each do |memusac|
                                          # get the parameters in a nice format
                                  Severity: Minor
                                  Found in app/models/results/usac_file.rb - About 2 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 place_results_by_time has a Cognitive Complexity of 18 (exceeds 5 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 2 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 ages_from_name has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def ages_from_name(name)
                                        if name[/\d{3}-\d{3}/]
                                          age_range_match = /(\d{3})-(\d{3})/.match(name)
                                          ages_begin = age_range_match[1].to_i / team_size(name)
                                          ages_end = ((age_range_match[2].to_i + 1) / team_size(name)) - 1
                                  Severity: Minor
                                  Found in app/models/categories/ages.rb - About 2 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 tree_select has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def tree_select(categories, model, name, selected = 0, allow_root = true, level = 0, init = true)
                                      html = +""
                                      if init
                                        html << "<select class=\"form-control\" name=\"#{model}[#{name}]\" id=\"#{model}_#{name}\">\n"
                                        if allow_root
                                  Severity: Minor
                                  Found in app/helpers/admin/article_categories_helper.rb - About 2 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language