scottwillson/racing_on_rails

View on GitHub

Showing 333 of 1,278 total issues

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

    def Person.export_data
      basename = "people.csv"
      path = Base.tmp_path basename
      path.unlink if path.exist?
      FileUtils.mkdir_p path.dirname unless path.dirname.exist?
Severity: Minor
Found in app/models/export/people.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 <=> has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def <=>(other)
      return -1 if other.nil? || !other

      if date
        if other.date
Severity: Minor
Found in app/models/events/comparison.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 save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.save(post, mailing_list)
    post.subject = Post.normalize_subject(post.subject, mailing_list.subject_line_prefix)

    transaction do
      original = find_original(post)
Severity: Minor
Found in app/models/post.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 validate! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def validate!
          raise(ArgumentError, "category is required") unless category
          raise(ArgumentError, "category must be a Models::Category, but is a #{category.class}") unless category.is_a?(Models::Category)
          raise(ArgumentError, "discipline must be a Models::Discipline, but is a #{discipline.class}") unless discipline.nil? || discipline.is_a?(Models::Discipline)
          raise(ArgumentError, "event must be a Models::Event, but is a #{event.class}") unless event.nil? || event.is_a?(Models::Event)
Severity: Minor
Found in app/models/calculations/v3/models/event_category.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 cleanup_names! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def self.cleanup_names!
        # Whitespace cleanup deletes duplicate categories
        Category.all.find_each do |category|
          normalized_name = Category.normalized_name(category.name)
          next unless category.name != normalized_name
Severity: Minor
Found in app/models/categories/cleanup.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 validate! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def validate!
          raise(ArgumentError, "participant is required") unless participant
          raise(ArgumentError, "source_results is required") unless source_results
          raise(ArgumentError, "source_results must be an Enumerable") unless source_results.is_a?(Enumerable)
          raise(ArgumentError, "source_results cannot be empty") if source_results.empty?
Severity: Minor
Found in app/models/calculations/v3/models/calculated_result.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 require_administrator_or_promoter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def require_administrator_or_promoter
    return false unless require_current_person

    unless administrator? ||
           (@event && (current_person == @event.promoter || @event.editors.include?(current_person))) ||
Severity: Minor
Found in app/controllers/authorization.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 tree_select has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def tree_select(categories, model, name, selected = 0, allow_root = true, level = 0, init = true)
Severity: Major
Found in app/helpers/admin/article_categories_helper.rb - About 50 mins to fix

    Method calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
    Found in app/models/competitions/bar.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 major_place has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def major_place
          if numeric_place?
            0
          elsif rejected?
            5
    Severity: Minor
    Found in app/models/results/comparison.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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.calculate!(year = Time.zone.today.year)
            ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
              transaction do
                series = WeeklySeries.where(name: parent_event_name).year(year).first
    
    
    Severity: Minor
    Found in app/models/competitions/portland_short_track_series/team_standings.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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.calculate!(year = Time.zone.today.year)
          ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
            transaction do
              parent = ::MultiDayEvent.year(year).where(name: parent_event_name).first
    
    
    Severity: Minor
    Found in app/models/competitions/overall.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 set_person has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_person
          if person&.new_record?
            person.updater = event
            if person.name.blank?
              self.person = nil
    Severity: Minor
    Found in app/models/results/people.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_person_by_number has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_person_by_number(matches)
          if number.present?
            if matches.size > 1
              # use number to choose between same names
              RaceNumber.find_all_by_value_and_event(number, event).each do |race_number|
    Severity: Minor
    Found in app/models/results/people.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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.calculate!(year = Time.zone.today.year)
          ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
            transaction do
              series = Series.where(name: "Cyclocross Crusade").year(year).first
    
    
    Severity: Minor
    Found in app/models/competitions/cross_crusade_team_competition.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 compare_by_highest_place has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def compare_by_highest_place(other)
          scores_by_place = scores.sort_by(&:source_result)
          other_scores_by_place = other.scores.sort_by(&:source_result)
          max_results = [scores_by_place.size, other_scores_by_place.size].max
          return 0 if max_results == 0
    Severity: Minor
    Found in app/models/results/comparison.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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). 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: Minor
    Found in app/models/competitions/mbra_bar.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 calculate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.calculate!(year = Time.zone.today.year)
          ActiveSupport::Notifications.instrument "calculate.#{name}.competitions.racing_on_rails" do
            transaction do
              series = WeeklySeries.where(name: parent_event_name).year(year).first
    
    
    Severity: Minor
    Found in app/models/competitions/blind_date_at_the_dairy_team_competition.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

    Severity
    Category
    Status
    Source
    Language