scottwillson/racing_on_rails

View on GitHub
app/models/person.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Person has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class Person < ApplicationRecord
  LOGIN_FORMAT = /\A\w[\w.+\-_@ ]+\z/.freeze

  include Comparable
  include Export::People
Severity: Minor
Found in app/models/person.rb - About 3 hrs to fix

    File person.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "sentient_user/sentient_user"
    
    # Someone who either appears in race results or who is added as a member of a racing association
    #
    # Names are _not_ unique. In fact, there are many business rules about names. See Aliases and Names.
    Severity: Minor
    Found in app/models/person.rb - About 2 hrs to fix

      Method lic_check has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.lic_check(lic, lic_date)
          if lic_date && lic.to_i > 0
            case lic_date
            when Date, Time, DateTime
              lic_date > Time.zone.today ? "current" : "CHECK LIC!"
      Severity: Minor
      Found in app/models/person.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 team_name= has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def team_name=(value)
          if value.blank? || value == "N/A"
            self.team = nil
          else
            self.team = Team.find_by_name_or_alias(value)
      Severity: Minor
      Found in app/models/person.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 hometown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def hometown
          if city.blank?
            if state.blank?
              ""
            elsif state == RacingAssociation.current.state
      Severity: Minor
      Found in app/models/person.rb - About 45 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 find_associated_records has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_associated_records
          if team&.new_record?
            if team.name.blank? || (team.name == "N/A")
              self.team = nil
            else
      Severity: Minor
      Found in app/models/person.rb - About 45 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 city_state_zip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def city_state_zip
          if city.present?
            if state.present?
              "#{city}, #{state} #{zip}"
            else
      Severity: Minor
      Found in app/models/person.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: Any reason not to change this to last name, first name?
      Severity: Minor
      Found in app/models/person.rb by fixme

      There are no issues that match your filters.

      Category
      Status