scottwillson/racing_on_rails

View on GitHub

Showing 1,265 of 1,265 total issues

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

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

  test "road index" do
    FactoryBot.create(:discipline)
    FactoryBot.create(:mtb_discipline)
    year = 2006

Severity: Major
Found in test/controllers/schedule_controller_test.rb and 1 other location - About 2 hrs to fix
test/controllers/schedule_controller_test.rb on lines 246..274

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

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 "mtb list" do
    FactoryBot.create(:discipline)
    FactoryBot.create(:mtb_discipline)

    year = 2006
Severity: Major
Found in test/controllers/schedule_controller_test.rb and 1 other location - About 2 hrs to fix
test/controllers/schedule_controller_test.rb on lines 92..119

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

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 "mtb calendar as json" do
    FactoryBot.create(:discipline)
    FactoryBot.create(:mtb_discipline)
    SingleDayEvent.create!(
      name: "Banana Belt I",
Severity: Major
Found in test/controllers/schedule_controller_test.rb and 1 other location - About 2 hrs to fix
test/controllers/schedule_controller_test.rb on lines 295..320

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

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 "mtb index as json" do
    FactoryBot.create(:discipline)
    FactoryBot.create(:mtb_discipline)
    SingleDayEvent.create!(
      name: "Banana Belt I",
Severity: Major
Found in test/controllers/schedule_controller_test.rb and 1 other location - About 2 hrs to fix
test/controllers/schedule_controller_test.rb on lines 323..348

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

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

        def test_with_source_events_points_for_place_no_points
          category = Models::Category.new("Women")
          rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], source_event_keys: [:road_bar], points_for_place: [1, 2, 3])
          calculator = Calculator.new(rules: rules, source_results: [])
          event_category = calculator.event_categories.first
test_ruby/models/calculations/v3/steps/reject_no_points_test.rb on lines 82..96

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

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

        def test_with_source_events_points_for_place
          category = Models::Category.new("Women")
          rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], source_event_keys: [:road_bar], points_for_place: [1, 2, 3])
          calculator = Calculator.new(rules: rules, source_results: [])
          event_category = calculator.event_categories.first
test_ruby/models/calculations/v3/steps/reject_no_points_test.rb on lines 100..114

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

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

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

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

        def self.calculate!(year = Time.zone.today.year)
          ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
            transaction do
              year = year.to_i if year.is_a?(String)
              date = Date.new(year, 1, 1)
    Severity: Major
    Found in app/models/competitions/mbra_team_bar.rb and 1 other location - About 2 hrs to fix
    app/models/competitions/mbra_bar.rb on lines 13..41

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

    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

        def self.calculate!(year = Time.zone.today.year)
          ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
            transaction do
              year = year.to_i if year.is_a?(String)
              date = Date.new(year, 1, 1)
    Severity: Major
    Found in app/models/competitions/mbra_bar.rb and 1 other location - About 2 hrs to fix
    app/models/competitions/mbra_team_bar.rb on lines 8..35

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

    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

    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

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

                  def test_calculate_points_for_place_no_points
                    category = Models::Category.new("Women")
                    rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], points_for_place: [1, 2, 3])
                    calculator = Calculator.new(rules: rules, source_results: [])
                    event_category = calculator.event_categories.first
          test_ruby/models/calculations/v3/steps/reject_no_points_test.rb on lines 46..60
          test_ruby/models/calculations/v3/steps/reject_no_source_event_points_test.rb on lines 46..60

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

          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_calculate_points_for_place
                    category = Models::Category.new("Women")
                    rules = Rules.new(category_rules: [Models::CategoryRule.new(category)], points_for_place: [1, 2, 3])
                    calculator = Calculator.new(rules: rules, source_results: [])
                    event_category = calculator.event_categories.first
          test_ruby/models/calculations/v3/steps/reject_no_points_test.rb on lines 46..60
          test_ruby/models/calculations/v3/steps/reject_no_points_test.rb on lines 64..78

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

          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

          Severity
          Category
          Status
          Source
          Language