vol1ura/Sat_9am_5km

View on GitHub

Showing 39 of 39 total issues

Complex method ClubsController#show (25.7)
Open

  def show
    @club = Club.find(params[:id])
    @count_results =
      Athlete
        .left_joins(results: :activity)
Severity: Minor
Found in app/controllers/clubs_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method Athlete::duplicates (25.4)
Open

  def self.duplicates
    sql = <<~SQL.squish
      SELECT id, parkrun_code, fiveverst_code, l_name FROM (
        SELECT id, parkrun_code, fiveverst_code, l_name, COUNT(id) OVER (PARTITION BY l_name) AS cnt FROM (
          SELECT *, array(SELECT unnest(string_to_array(LOWER(name), ' ')) ORDER BY 1) AS l_name FROM athletes
Severity: Minor
Found in app/models/athlete.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(activity_id)
    activity = Activity.published.find activity_id

    activity.results.where('personal_best = TRUE OR first_run = TRUE').update_all(personal_best: false, first_run: false) # rubocop:disable Rails/SkipsModelValidations

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

Complex method ClubsController#search (24.7)
Open

  def search
    @clubs =
      Club
        .joins(:country)
        .where(country: { code: top_level_domain })
Severity: Minor
Found in app/controllers/clubs_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

  def call
    Rails.cache.fetch('vk_photo_url_list', expires_in: 3.hours) do
      album_landscape_photos.sample(@num).map do |photo|
        photo[:sizes].max_by { |p| p[:width] > MAX_WIDTH ? 0 : p[:width] }[:url]
      end
Severity: Minor
Found in app/services/vk_photos.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def call
        return unless @user&.telegram_id

        notify(Rails.env.local? ? ENV['DEV_TELEGRAM_ID'] : @user.telegram_id)
      rescue StandardError => e
Severity: Minor
Found in app/services/telegram/notification/newsletter.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

Complex method ClubsController#index (22.6)
Open

  def index
    @clubs = Athlete
      .joins(club: :country)
      .where(country: { code: top_level_domain })
      .group(:club)
Severity: Minor
Found in app/controllers/clubs_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method EventsController#search (22.3)
Open

  def search
    @events =
      Event
        .in_country(top_level_domain)
        .without_friends
Severity: Minor
Found in app/controllers/events_controller.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method index(download_links)::column#athlete (21.4)
Open

    column :athlete do |r|
      if r.athlete
        external_link_to r.athlete.name.presence || t('common.without_name'), admin_athlete_path(r.athlete)
      else
        external_link_to t('common.without_token'), new_admin_athlete_path(result_id: r.id)
Severity: Minor
Found in app/admin/results.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method member_action#insert_above (21.3)
Open

  member_action :insert_above, method: :post, if: proc { can? :manage, Result } do
    resource.insert_new_result_above!
    redirect_to collection_path, notice: t('active_admin.results.result_successfully_appended', position: resource.position)
  rescue StandardError => e
    Rollbar.error e
Severity: Minor
Found in app/admin/results.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

  def perform(activity_id, with_expiration: false)
    expire_trophies if with_expiration
    activity = Activity.published.find activity_id

    activity.participants.where.not(id: five_plus_badge.trophies.select(:athlete_id)).find_each do |athlete|
Severity: Minor
Found in app/jobs/five_plus_awarding_job.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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def destroy
      if resource.user_id
        flash[:error] = t '.cannot_delete_registered'
      elsif resource.results.exists? || Volunteer.exists?(athlete: resource)
        flash[:error] = t '.cannot_delete_participant'
Severity: Minor
Found in app/admin/athletes.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def call
      return unless @user.image.attached?
      return if Vips::Image.new_from_file(image_file.path).size.max <= MAX_DIMENSION && image_file.size <= MAX_SIZE

      compressed_image_file = ImageProcessing::Vips
Severity: Minor
Found in app/services/users/image_compressor.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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(activity_id, badge_id)
    activity = Activity.published.find activity_id
    badge = Badge.find badge_id
    return unless badge.funrun_kind? || badge.jubilee_participating_kind?

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

  def update
    if current_user.update(user_params)
      if params[:delete_image]
        current_user.image.purge
      elsif params[:user][:image] && current_user.image.attached?
Severity: Minor
Found in app/controllers/users_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

Complex method Parkzhrun::AthleteFinder#find_athlete_by_info (20.5)
Open

    def find_athlete_by_info
      @athlete = Athlete.find_by(id: athlete_info[:s95_id] - Athlete::SAT_9AM_5KM_BORDER) if athlete_info[:s95_id]
      @athlete ||= Athlete.find_by(parkrun_code: athlete_info[:parkrun_id]) if athlete_info[:parkrun_id]
      @athlete ||= Athlete.find_by(fiveverst_code: athlete_info[:five_verst_id]) if athlete_info[:five_verst_id]
      @athlete

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method sidebar#Управление наградой (20.2)
Open

  sidebar 'Управление наградой', only: :show do
    para link_to 'Обладатели', admin_badge_trophies_path(resource)
    h3 'Предпросмотр'
    image_tag resource.image.variant(:web), class: 'img-badge' if resource.image.attached?
Severity: Minor
Found in app/admin/badges.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method VkPhotos#call (20.1)
Open

  def call
    Rails.cache.fetch('vk_photo_url_list', expires_in: 3.hours) do
      album_landscape_photos.sample(@num).map do |photo|
        photo[:sizes].max_by { |p| p[:width] > MAX_WIDTH ? 0 : p[:width] }[:url]
      end
Severity: Minor
Found in app/services/vk_photos.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method main#scoped_collection (20.0)
Open

    def scoped_collection
      if current_user.admin?
        end_of_association_chain
      else
        event_ids = current_user.permissions.where(subject_class: 'Volunteer').pluck(:event_id).compact
Severity: Minor
Found in app/admin/volunteers.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Severity
Category
Status
Source
Language