scottwillson/racing_on_rails

View on GitHub
app/models/result.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

    Method set_team has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_team
        if team&.new_record?
          team.updater = event
          if team.name.blank?
            self.team = nil
    Severity: Minor
    Found in app/models/result.rb - About 35 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 every_person_is_a_member? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def every_person_is_a_member?
        return true if RacingAssociation.current.exempt_team_categories.nil? || RacingAssociation.current.exempt_team_categories.include?(race.category.name)
    
        Result.where(race_id: race_id, place: place).where.not(id: id).find_each do |result|
          next unless result.person_id && !result.person.member?(date)
    Severity: Minor
    Found in app/models/result.rb - About 35 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 last_event? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def last_event?
        return false unless event&.parent
        return false unless event.parent.respond_to?(:parent)
        return true unless event.parent
    
    
    Severity: Minor
    Found in app/models/result.rb - About 35 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

    TODO found
    Open

      # TODO rationalize names
    Severity: Minor
    Found in app/models/result.rb by fixme

    There are no issues that match your filters.

    Category
    Status