scottwillson/racing_on_rails

View on GitHub
app/models/race.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Race has 37 methods (exceeds 20 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 4 hrs to fix

    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

      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 calculate_members_only_places! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def calculate_members_only_places!
          # count up from zero
          last_members_only_place = 0
          # assuming first result starting at zero+one (better than sorting results twice?)
          last_result_place = 0
      Severity: Minor
      Found in app/models/race.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 place_results_by_time has 28 lines of code (exceeds 25 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 1 hr to fix

        Method find_associated_records has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def find_associated_records
            if category && (category.new_record? || category.changed?)
              if category.name.blank?
                self.category = nil
              else
        Severity: Minor
        Found in app/models/race.rb - About 55 mins 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 create_result_before has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_result_before(result_id)
            return results.create(place: "1") if results.empty?
        
            if result_id
              _results = results.sort
        Severity: Minor
        Found in app/models/race.rb - About 25 mins 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

        FIXME found
        Open

          # FIXME Handle people with only a number
        Severity: Minor
        Found in app/models/race.rb by fixme

        There are no issues that match your filters.

        Category
        Status