scottwillson/racing_on_rails

View on GitHub

Showing 1,265 of 1,265 total issues

File teams_controller_test.rb has 368 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require File.expand_path("../../test_helper", __dir__)

module Admin
  # :stopdoc:
  class TeamsControllerTest < ActionController::TestCase
Severity: Minor
Found in test/controllers/admin/teams_controller_test.rb - About 4 hrs to fix

    Method get_expected_races has 118 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def get_expected_races
          races = []
    
          race = Race.new(category: Category.new(name: "Senior Men Pro/1/2/3"))
          race.results << Result.new(place: "1", first_name: "Evan", last_name: "Elken", number: "154", license: "999999999", team_name: "Jittery Joe's", points: "23.0")
    Severity: Major
    Found in test/models/results/results_file_test.rb - About 4 hrs to fix

      File login_test.rb has 362 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require File.expand_path("../../test_helper", __dir__)
      
      # :stopdoc:
      class LoginTest < ActionController::TestCase
        tests PeopleController
      Severity: Minor
      Found in test/controllers/people/login_test.rb - About 4 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          test "import mbra csv" do
            FactoryBot.create(:discipline)
            FactoryBot.create(:discipline, name: "Criterium")
            Team.create!(id: 1_200_000, name: "Bike Team")
            Schedule::Schedule.import(file_fixture("schedule/comma-delimited.csv"))
        Severity: Major
        Found in test/models/schedule/schedule_test.rb and 1 other location - About 4 hrs to fix
        test/models/schedule/schedule_test.rb on lines 347..378

        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 157.

        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

          test "import mbra tabbed" do
            FactoryBot.create(:discipline)
            FactoryBot.create(:discipline, name: "Criterium")
            Team.create!(id: 1_200_000, name: "Bike Team")
            Schedule::Schedule.import(file_fixture("schedule/tab-delimited.txt"))
        Severity: Major
        Found in test/models/schedule/schedule_test.rb and 1 other location - About 4 hrs to fix
        test/models/schedule/schedule_test.rb on lines 381..412

        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 157.

        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

        File schedule_test.rb has 356 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require File.expand_path("../../test_helper", __dir__)
        
        # :stopdoc:
        class ScheduleTest < ActiveSupport::TestCase
          test "create" do
        Severity: Minor
        Found in test/models/schedule/schedule_test.rb - About 4 hrs to fix

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      result(place: 2, participant_id: 2, points: 355, tied: nil, scores: [
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 19) },
            Severity: Major
            Found in test_ruby/models/competitions/calculations/place_test.rb and 1 other location - About 4 hrs to fix
            test_ruby/models/competitions/calculations/place_test.rb on lines 300..313

            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 144.

            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

                      result(place: 1, participant_id: 1, points: 355, tied: nil, scores: [
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 1, points: 30, date: Date.new(2015, 10, 3) },
            Severity: Major
            Found in test_ruby/models/competitions/calculations/place_test.rb and 1 other location - About 4 hrs to fix
            test_ruby/models/competitions/calculations/place_test.rb on lines 314..327

            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 144.

            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

                      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) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 1, points: 30, date: Date.new(2015, 10, 3) },
            Severity: Major
            Found in test_ruby/models/competitions/calculations/place_test.rb and 1 other location - About 4 hrs to fix
            test_ruby/models/competitions/calculations/place_test.rb on lines 284..297

            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 140.

            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

                      result(points: 355, participant_id: 2, scores: [
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 13) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 2, points: 29, date: Date.new(2015, 9, 13) },
                               { numeric_place: 1, points: 30, date: Date.new(2015, 9, 19) },
            Severity: Major
            Found in test_ruby/models/competitions/calculations/place_test.rb and 1 other location - About 4 hrs to fix
            test_ruby/models/competitions/calculations/place_test.rb on lines 270..283

            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 140.

            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

            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

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                      def test_highest_place_in_last_race_breaks_tie
                        source_results = [
                          result(points: 27, participant_id: 1, scores: [
                                   { numeric_place: 1, date: Date.new(2012, 10, 1) },
                                   { numeric_place: 2, date: Date.new(2012, 10, 8) }
                Severity: Major
                Found in test_ruby/models/competitions/calculations/place_test.rb and 2 other locations - About 3 hrs to fix
                test_ruby/models/competitions/calculations/place_test.rb on lines 96..119
                test_ruby/models/competitions/calculations/place_test.rb on lines 242..265

                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 128.

                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 3 locations. Consider refactoring.
                Open

                      def test_last_result_should_break_tie
                        source_results = [
                          result(points: 27, participant_id: 1, scores: [
                                   { numeric_place: 1, date: Date.new(2012, 10, 1) },
                                   { numeric_place: 2, date: Date.new(2012, 10, 19) }
                Severity: Major
                Found in test_ruby/models/competitions/calculations/place_test.rb and 2 other locations - About 3 hrs to fix
                test_ruby/models/competitions/calculations/place_test.rb on lines 96..119
                test_ruby/models/competitions/calculations/place_test.rb on lines 216..239

                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 128.

                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 3 locations. Consider refactoring.
                Open

                      def test_highest_result_breaks_tie
                        source_results = [
                          result(points: 27, participant_id: 1, scores: [
                                   { numeric_place: 1, date: Date.new(2012, 10, 1) },
                                   { numeric_place: 2, date: Date.new(2012, 10, 8) }
                Severity: Major
                Found in test_ruby/models/competitions/calculations/place_test.rb and 2 other locations - About 3 hrs to fix
                test_ruby/models/competitions/calculations/place_test.rb on lines 216..239
                test_ruby/models/competitions/calculations/place_test.rb on lines 242..265

                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 128.

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