From 80c8bdf8eab2992a5cb4fb1eb9afbbd823b9525c Mon Sep 17 00:00:00 2001 From: Adrian Hirt Date: Thu, 28 Dec 2023 13:56:39 +0100 Subject: [PATCH] Comply to rubocop & haml-lin --- app/grids/admin/uploads.rb | 2 +- app/helpers/tournament_helper.rb | 4 ++-- app/models/application_record.rb | 2 +- app/models/concerns/encryptable.rb | 2 +- app/models/order.rb | 2 +- app/operations/admin/seat_map/load_seats.rb | 2 +- app/operations/admin/settings/update.rb | 2 +- app/operations/api/v1/event/index.rb | 2 +- app/operations/api/v1/news/index.rb | 2 +- app/operations/lan/seat_map/load_seats.rb | 2 +- app/operations/shop/order/cleanup_untouched.rb | 2 +- app/views/shop/orders/show.html.haml | 2 +- app/views/tournament_teams/index.html.haml | 2 +- app/views/tournament_teams/show.html.haml | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/grids/admin/uploads.rb b/app/grids/admin/uploads.rb index f8df252b..846f5610 100644 --- a/app/grids/admin/uploads.rb +++ b/app/grids/admin/uploads.rb @@ -33,7 +33,7 @@ class Uploads < ApplicationGrid scope.joins(file_attachment: :blob).where(blob: { content_type: value }) end - filter :uploaded_by, :enum, select: User.where(id: Upload.all.select(:user_id)).map { |user| [user.username, user.id] }.sort << ['-', 0], + filter :uploaded_by, :enum, select: User.where(id: Upload.select(:user_id)).map { |user| [user.username, user.id] }.sort << ['-', 0], include_blank: _('Form|Select|Show all') do |value, scope, _grid| if value == '0' scope.where(user_id: nil) diff --git a/app/helpers/tournament_helper.rb b/app/helpers/tournament_helper.rb index bfa72017..710c7eec 100644 --- a/app/helpers/tournament_helper.rb +++ b/app/helpers/tournament_helper.rb @@ -3,7 +3,7 @@ def format_match_score(match, relevant_team) show_score = match.away_score != 0 || match.home_score != 0 team = match.send(relevant_team) - score = match.send("#{relevant_team}_score").to_s + score = match.send(:"#{relevant_team}_score").to_s if match.draw? tag.span(class: 'text-warning') do @@ -26,7 +26,7 @@ def format_match_score_large(match, relevant_team) show_score = match.away_score != 0 || match.home_score != 0 team = match.send(relevant_team) - score = match.send("#{relevant_team}_score").to_s + score = match.send(:"#{relevant_team}_score").to_s # rubocop:disable Lint/DuplicateBranch if match.errors.any? diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 0de7c695..4229d1a9 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -15,7 +15,7 @@ def self.validates_boolean(attribute, **) def self.translate_enums defined_enums.each_key do |key| - define_method "humanized_#{key}" do + define_method :"humanized_#{key}" do _("#{self.class.name}|#{key}|#{send(key)}") end end diff --git a/app/models/concerns/encryptable.rb b/app/models/concerns/encryptable.rb index 150c75c6..19b562a4 100644 --- a/app/models/concerns/encryptable.rb +++ b/app/models/concerns/encryptable.rb @@ -3,7 +3,7 @@ module Encryptable class_methods do def encryptable_attribute(name, attributes = nil) - define_method "encrypted_#{name}" do + define_method :"encrypted_#{name}" do if attributes.nil? data = send(name) elsif attributes.is_a?(Array) diff --git a/app/models/order.rb b/app/models/order.rb index 67303887..33a8d245 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -132,7 +132,7 @@ def remove_address fail 'Wrong status' unless completed? SHIPPING_ADDRESS_FIELDS.each do |field| - public_send("#{field}=", nil) + public_send(:"#{field}=", nil) end end diff --git a/app/operations/admin/seat_map/load_seats.rb b/app/operations/admin/seat_map/load_seats.rb index e7d8db52..399af62f 100644 --- a/app/operations/admin/seat_map/load_seats.rb +++ b/app/operations/admin/seat_map/load_seats.rb @@ -13,7 +13,7 @@ def data seats: [] } - seat_map.seats.includes(:seat_category, ticket: :assignee).each do |seat| + seat_map.seats.includes(:seat_category, ticket: :assignee).find_each do |seat| seat_data = { backendId: seat.id, seatCategoryId: seat.seat_category_id, diff --git a/app/operations/admin/settings/update.rb b/app/operations/admin/settings/update.rb index 7cc3b3ed..ea6b6d11 100644 --- a/app/operations/admin/settings/update.rb +++ b/app/operations/admin/settings/update.rb @@ -42,7 +42,7 @@ def perform entered_values[key] = value if config.valid? - AppConfig.send("#{key}=", value) + AppConfig.send(:"#{key}=", value) else model.errors.merge!(config.errors) end diff --git a/app/operations/api/v1/event/index.rb b/app/operations/api/v1/event/index.rb index 860e0ac9..3dd10743 100644 --- a/app/operations/api/v1/event/index.rb +++ b/app/operations/api/v1/event/index.rb @@ -7,7 +7,7 @@ class Index < RailsOps::Operation def result result = [] - Queries::Event::FetchFutureEvents.run.where(published: true).each do |event| + Queries::Event::FetchFutureEvents.run.where(published: true).find_each do |event| result << { title: event.title, description: event.description, diff --git a/app/operations/api/v1/news/index.rb b/app/operations/api/v1/news/index.rb index 7db2095c..4c0100d5 100644 --- a/app/operations/api/v1/news/index.rb +++ b/app/operations/api/v1/news/index.rb @@ -7,7 +7,7 @@ class Index < RailsOps::Operation def result result = [] - :: NewsPost.where(published: true).each do |news_post| + :: NewsPost.where(published: true).find_each do |news_post| result << { title: news_post.title, content: news_post.content, diff --git a/app/operations/lan/seat_map/load_seats.rb b/app/operations/lan/seat_map/load_seats.rb index ca0028cd..be08de7c 100644 --- a/app/operations/lan/seat_map/load_seats.rb +++ b/app/operations/lan/seat_map/load_seats.rb @@ -13,7 +13,7 @@ def data seats: [] } - seat_map.seats.includes(:seat_category, ticket: :assignee).each do |seat| + seat_map.seats.includes(:seat_category, ticket: :assignee).find_each do |seat| seat_data = { backendId: seat.id, seatCategoryId: seat.seat_category_id, diff --git a/app/operations/shop/order/cleanup_untouched.rb b/app/operations/shop/order/cleanup_untouched.rb index 71c28ad4..86d79435 100644 --- a/app/operations/shop/order/cleanup_untouched.rb +++ b/app/operations/shop/order/cleanup_untouched.rb @@ -7,7 +7,7 @@ class CleanupUntouched < RailsOps::Operation def perform # Delete other orders for user that have status `created` ActiveRecord::Base.transaction do - Order.where(user: context.user, status: 'created').each do |order| + Order.where(user: context.user, status: 'created').find_each do |order| Operations::Shop::Order::CleanupSingleOrder.run order: order end end diff --git a/app/views/shop/orders/show.html.haml b/app/views/shop/orders/show.html.haml index 4dc4498d..24f6286e 100644 --- a/app/views/shop/orders/show.html.haml +++ b/app/views/shop/orders/show.html.haml @@ -48,4 +48,4 @@ %td{ colspan: 3 }= _('Order|Total') %td= money_formatted(model.total) -= op.product_behaviour_hints.join.html_safe # rubocop:disable Rails/OutputSafety += op.product_behaviour_hints.join.html_safe # rubocop:disable Rails/OutputSafety diff --git a/app/views/tournament_teams/index.html.haml b/app/views/tournament_teams/index.html.haml index 8c2d3e40..e1c27be2 100644 --- a/app/views/tournament_teams/index.html.haml +++ b/app/views/tournament_teams/index.html.haml @@ -23,7 +23,7 @@ - if op.teams.none? %tr %td= _('Tournament|No teams') - - op.teams.includes(:users).each do |team| + - op.teams.includes(:users).find_each do |team| %tr %td = link_to team.name, team_path(team) diff --git a/app/views/tournament_teams/show.html.haml b/app/views/tournament_teams/show.html.haml index 8a9f8b8c..58a66700 100644 --- a/app/views/tournament_teams/show.html.haml +++ b/app/views/tournament_teams/show.html.haml @@ -51,7 +51,7 @@ color: :danger -# Then the other users - - model.team_members.includes(:user).each do |team_member| + - model.team_members.includes(:user).find_each do |team_member| - next if team_member.captain? .d-flex.justify-content-between.align-items-center.border-bottom.py-2