scottwillson/racing_on_rails

View on GitHub

Showing 333 of 1,278 total issues

Method city_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def city_state
    if city.present?
      if state.present?
        "#{city}, #{state}"
      else
Severity: Minor
Found in app/models/event.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

Method select_results_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def select_results_for(field, results, limit, use_source_result_points)
    if limit == Competitions::Calculations::Calculator::UNLIMITED
      results
    else
      results.group_by { |r| [r.participant_id, r[field]] }
Severity: Minor
Found in app/models/competitions/calculations/select_results.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

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

Method s_to_time has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def s_to_time(string)
      if string.to_s.blank? || !string.to_s[/\d/]
        nil
      else
        string = string.tr(",", ".")
Severity: Minor
Found in app/models/results/times.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

Method export_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.export_all
    ::Alias.export
    ::Category.export
    ::Event.export
    ::Person.export
Severity: Minor
Found in app/models/export/base.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

Method add_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def add_name
      last_year = Time.zone.today.year - 1
      if name_was.present? && results_before_this_year? && names.none? { |name| name.year == last_year }
        name = names.build(name: name_was, year: last_year)
        name.first_name = first_name_was if respond_to?(:first_name)
Severity: Minor
Found in app/models/names/nameable.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

Method rental? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.rental?(number, discipline = Discipline[:road])
    return false if RacingAssociation.current.rental_numbers.nil?

    return true if number.blank?

Severity: Minor
Found in app/models/race_number.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

Method assign_member_from_imported_people has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def assign_member_from_imported_people(year)
    if @update_membership
      @member_from_imported_people = if year && year > Time.zone.today.year
                                       Time.zone.local(year).beginning_of_year.to_date
                                     else
Severity: Minor
Found in app/models/people_file.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

Method result_methods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def result_methods(row, _race)
      attributes = row.to_hash.dup
      custom_attributes = {}
      attributes.delete_if do |key, value|
        _key = key.to_s.to_sym
Severity: Minor
Found in app/models/results/results_file.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

Method apply_place has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_place(results, rules)
    results = apply_preliminary(results, rules)

    place = 1
    previous_result = nil
Severity: Minor
Found in app/models/competitions/calculations/place.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

Method find_or_create_event_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def find_or_create_event_category(source_result)
    return event_categories.first unless categories?

    source_result_category = source_result.event_category.category

Severity: Minor
Found in app/models/calculations/v3/calculators/categories.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

Method calculate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.calculate!(calculator)
          return calculator.event_categories if calculator.rules.disciplines.empty?

          calculator.event_categories.each do |category|
            category.results.each do |result|
Severity: Minor
Found in app/models/calculations/v3/steps/select_in_discipline.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

Method validate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def validate!
          raise(ArgumentError, "id must be a Numeric") if id && !id.is_a?(Numeric)
          raise(ArgumentError, "event_category is required") unless event_category
          raise(ArgumentError, "event_category must be an EventCategory, but was a #{event_category.class}") unless event_category.is_a?(EventCategory)
        end
Severity: Minor
Found in app/models/calculations/v3/models/source_result.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

Method show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def show
      @event = OregonWomensPrestigeSeries.find_for_year(@year) || OregonWomensPrestigeSeries.new
      @team_event = OregonWomensPrestigeTeamSeries.find_for_year(@year) || OregonWomensPrestigeTeamSeries.new

      request.session_options[:skip] = true
Severity: Minor
Found in app/controllers/competitions/oregon_womens_prestige_series_controller.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

Method validate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def validate!
          raise(ArgumentError, "Discipline is nil") unless discipline
          raise(ArgumentError, "discipline must be a Models::Discipline, but is a #{discipline.class}") unless discipline.is_a?(Models::Discipline)
          raise(ArgumentError, "end_date #{end_date} cannot be before date #{date} for event #{id}") if end_date && end_date < date
        end
Severity: Minor
Found in app/models/calculations/v3/models/event.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

Method include? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def include?(other, result_age = nil)
      return false unless other

      abilities_include?(other) &&
        ages_include?(other, result_age) &&
Severity: Minor
Found in app/models/categories/matching.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

Method labelled_check_box has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def labelled_check_box(method, text = nil, check_box_options = {})
      label_options = check_box_options.delete(:label) || {}
      if check_box_options[:editable] == false
        labelled_text method, @object.send(method) ? "Yes" : "No", text, check_box_options
      else
Severity: Minor
Found in app/helpers/racing_on_rails/form_builder.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

Method normalize_punctuation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.normalize_punctuation(name)
        if name
          # trailing punctuation
          name = name.gsub(%r{[/:.,"]\z}, "")

Severity: Minor
Found in app/models/categories/name_normalization.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

Method calculate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.calculate!(calculator)
          return calculator.event_categories unless calculator.rules.missing_result_penalty?

          calculator.source_results
                    .group_by(&:participant)
Severity: Minor
Found in app/models/calculations/v3/steps/add_missing_results_penalty.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

Method labelled_text_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def labelled_text_field(method, text = method.to_s.titleize, text_field_options = { class: "form-control" })
      label_options = text_field_options.delete(:label) || { class: "control-label col-sm-4" }
      editable = text_field_options.delete(:editable)
      if editable == false
        %(#{label(method, (text || method.to_s.titleize).to_s, label_options)} <div id="#{object_name}_#{method}">#{@object.send(method)}</div>).html_safe
Severity: Minor
Found in app/helpers/racing_on_rails/form_builder.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

Severity
Category
Status
Source
Language