scottwillson/racing_on_rails

View on GitHub

Showing 333 of 1,278 total issues

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

      def self.render(column, row)
        result = row.source
        text = row[column.key]
        return text unless result.team_id

Severity: Minor
Found in app/helpers/results/renderers/team_name_renderer.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 import has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def import
        case params[:commit]
        when "Cancel"
          session[:people_file_path] = nil
          redirect_to(action: "index")
Severity: Minor
Found in app/controllers/admin/people/import.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 require_same_person_or_administrator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def require_same_person_or_administrator
    return false unless require_current_person

    unless administrator? || (@person && current_person == @person)
      redirect_to unauthorized_path
Severity: Minor
Found in app/controllers/authorization.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_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def labelled_select(method, choices, options = {}, html_options = { class: "form-control" })
      label_options = options.delete(:label) || { class: "control-label col-sm-4" }
      text = label_options.delete(:text) if label_options
      if options[: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

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

      def self.replace_roman_numeral_categories(name)
        if name
          name = name.split.map do |token|
            case token
            when "I"
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 number has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def number(discipline_param, reload = false, year = nil)
      return nil if discipline_param.nil?

      year ||= RacingAssociation.current.year
      discipline_param = discipline_param.to_param if discipline_param.is_a?(Discipline)
Severity: Minor
Found in app/models/people/numbers.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)
          if calculator.rules.members_only?
            calculator.unrejected_results.each do |result|
              if calculator.year == 2021
                result.participant.id.in?(TEAMS_2021)
Severity: Minor
Found in app/models/calculations/v3/steps/select_members.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
      # Very explicit because we don't want to call something like 'eval' on a request parameter!
      case params[:type]
      when "rider_rankings"
        competition_class = RiderRankings
Severity: Minor
Found in app/controllers/competitions/competitions_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 split_camelcase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.split_camelcase(name)
        return name if name.nil?

        unless name.downcase == name || name.upcase == name
          name = name.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1 \2')
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 membership_dates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def membership_dates
      errors.add("member_from", "cannot be nil if member_to is not nil (#{member_to})") if member_to && !member_from

      errors.add("member_to", "cannot be nil if member_from is not nil (#{member_from})") if member_from && !member_to

Severity: Minor
Found in app/models/people/membership.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 racer_days_by_discipline has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.racer_days_by_discipline(years)
    chart_data = Discipline.all.map { |discipline| { name: discipline.name, data: [] } }
    years.each do |year|
      res = Result.joins(:event).where(events: { year: year, type: "SingleDayEvent" })
                  .where(competition_result: false, team_competition_result: false)
Severity: Minor
Found in app/services/stats.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 events_for_api has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def events_for_api(year)
    name = params[:name].try(:strip)
    year = RacingAssociation.current.effective_year.to_i if year.blank?

    if name.present?
Severity: Minor
Found in app/controllers/events_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 racers_by_discipline has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.racers_by_discipline(years)
    chart_data = Discipline.all.map { |discipline| { name: discipline.name, data: [] } }
    years.each do |year|
      res = Result.joins(:event).where(events: { year: year, type: "SingleDayEvent" })
                  .where(competition_result: false, team_competition_result: false)
Severity: Minor
Found in app/services/stats.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