scottwillson/racing_on_rails

View on GitHub

Showing 331 of 1,265 total issues

Consider simplifying this complex logical expression.
Open

            elsif token[/\Amaster\z/i] || token[/\Amas\z/i] || token[/\Amstr?\z/i] || token[/\Amaster's\z/i] ||
                  token[/\Amast.?\z/i] || token[/\Amaasters\z/i] || token[/\Amastes\z/i] || token[/\Amastres\z/i] ||
                  token[/\Amater\z/i] || token[/\Amaser\z/i] || token[/\Amst\z/i]

              "Masters"
Severity: Critical
Found in app/models/categories/name_normalization.rb - About 2 hrs to fix

    Function makeEditable has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function makeEditable() {
      jQuery('.editable').editable(
        function(value, settings) {
          var element = jQuery(this);
          element.find("input").attr("disabled", "disabled");
    Severity: Major
    Found in app/assets/javascripts/application.js - About 2 hrs to fix

      Method test_set_gender_from_name has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def test_set_gender_from_name
            {
              "Athena" => "F",
              "Beginner Men" => "M",
              "Beginner Women" => "F",
      Severity: Major
      Found in test_ruby/models/categories/gender_test.rb - About 2 hrs to fix

        Method find_all_for_export has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.find_all_for_export(date = Time.zone.today, include_people = "members_only")
                association_number_issuer_id = NumberIssuer.find_by(name: RacingAssociation.current.short_name).id
                case include_people
                when "members_only"
                  where_clause = "WHERE (people.member_to >= '#{date}')"
        Severity: Major
        Found in app/models/people/export.rb - About 2 hrs to fix

          Method show has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def show
                discipline = Discipline[params["discipline"]]
                if discipline.nil?
                  flash.now[:warn] = "Could not find discipline \'#{params['discipline']}\'"
                  return render(:show)
          Severity: Minor
          Found in app/controllers/competitions/bar_controller.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 date_of_birth= has a Cognitive Complexity of 17 (exceeds 5 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 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 assert_same_elements has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def assert_same_elements(expected, actual, message = "")
                return if expected.nil? && actual.nil?
          
                if !expected.nil? && actual.nil?
                  flunk "#{message}\n Expected #{expected} but was nil"
          Severity: Minor
          Found in lib/test/enumerable_assertions.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 category_names has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def category_names
                if year < 2016
                  [
                    "Athena",
                    "Beginner Men",
          Severity: Major
          Found in app/models/competitions/cross_crusade_team_competition.rb - About 2 hrs to fix

            Class RacingAssociation has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class RacingAssociation < ApplicationRecord
              ADMIN_TABS = %i[schedule first_aid people teams velodromes categories article_categories articles pages].freeze
            
              # TODO: bmx_numbers? Shouldn"t this be in disciplines?
            
            
            Severity: Minor
            Found in app/models/racing_association.rb - About 2 hrs to fix

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

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

                Method test_min_max has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def test_min_max
                        category = Models::Category.new("Athena")
                        participant = Models::Participant.new(0)
                        source_events = []
                        source_results = []
                Severity: Major
                Found in test_ruby/models/calculations/v3/calculator_test.rb - About 2 hrs to fix

                  Function bindSelectModal has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function bindSelectModal() {
                    jQuery('button.select-modal').each(function(index, element) {
                      var button = jQuery(element);
                      var method = button.data('method');
                      var objectName = button.data('object-name');
                  Severity: Major
                  Found in app/assets/javascripts/select_modal.js - About 2 hrs to fix

                    Method calculate! has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def calculate!
                            @logger.debug "Calculator#calculate! source_results: #{source_results.size} rules: #{rules.to_h}"
                    
                            if rules.place_by == "place"
                              # place before assigning points
                    Severity: Major
                    Found in app/models/calculations/v3/calculator.rb - About 2 hrs to fix

                      Method source_results_query has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def source_results_query(race)
                            query = Result
                                    .select(
                                      "distinct results.id as id",
                                      "1 as multiplier",
                      Severity: Minor
                      Found in app/models/competitions/competition.rb - About 2 hrs to fix

                        Method test_group_by_category has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def test_group_by_category
                                source_results = []
                                masters_men = Models::Category.new("Masters Men")
                                junior_women = Models::Category.new("Junior Women")
                                rejected_category = Models::Category.new("Category 3")

                          Method racing_association_params has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def racing_association_params
                              params.require(:racing_association).permit(
                                :add_members_from_results,
                                :administrator_tabs,
                                :allow_iframes,
                          Severity: Minor
                          Found in app/controllers/racing_associations_controller.rb - About 1 hr to fix

                            Method event has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def event
                                if params[:key]
                                  year = params[:year] || RacingAssociation.current.effective_year
                                  calculation = Calculations::V3::Calculation.find_by(key: params[:key], year: year)
                            
                            
                            Severity: Minor
                            Found in app/controllers/results_controller.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 normalize_case has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def self.normalize_case(name)
                                    if name
                                      name = name.split.map do |token|
                                        # Calling RacingAssociation.current triggers an infinite loop
                                        if token[/of/i]
                            Severity: Minor
                            Found in app/models/categories/name_normalization.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 render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def self.render(column, row)
                                    time = row[key(column)]
                                    return nil if time.nil?
                                    return time if time.is_a?(String) || time.is_a?(DateTime)
                            
                            
                            Severity: Minor
                            Found in app/helpers/results/renderers/time_renderer.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 index has a Cognitive Complexity of 15 (exceeds 5 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

                            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