A platform for community discussion. Free, open, simple.
DEV: Replace Ruby numbered parameters by `it` where applicable (#37810)
Loïc Guitauta633007bae02
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 01e858004a0..e6fed880841 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -759,7 +759,7 @@ class ApplicationController < ActionController::BaseNO_DESTINATION_COOKIE = %w[/login /signup /session/ /auth/ /uploads/].freezedef is_valid_destination_url?(url)- url.present? && url != path("/") && NO_DESTINATION_COOKIE.none? { url.start_with? path(_1) }+ url.present? && url != path("/") && NO_DESTINATION_COOKIE.none? { url.start_with? path(it) }enddef destination_urldiff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rbindex 29eeee423c5..5eed4da40b8 100644--- a/app/controllers/users/omniauth_callbacks_controller.rb+++ b/app/controllers/users/omniauth_callbacks_controller.rb@@ -105,7 +105,7 @@ class Users::OmniauthCallbacksController < ApplicationControllertrueend- ALLOWED_FAILURE_ERRORS = %w[csrf_detected request_error invalid_iat unauthorized].index_by { _1 }+ ALLOWED_FAILURE_ERRORS = %w[csrf_detected request_error invalid_iat unauthorized].index_by { it }def failureerror_name = params[:message].to_s.gsub(/[^\w-]/, "").presence@@ -113,7 +113,7 @@ class Users::OmniauthCallbacksController < ApplicationControllerif error == "generic"provider_name = params[:provider].presence || params[:strategy].presence- provider = Discourse.enabled_authenticators.find { _1.name == provider_name }&.display_name+ provider = Discourse.enabled_authenticators.find { it.name == provider_name }&.display_nameif provider.blank? && Discourse.enabled_authenticators.one?provider = Discourse.enabled_authenticators[0].display_namediff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rbindex fd0397f8ead..3deb70c0537 100644--- a/app/mailers/user_notifications.rb+++ b/app/mailers/user_notifications.rb@@ -882,6 +882,6 @@ class UserNotifications < ActionMailer::Base.not_suspended.where("created_at > ?", date).count- .tap { Discourse.redis.setex(key, 1.day, _1) }+ .tap { Discourse.redis.setex(key, 1.day, it) }endenddiff --git a/app/models/category.rb b/app/models/category.rbindex f976e67cb08..ef19f5d5374 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -327,7 +327,7 @@ class Category < ActiveRecord::Basesqls =slugs.map do |slug|category_slugs =- slug.split(":").first(SiteSetting.max_category_nesting).map { Slug.for(_1, "") }+ slug.split(":").first(SiteSetting.max_category_nesting).map { Slug.for(it, "") }sql = ""diff --git a/app/models/concerns/category_hashtag.rb b/app/models/concerns/category_hashtag.rbindex c17bbe6ee29..a2128a7ce0d 100644--- a/app/models/concerns/category_hashtag.rb+++ b/app/models/concerns/category_hashtag.rb@@ -18,7 +18,7 @@ module CategoryHashtagslug_path = split_slug_path(slug)next if slug_path.blank?- slug_path.map! { CGI.escape(_1) } if SiteSetting.slug_generation_method == "encoded"+ slug_path.map! { CGI.escape(it) } if SiteSetting.slug_generation_method == "encoded"parent_slug, child_slug = slug_path.last(2)# Category slugs can be in the parent:child format, if therediff --git a/app/services/category/query/hierarchical_search.rb b/app/services/category/query/hierarchical_search.rbindex a9f634a8b38..917852944b5 100644--- a/app/services/category/query/hierarchical_search.rb+++ b/app/services/category/query/hierarchical_search.rb@@ -7,7 +7,7 @@ class Category::Query::HierarchicalSearchenddef call- build_relation.tap { prepend_allowed_categories_cte(_1) }.to_a+ build_relation.tap { prepend_allowed_categories_cte(it) }.to_aendprivatediff --git a/app/services/groups/create.rb b/app/services/groups/create.rbindex c6057ad6e22..db5d2cf65e7 100644--- a/app/services/groups/create.rb+++ b/app/services/groups/create.rb@@ -124,7 +124,7 @@ class Groups::Createenddef build_user_attributes(params:)- params.owner_ids.map { { user_id: _1, owner: true } } + params.user_ids.map { { user_id: _1 } }+ params.owner_ids.map { { user_id: it, owner: true } } + params.user_ids.map { { user_id: it } }enddef instantiate_group(params:, guardian:, user_attributes:, options:)@@ -132,7 +132,7 @@ class Groups::Createparams.except(:owner_usernames, :usernames, :associated_group_ids).merge(options.dynamic_attributes,),- ) { _1.group_users.build(user_attributes) }+ ) { it.group_users.build(user_attributes) }enddef should_associate_groups(guardian:, params:)diff --git a/app/services/user/bulk_destroy.rb b/app/services/user/bulk_destroy.rbindex d411bda2f48..a21c2da2694 100644--- a/app/services/user/bulk_destroy.rb+++ b/app/services/user/bulk_destroy.rb@@ -27,7 +27,7 @@ class User::BulkDestroyenddef can_delete_users(guardian:, users:)- users.all? { guardian.can_delete_user?(_1) }+ users.all? { guardian.can_delete_user?(it) }enddef delete(users:, guardian:, params:)diff --git a/app/services/user/silence.rb b/app/services/user/silence.rbindex c993ba21cb4..56e4ce53663 100644--- a/app/services/user/silence.rb+++ b/app/services/user/silence.rb@@ -43,7 +43,7 @@ class User::Silenceenddef can_silence_all_users(guardian:, users:)- users.all? { guardian.can_silence_user?(_1) }+ users.all? { guardian.can_silence_user?(it) }enddef silence(guardian:, users:, params:)diff --git a/app/services/user/suspend.rb b/app/services/user/suspend.rbindex bd7db6e31c1..c7c3c402c67 100644--- a/app/services/user/suspend.rb+++ b/app/services/user/suspend.rb@@ -43,7 +43,7 @@ class User::Suspendenddef can_suspend_all_users(guardian:, users:)- users.all? { guardian.can_suspend?(_1) }+ users.all? { guardian.can_suspend?(it) }enddef suspend(guardian:, users:, params:)diff --git a/lib/active_support_type_extensions/array.rb b/lib/active_support_type_extensions/array.rbindex 7955b26cba5..ba598bbe4a0 100644--- a/lib/active_support_type_extensions/array.rb+++ b/lib/active_support_type_extensions/array.rb@@ -21,7 +21,7 @@ module ActiveSupportTypeExtensionsvalue.map { |item| Integer(item, exception: false) || item }else::Array.wrap(value)- end.tap { _1.compact_blank! if compact_blank }+ end.tap { it.compact_blank! if compact_blank }endendenddiff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex d0c9d7be120..eef09a8179b 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -701,7 +701,7 @@ module Emailelsif mail.bounced?# "Final-Recipient" has a specific format (<name> ; <address>)# cf. https://www.ietf.org/rfc/rfc2298.html#section-3.2.4- address_type, generic_address = mail.final_recipient.to_s.split(";").map { _1.to_s.strip }+ address_type, generic_address = mail.final_recipient.to_s.split(";").map { it.to_s.strip }return generic_address, nil if generic_address.include?("@") && address_type == "rfc822"end@@ -751,7 +751,7 @@ module Emailreturn if list_address.blank?# the CC header often includes the name of the sender- address_to_name = mail[:cc]&.element&.addresses&.to_h { [_1.address, _1.name] } || {}+ address_to_name = mail[:cc]&.element&.addresses.to_h { [it.address, it.name] }%i[from reply_to x_mailfrom x_original_from].each do |header|next if mail[header].blank?diff --git a/lib/email/styles.rb b/lib/email/styles.rbindex 6eb71899cc8..8643a8bd2f0 100644--- a/lib/email/styles.rb+++ b/lib/email/styles.rb@@ -381,7 +381,7 @@ module Emailstyle.split(";").select(&:present?)- .map { _1.split(":", 2).map(&:strip) }+ .map { it.split(":", 2).map(&:strip) }.each do |k, v|next if k.blank? || v.blank?next if styles[k]&.end_with?("!important") && !v.end_with?("!important")diff --git a/lib/hijack.rb b/lib/hijack.rbindex 0447fe359ca..d21e6f04465 100644--- a/lib/hijack.rb+++ b/lib/hijack.rb@@ -57,7 +57,7 @@ module Hijack# this trick avoids double render, also avoids any litter that the controller hooks# place on the responseinstance = controller_class.new- response = ActionDispatch::Response.new.tap { _1.request = request_copy }+ response = ActionDispatch::Response.new.tap { it.request = request_copy }instance.set_response!(response)instance.set_request!(request_copy)diff --git a/lib/import_export/importer.rb b/lib/import_export/importer.rbindex 087832163b2..67c1b00d80a 100644--- a/lib/import_export/importer.rb+++ b/lib/import_export/importer.rb@@ -238,7 +238,7 @@ module ImportExportenddef fix_permissions- categories_by_id = @categories.index_by { _1[:id] }+ categories_by_id = @categories.index_by { it[:id] }@categories.each do |category|if category[:permissions_params].blank?diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rbindex ad58bd334dd..22e13c6f5a9 100644--- a/lib/js_locale_helper.rb+++ b/lib/js_locale_helper.rb@@ -153,7 +153,7 @@ module JsLocaleHelper.mf_locales(l).pluck(:translation_key, :value).to_h- .transform_keys { _1.sub(/^[a-z_]*js\./, "") },+ .transform_keys { it.sub(/^[a-z_]*js\./, "") },)end.compact_blankdiff --git a/lib/onebox/mixins/github_auth_header.rb b/lib/onebox/mixins/github_auth_header.rbindex 5cdac6ca828..8754b3c84d5 100644--- a/lib/onebox/mixins/github_auth_header.rb+++ b/lib/onebox/mixins/github_auth_header.rb@@ -6,7 +6,7 @@ module Oneboxdef github_auth_header(github_org)return {} if SiteSetting.github_onebox_access_tokens.blank?- org_tokens = SiteSetting.github_onebox_access_tokens.split("\n").to_h { _1.split("|") }+ org_tokens = SiteSetting.github_onebox_access_tokens.split("\n").to_h { it.split("|") }token = org_tokens[github_org] || org_tokens["default"]diff --git a/lib/service/base.rb b/lib/service/base.rbindex 3dd98571393..724c2f87bf7 100644--- a/lib/service/base.rb+++ b/lib/service/base.rb@@ -104,7 +104,7 @@ module Servicebase_class: Service::ContractBase,&block)- contract_class = Class.new(base_class).tap { _1.class_eval(&block) if block }+ contract_class = Class.new(base_class).tap { it.class_eval(&block) if block }const_set("#{name.to_s.classify.sub("Default", "")}Contract", contract_class)steps << ContractStep.new(name, class_name: contract_class, default_values_from:)end@@ -126,7 +126,7 @@ module Serviceenddef options(&block)- klass = Class.new(Service::OptionsBase).tap { _1.class_eval(&block) }+ klass = Class.new(Service::OptionsBase).tap { it.class_eval(&block) }const_set("Options", klass)steps << OptionsStep.new(:default, class_name: klass)end@@ -172,11 +172,11 @@ module Servicedef run_stepobject = class_name&.new(context)method = object&.method(:call) || instance.method(method_name)- if !object && method.parameters.any? { _1[0] != :keyreq }+ if !object && method.parameters.any? { it[0] != :keyreq }raise DefaultValuesNotAllowed,"In #{type} '#{name}': default values in step implementations are not allowed. Maybe they could be defined in a params or options block?"end- args = context.slice(*method.parameters.select { _1[0] == :keyreq }.map(&:last))+ args = context.slice(*method.parameters.select { it[0] == :keyreq }.map(&:last))context[result_key][:object] = object if objectinstance.instance_exec(**args, &method)end@@ -335,7 +335,7 @@ module Servicedef filtered_backtraceArray.wrap(backtrace)- .chunk { _1.match?(%r{/(gems|lib/service|ruby)/}) }+ .chunk { it.match?(%r{/(gems|lib/service|ruby)/}) }.flat_map do |excluded, lines|next "(#{lines.size} framework line(s) excluded)" if excludedlinesdiff --git a/lib/service/contract_base.rb b/lib/service/contract_base.rbindex 08aa62037dc..b4f3241634f 100644--- a/lib/service/contract_base.rb+++ b/lib/service/contract_base.rb@@ -40,7 +40,7 @@ class Service::ContractBasedef to_hashattributes.symbolize_keys.deep_transform_values do- _1.is_a?(Service::ContractBase) ? _1.to_hash : _1+ it.is_a?(Service::ContractBase) ? it.to_hash : itendend@@ -59,7 +59,7 @@ class Service::ContractBaseenddef nested_attributes- @attributes.each_value.select { _1.type.is_a?(Service::NestedContractType) && _1.value }+ @attributes.each_value.select { it.type.is_a?(Service::NestedContractType) && it.value }enddef validate_nested(attribute)diff --git a/lib/service/runner.rb b/lib/service/runner.rbindex d61254a64a9..980f060e20a 100644--- a/lib/service/runner.rb+++ b/lib/service/runner.rb@@ -101,7 +101,7 @@ class Service::Runnercondition: ->(*exceptions) donext unless result["result.try.default"]&.exceptionnext true if exceptions.empty?- exceptions.any? { result["result.try.default"].exception.is_a?(_1) }+ exceptions.any? { result["result.try.default"].exception.is_a?(it) }end,key: %w[result try],name: "default",@@ -165,7 +165,7 @@ class Service::Runnerresult[[*action[:key], action[:name] || args.first || action[:default_name]].join(".")].public_send(action[:property] || :itself),- **result.slice(*block.parameters.filter_map { _1.last if _1.first == :keyreq }),+ **result.slice(*block.parameters.filter_map { it.last if it.first == :keyreq }),&block)end,diff --git a/lib/service/steps_inspector.rb b/lib/service/steps_inspector.rbindex 7a830dd439c..fa195777622 100644--- a/lib/service/steps_inspector.rb+++ b/lib/service/steps_inspector.rb@@ -119,7 +119,7 @@ class Service::StepsInspectordef steps[self,- *step.steps.map { Step.for(_1, result, nesting_level: nesting_level + 1, color:).steps },+ *step.steps.map { Step.for(it, result, nesting_level: nesting_level + 1, color:).steps },]end@@ -160,7 +160,7 @@ class Service::StepsInspector[self,*step.steps.map do- Step.for(_1, result, nesting_level: nesting_level + 1, color: skipped_color).steps+ Step.for(it, result, nesting_level: nesting_level + 1, color: skipped_color).stepsend,]end@@ -190,7 +190,7 @@ class Service::StepsInspectorattr_reader :steps, :resultdef initialize(result)- @steps = result.__steps__.map { Step.for(_1, result).steps }.flatten+ @steps = result.__steps__.map { Step.for(it, result).steps }.flatten@result = resultenddiff --git a/lib/topics_filter.rb b/lib/topics_filter.rbindex c2e21d45d9c..24cef301fe8 100644--- a/lib/topics_filter.rb+++ b/lib/topics_filter.rb@@ -107,7 +107,7 @@ class TopicsFilterwhen "views-max"filter_by_number_of_views(max: filter_values)else- if custom_filter = DiscoursePluginRegistry.custom_filter_mappings.find { _1.key?(filter) }+ if custom_filter = DiscoursePluginRegistry.custom_filter_mappings.find { it.key?(filter) }@scope = custom_filter[filter].call(@scope, filter_values, @guardian) || @scopeendenddiff --git a/lib/validators/allowed_iframes_validator.rb b/lib/validators/allowed_iframes_validator.rbindex 63e155364fc..3e557a3de2a 100644--- a/lib/validators/allowed_iframes_validator.rb+++ b/lib/validators/allowed_iframes_validator.rb@@ -9,7 +9,7 @@ class AllowedIframesValidatorenddef valid_value?(values)- values.split("|").all? { _1.match? VALID_ALLOWED_IFRAME_URL_REGEX }+ values.split("|").all? { it.match? VALID_ALLOWED_IFRAME_URL_REGEX }enddef error_messagediff --git a/lib/validators/csp_script_src_validator.rb b/lib/validators/csp_script_src_validator.rbindex 419a6cf456d..ee6a7362be9 100644--- a/lib/validators/csp_script_src_validator.rb+++ b/lib/validators/csp_script_src_validator.rb@@ -13,7 +13,7 @@ class CspScriptSrcValidatorenddef valid_value?(values)- values.split("|").all? { _1.match? VALID_SOURCE_REGEX }+ values.split("|").all? { it.match? VALID_SOURCE_REGEX }enddef error_messagediff --git a/migrations/lib/importer/steps/badges/badges.rb b/migrations/lib/importer/steps/badges/badges.rbindex 189b0228229..62af9c28355 100644--- a/migrations/lib/importer/steps/badges/badges.rb+++ b/migrations/lib/importer/steps/badges/badges.rb@@ -7,7 +7,7 @@ module Migrations::Importer::StepsVALID_TRIGGERS =Badge::Trigger.constants(false)- .filter_map { Badge::Trigger.const_get(_1) unless _1 == :DeprecatedPostProcessed }+ .filter_map { Badge::Trigger.const_get(it) unless it == :DeprecatedPostProcessed }.to_set.freezediff --git a/plugins/chat/app/services/chat/action/search_message/process_search_query.rb b/plugins/chat/app/services/chat/action/search_message/process_search_query.rbindex 138ca5ce049..38e744bdd31 100644--- a/plugins/chat/app/services/chat/action/search_message/process_search_query.rb+++ b/plugins/chat/app/services/chat/action/search_message/process_search_query.rb@@ -104,9 +104,9 @@ module Chatdef filtered_messagesmessages- .then { apply_username_filters(_1) }- .then { apply_channel_filters(_1) }- .then { apply_ts_query(_1) }+ .then { apply_username_filters(it) }+ .then { apply_channel_filters(it) }+ .then { apply_ts_query(it) }enddef apply_ts_query(messages)diff --git a/plugins/chat/lib/chat/channel_fetcher.rb b/plugins/chat/lib/chat/channel_fetcher.rbindex 9ac302a4e40..9585dfec8c6 100644--- a/plugins/chat/lib/chat/channel_fetcher.rb+++ b/plugins/chat/lib/chat/channel_fetcher.rb@@ -246,7 +246,7 @@ module ChatUserField.all.pluck(:id).map { |fid| "#{User::USER_FIELD_PREFIX}#{fid}" }User.preload_custom_fields(- channels.flat_map { _1.chatable.direct_message_users.map(&:user).compact },+ channels.flat_map { it.chatable.direct_message_users.map(&:user).compact },preload_fields,)diff --git a/plugins/chat/lib/chat/message_blocks_validator.rb b/plugins/chat/lib/chat/message_blocks_validator.rbindex 51b3ec26eae..439d760c136 100644--- a/plugins/chat/lib/chat/message_blocks_validator.rb+++ b/plugins/chat/lib/chat/message_blocks_validator.rb@@ -10,7 +10,7 @@ module Chatschemer = JSONSchemer.schema(Chat::Schemas::MessageBlocks)if !schemer.valid?(record.blocks)- record.errors.add(:blocks, schemer.validate(record.blocks).map { _1.fetch("error") })+ record.errors.add(:blocks, schemer.validate(record.blocks).map { it.fetch("error") })returnenddiff --git a/plugins/chat/lib/chat/user_notifications_extension.rb b/plugins/chat/lib/chat/user_notifications_extension.rbindex 3f22ec6f374..18ca672543b 100644--- a/plugins/chat/lib/chat/user_notifications_extension.rb+++ b/plugins/chat/lib/chat/user_notifications_extension.rb@@ -47,11 +47,11 @@ module Chat# and a count of unread messages per channelChat::Message.includes(:user, :chat_channel)- .where(chat_channel_id: data.map { _1[1] })+ .where(chat_channel_id: data.map { it[1] }).where("chat_messages.id >= (SELECT min_unread_id- FROM (VALUES #{data.map { "(#{_1[1]}, #{_1[2]})" }.join(",")}) AS t(channel_id, min_unread_id)+ FROM (VALUES #{data.map { "(#{it[1]}, #{it[2]})" }.join(",")}) AS t(channel_id, min_unread_id)WHERE t.channel_id = chat_messages.chat_channel_id)",)@@ -63,11 +63,11 @@ module Chatdef messages_for_threads(data, guardian)Chat::Message.includes(:user, :chat_channel)- .where(thread_id: data.map { _1[1] })+ .where(thread_id: data.map { it[1] }).where("chat_messages.id >= (SELECT min_unread_id- FROM (VALUES #{data.map { "(#{_1[1]}, #{_1[2]})" }.join(",")}) AS t(thread_id, min_unread_id)+ FROM (VALUES #{data.map { "(#{it[1]}, #{it[2]})" }.join(",")}) AS t(thread_id, min_unread_id)WHERE t.thread_id = chat_messages.thread_id)",)@@ -88,7 +88,7 @@ module Chatreturn subject(:private_email, count:) if SiteSetting.private_email# consider "direct messages" with more than 2 users as group messages (aka. channels)- dms, groups = grouped_dms.keys.partition { _1.user_chat_channel_memberships.count == 2 }+ dms, groups = grouped_dms.keys.partition { it.user_chat_channel_memberships.count == 2 }channels = grouped_channels.keys + groupsdiff --git a/plugins/chat/spec/services/actions/search_for_messages_spec.rb b/plugins/chat/spec/services/actions/search_for_messages_spec.rbindex af27c1870b2..4cf2c207b6c 100644--- a/plugins/chat/spec/services/actions/search_for_messages_spec.rb+++ b/plugins/chat/spec/services/actions/search_for_messages_spec.rb@@ -20,7 +20,7 @@ RSpec.describe Chat::Action::SearchForMessages doSearchIndexer.enableSiteSetting.chat_enabled = truechannel.add(current_user)- [message_1, message_2, message_3].each { SearchIndexer.index(_1, force: true) }+ [message_1, message_2, message_3].each { SearchIndexer.index(it, force: true) }endit "returns matching messages" do@@ -50,7 +50,7 @@ RSpec.describe Chat::Action::SearchForMessages dobefore do[alice_message_1, alice_message_2, bob_message].each do- SearchIndexer.index(_1, force: true)+ SearchIndexer.index(it, force: true)endend@@ -115,7 +115,7 @@ RSpec.describe Chat::Action::SearchForMessages dobefore doargs[:limit] = 2- [message_4, message_5].each { SearchIndexer.index(_1, force: true) }+ [message_4, message_5].each { SearchIndexer.index(it, force: true) }endit "limits the number of results" do@@ -128,7 +128,7 @@ RSpec.describe Chat::Action::SearchForMessages dofab!(:message_5) { Fabricate(:chat_message, chat_channel: channel, message: "test five") }fab!(:message_6) { Fabricate(:chat_message, chat_channel: channel, message: "test six") }- before { [message_4, message_5, message_6].each { SearchIndexer.index(_1, force: true) } }+ before { [message_4, message_5, message_6].each { SearchIndexer.index(it, force: true) } }context "with offset parameter" dolet(:all_results) do@@ -213,7 +213,7 @@ RSpec.describe Chat::Action::SearchForMessages dobefore do[original_message, thread_reply, regular_message].each do- SearchIndexer.index(_1, force: true)+ SearchIndexer.index(it, force: true)endend@@ -255,7 +255,7 @@ RSpec.describe Chat::Action::SearchForMessages dobefore dochannel_2.add(current_user)[channel_1_message, channel_2_message, private_channel_message].each do- SearchIndexer.index(_1, force: true)+ SearchIndexer.index(it, force: true)endenddiff --git a/plugins/chat/spec/services/chat/action/search_message/process_search_query_spec.rb b/plugins/chat/spec/services/chat/action/search_message/process_search_query_spec.rbindex b56015256aa..d682cf5f572 100644--- a/plugins/chat/spec/services/chat/action/search_message/process_search_query_spec.rb+++ b/plugins/chat/spec/services/chat/action/search_message/process_search_query_spec.rb@@ -16,7 +16,7 @@ RSpec.describe Chat::Action::SearchMessage::ProcessSearchQuery dochannel.add(current_user)SearchIndexer.enableSiteSetting.chat_enabled = true- Chat::Message.all.each { SearchIndexer.index(_1, force: true) }+ Chat::Message.all.each { SearchIndexer.index(it, force: true) }endcontext "with no filters" dodiff --git a/plugins/chat/spec/services/chat/lookup_user_threads_spec.rb b/plugins/chat/spec/services/chat/lookup_user_threads_spec.rbindex 26c0abc125c..ac83f538aed 100644--- a/plugins/chat/spec/services/chat/lookup_user_threads_spec.rb+++ b/plugins/chat/spec/services/chat/lookup_user_threads_spec.rb@@ -115,7 +115,7 @@ RSpec.describe ::Chat::LookupUserThreads doendit "doesn't return threads with no replies" do- Fabricate(:chat_thread, channel: channel_1).tap { _1.add(current_user) }+ Fabricate(:chat_thread, channel: channel_1).tap { it.add(current_user) }expect(result.threads).to eq([thread_1])enddiff --git a/plugins/chat/spec/services/chat/update_message_spec.rb b/plugins/chat/spec/services/chat/update_message_spec.rbindex 2040fcbf1d9..c0f80b14464 100644--- a/plugins/chat/spec/services/chat/update_message_spec.rb+++ b/plugins/chat/spec/services/chat/update_message_spec.rb@@ -178,7 +178,7 @@ RSpec.describe Chat::UpdateMessage do},)end- expect(events.map { _1[:event_name] }).to include(:chat_message_edited)+ expect(events.map { it[:event_name] }).to include(:chat_message_edited)endit "publishes updated message to message bus" dodiff --git a/plugins/discourse-ai/app/models/ai_summary.rb b/plugins/discourse-ai/app/models/ai_summary.rbindex 4fe38c37300..e43036c7c14 100644--- a/plugins/discourse-ai/app/models/ai_summary.rb+++ b/plugins/discourse-ai/app/models/ai_summary.rb@@ -31,7 +31,7 @@ class AiSummary < ActiveRecord::Base],).first- .then { AiSummary.find_by(id: _1["id"]) }+ .then { AiSummary.find_by(id: it["id"]) }enddef self.build_sha(joined_ids)diff --git a/plugins/discourse-ai/lib/ai_helper/chat_thread_titler.rb b/plugins/discourse-ai/lib/ai_helper/chat_thread_titler.rbindex 77cb80e6874..1f183c16493 100644--- a/plugins/discourse-ai/lib/ai_helper/chat_thread_titler.rb+++ b/plugins/discourse-ai/lib/ai_helper/chat_thread_titler.rb@@ -63,7 +63,7 @@ module DiscourseAi.split("\n").first.to_s- .then { _1.match?(/^(["']).*\1$/) ? _1[1..-2] : _1 }+ .then { it.match?(/^(["']).*\1$/) ? it[1..-2] : it }.truncate(100, separator: " ")enddiff --git a/plugins/discourse-ai/lib/ai_helper/semantic_categorizer.rb b/plugins/discourse-ai/lib/ai_helper/semantic_categorizer.rbindex 81d4197bcf8..eef94634878 100644--- a/plugins/discourse-ai/lib/ai_helper/semantic_categorizer.rb+++ b/plugins/discourse-ai/lib/ai_helper/semantic_categorizer.rb@@ -89,7 +89,7 @@ module DiscourseAi.sort_by { |c| -c[:score] }.take(7).then do |tags|- models = Tag.where(name: tags.map { _1[:name] }).index_by(&:name)+ models = Tag.where(name: tags.map { it[:name] }).index_by(&:name)tags.map do |tag|model = models.dig(tag[:name])tag[:id] = model&.iddiff --git a/plugins/discourse-ai/lib/personas/persona.rb b/plugins/discourse-ai/lib/personas/persona.rbindex af48e6bf6e1..f4e54927266 100644--- a/plugins/discourse-ai/lib/personas/persona.rb+++ b/plugins/discourse-ai/lib/personas/persona.rb@@ -427,7 +427,7 @@ module DiscourseAi.rerank(conversation_context.last[:content], guidance).to_a.take(rag_conversation_chunks)- .map { _1[:index] }+ .map { it[:index] }if ranks.empty?fragments = fragments.take(rag_conversation_chunks)diff --git a/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb b/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rbindex ddaaaaf1be7..9f04522ee51 100644--- a/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb+++ b/plugins/discourse-ai/lib/personas/tools/discourse_meta_search.rb@@ -112,12 +112,12 @@ module DiscourseAielsecategories =if categories_json = json.dig("grouped_search_result", "extra", "categories")- categories_json.index_by { _1["id"] }+ categories_json.index_by { it["id"] }elseself.class.categoriesend- topics = (json["topics"]).index_by { _1["id"] }+ topics = (json["topics"]).index_by { it["id"] }format_results(posts, args: parameters) do |post|topic = topics[post["topic_id"]]diff --git a/plugins/discourse-ai/lib/sentiment/post_classification.rb b/plugins/discourse-ai/lib/sentiment/post_classification.rbindex becc8cdc800..f4dd526aaff 100644--- a/plugins/discourse-ai/lib/sentiment/post_classification.rb+++ b/plugins/discourse-ai/lib/sentiment/post_classification.rb@@ -5,7 +5,7 @@ module DiscourseAiclass PostClassificationdef self.backfill_query(from_post_id: nil, max_age_days: nil)available_classifier_names =- DiscourseAi::Sentiment::SentimentSiteSettingJsonSchema.values.map { _1.model_name }+ DiscourseAi::Sentiment::SentimentSiteSettingJsonSchema.values.map { it.model_name }queries =available_classifier_names.map do |classifier_name|diff --git a/plugins/discourse-ai/spec/lib/modules/sentiment/emotion_filter_order_spec.rb b/plugins/discourse-ai/spec/lib/modules/sentiment/emotion_filter_order_spec.rbindex a8ab2ea56fa..1d9a0d08051 100644--- a/plugins/discourse-ai/spec/lib/modules/sentiment/emotion_filter_order_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/sentiment/emotion_filter_order_spec.rb@@ -178,7 +178,7 @@ RSpec.describe DiscourseAi::Sentiment::EmotionFilterOrder dofilter =DiscoursePluginRegistry.custom_filter_mappings- .find { _1.keys.include? "order:emotion_#{emotion}" }+ .find { it.keys.include? "order:emotion_#{emotion}" }.values.firstresult = filter.call(scope, order_direction, guardian)diff --git a/plugins/discourse-assign/plugin.rb b/plugins/discourse-assign/plugin.rbindex 2d2a2c304d9..6abee802201 100644--- a/plugins/discourse-assign/plugin.rb+++ b/plugins/discourse-assign/plugin.rb@@ -213,9 +213,9 @@ after_initialize dotopics.each do |topic|if assignments = assignments_map[topic.id]- topic_assignments, post_assignments = assignments.partition { _1.target_type == "Topic" }+ topic_assignments, post_assignments = assignments.partition { it.target_type == "Topic" }- direct_assignment = topic_assignments.find { _1.target_id == topic.id }+ direct_assignment = topic_assignments.find { it.target_id == topic.id }indirectly_assigned_to = {}@@ -270,8 +270,8 @@ after_initialize doresults.posts.each do |post|if topic_assignments = assignments[post.topic_id]- direct_assignment = topic_assignments.find { _1.target_type == "Topic" }- indirect_assignments = topic_assignments.select { _1.target_type == "Post" }+ direct_assignment = topic_assignments.find { it.target_type == "Topic" }+ indirect_assignments = topic_assignments.select { it.target_type == "Post" }endif indirect_assignments.present?diff --git a/plugins/discourse-assign/spec/requests/list_controller_spec.rb b/plugins/discourse-assign/spec/requests/list_controller_spec.rbindex 253efe023ad..1b0f0bd4d8c 100644--- a/plugins/discourse-assign/spec/requests/list_controller_spec.rb+++ b/plugins/discourse-assign/spec/requests/list_controller_spec.rb@@ -378,7 +378,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id, topic_3.id)endend@@ -395,7 +395,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id)end@@ -406,7 +406,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_2.id)end@@ -429,7 +429,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id, topic_3.id)end@@ -452,7 +452,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id)end@@ -467,7 +467,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id)end@@ -482,7 +482,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_3.id)end@@ -496,7 +496,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id, topic_3.id)end@@ -514,7 +514,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id)endend@@ -529,7 +529,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id, topic_3.id)end@@ -542,7 +542,7 @@ describe ListController doexpect(response.status).to eq(200)expect(- response.parsed_body.dig("topic_list", "topics").map { _1["id"] },+ response.parsed_body.dig("topic_list", "topics").map { it["id"] },).to contain_exactly(topic_1.id, topic_2.id, topic_3.id)endenddiff --git a/plugins/discourse-assign/spec/system/user_menu_spec.rb b/plugins/discourse-assign/spec/system/user_menu_spec.rbindex 7ceed14dbd7..528360e735c 100644--- a/plugins/discourse-assign/spec/system/user_menu_spec.rb+++ b/plugins/discourse-assign/spec/system/user_menu_spec.rb@@ -27,7 +27,7 @@ RSpec.describe "Assign | User Menu", type: :system doread_user_assign_2,read_user_assign,read_group_assign,- ].map { _1.topic.fancy_title }+ ].map { it.topic.fancy_title }endit "orders the items properly" dodiff --git a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rbindex f9040bb7876..b6c65c549fd 100644--- a/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb+++ b/plugins/discourse-gamification/app/models/discourse_gamification/gamification_score.rb@@ -7,11 +7,11 @@ module DiscourseGamificationbelongs_to :userdef self.enabled_scorables- Scorable.subclasses.filter { _1.enabled? }+ Scorable.subclasses.filter { it.enabled? }enddef self.scorables_queries- enabled_scorables.map { "( #{_1.query} )" }.join(" UNION ALL ")+ enabled_scorables.map { "( #{it.query} )" }.join(" UNION ALL ")enddef self.calculate_scores(since_date: Date.today, only_subclass: nil)diff --git a/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb b/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rbindex 6ef263a89e4..1aa8d99573f 100644--- a/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb+++ b/plugins/discourse-gamification/lib/discourse_gamification/scorables/scorable.rb@@ -7,7 +7,7 @@ module DiscourseGamificationenddef scorable_category_list- SiteSetting.scorable_categories.split("|").map { _1.to_i }.join(", ")+ SiteSetting.scorable_categories.split("|").map { it.to_i }.join(", ")endendenddiff --git a/plugins/discourse-gamification/spec/requests/admin_gamification_score_event_controller_spec.rb b/plugins/discourse-gamification/spec/requests/admin_gamification_score_event_controller_spec.rbindex 21e4f5d57df..7479e6afda3 100644--- a/plugins/discourse-gamification/spec/requests/admin_gamification_score_event_controller_spec.rb+++ b/plugins/discourse-gamification/spec/requests/admin_gamification_score_event_controller_spec.rb@@ -49,7 +49,7 @@ RSpec.describe DiscourseGamification::AdminGamificationScoreEventController doget "/admin/plugins/gamification/score_events.json?user_id=#{current_user.id}"expect(response.status).to eq(200)expect(response.parsed_body["events"].length).to eq(2)- expect(response.parsed_body["events"].map { _1["points"] }.sum).to eq(24)+ expect(response.parsed_body["events"].map { it["points"] }.sum).to eq(24)endit "returns users and their calculated scores for a specific user and date" dodiff --git a/script/bulk_import/generic_bulk.rb b/script/bulk_import/generic_bulk.rbindex 4379c618e24..484b259ecdb 100644--- a/script/bulk_import/generic_bulk.rb+++ b/script/bulk_import/generic_bulk.rb@@ -324,7 +324,7 @@ class BulkImport::Generic < BulkImport::BaseSQLfield_names =- query("SELECT DISTINCT name FROM category_custom_fields") { _1.map { |row| row["name"] } }+ query("SELECT DISTINCT name FROM category_custom_fields") { it.map { |row| row["name"] } }existing_category_custom_fields =CategoryCustomField.where(name: field_names).pluck(:category_id, :name).to_set@@ -1189,7 +1189,7 @@ class BulkImport::Generic < BulkImport::BaseSQLfield_names =- query("SELECT DISTINCT name FROM post_custom_fields") { _1.map { |row| row["name"] } }+ query("SELECT DISTINCT name FROM post_custom_fields") { it.map { |row| row["name"] } }existing_post_custom_fields =PostCustomField.where(name: field_names).pluck(:post_id, :name).to_setdiff --git a/script/import_scripts/phpbb3/support/settings.rb b/script/import_scripts/phpbb3/support/settings.rbindex cee09d6970c..3f8054eda25 100644--- a/script/import_scripts/phpbb3/support/settings.rb+++ b/script/import_scripts/phpbb3/support/settings.rb@@ -50,7 +50,7 @@ module ImportScripts::PhpBB3@new_categories = import_settings["new_categories"]@category_mappings =- import_settings.fetch("category_mappings", []).index_by { _1[:source_category_id].to_s }+ import_settings.fetch("category_mappings", []).index_by { it[:source_category_id].to_s }@tag_mappings = import_settings["tag_mappings"]@rank_mapping = import_settings["rank_mapping"]diff --git a/script/import_scripts/vbulletin3.rb b/script/import_scripts/vbulletin3.rbindex 1eb6ff3f711..41f5cfaff3d 100644--- a/script/import_scripts/vbulletin3.rb+++ b/script/import_scripts/vbulletin3.rb@@ -717,7 +717,7 @@ LEFT OUTER JOIN #{TABLE_PREFIX}avatar a ON a.avatarid = u.avataridputs "", "creating category moderator groups..."forums = mysql_query("SELECT forumid, parentid, title FROM #{TABLE_PREFIX}forum").to_aforums.each { |f| f["children"] = forums.select { |c| c["parentid"] == f["forumid"] } }- forum_map = forums.index_by { _1["forumid"] }+ forum_map = forums.index_by { it["forumid"] }modentries = mysql_query(<<-SQL).to_aSELECT m.forumid, m.userid, u.usergroupid IN (5,6) is_staffFROM #{TABLE_PREFIX}moderator mdiff --git a/spec/integrity/having_multiple_tagged_loggers_spec.rb b/spec/integrity/having_multiple_tagged_loggers_spec.rbindex c2c20dcbabc..02f22bf3eae 100644--- a/spec/integrity/having_multiple_tagged_loggers_spec.rb+++ b/spec/integrity/having_multiple_tagged_loggers_spec.rb@@ -3,9 +3,9 @@RSpec.describe "Having multiple tagged loggers", type: :request dolet(:loggers) { 2.times.map { ActiveSupport::TaggedLogging.new(Logger.new(nil)) } }- before { loggers.each { Rails.logger.broadcast_to(_1) } }+ before { loggers.each { Rails.logger.broadcast_to(it) } }- after { loggers.each { Rails.logger.stop_broadcasting_to(_1) } }+ after { loggers.each { Rails.logger.stop_broadcasting_to(it) } }it "does not execute request twice" doexpect_any_instance_of(SilenceLogger).to receive(:call_app).once.and_call_originaldiff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rbindex 1345234a800..a6226db46dc 100644--- a/spec/lib/post_creator_spec.rb+++ b/spec/lib/post_creator_spec.rb@@ -268,19 +268,19 @@ RSpec.describe PostCreator dop = nilmessages = MessageBus.track_publish { p = creator.create }- expect(messages.find { _1.channel == "/latest" }).not_to eq(nil)- expect(messages.find { _1.channel == "/new" }).not_to eq(nil)- expect(messages.find { _1.channel == "/unread/#{p.user_id}" }).not_to eq(nil)- expect(messages.find { _1.channel == "/user-drafts/#{p.user_id}" }).not_to eq(nil)+ expect(messages.find { it.channel == "/latest" }).not_to eq(nil)+ expect(messages.find { it.channel == "/new" }).not_to eq(nil)+ expect(messages.find { it.channel == "/unread/#{p.user_id}" }).not_to eq(nil)+ expect(messages.find { it.channel == "/user-drafts/#{p.user_id}" }).not_to eq(nil)- user_action = messages.find { _1.channel == "/u/#{p.user.username}" }+ user_action = messages.find { it.channel == "/u/#{p.user.username}" }expect(user_action).to eq(nil)topics_stats =messages.find { |m| m.channel == "/topic/#{p.topic.id}" && m.data[:type] == :stats }expect(topics_stats).to eq(nil)- expect(messages.filter { _1.channel != "/distributed_hash" }.size).to eq(6)+ expect(messages.filter { it.channel != "/distributed_hash" }.size).to eq(6)endit "extracts links from the post" dodiff --git a/spec/lib/search_spec.rb b/spec/lib/search_spec.rbindex 7f1efce2c08..c862a610452 100644--- a/spec/lib/search_spec.rb+++ b/spec/lib/search_spec.rb@@ -3291,7 +3291,7 @@ RSpec.describe Search dobefore dodescribed_class.advanced_order(:chars, enabled: method(:enabled?)) do- _1.reorder("MAX(LENGTH(posts.raw)) DESC")+ it.reorder("MAX(LENGTH(posts.raw)) DESC")endenddiff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rbindex 613b241ec3f..b1768244bea 100644--- a/spec/models/theme_spec.rb+++ b/spec/models/theme_spec.rb@@ -1566,8 +1566,8 @@ HTMLlet!(:another_theme) { Fabricate(:theme) }before do- users.take(3).each { _1.user_option.update!(theme_ids: [theme.id]) }- users.slice(3..4).each { _1.user_option.update!(theme_ids: [another_theme.id]) }+ users.take(3).each { it.user_option.update!(theme_ids: [theme.id]) }+ users.slice(3..4).each { it.user_option.update!(theme_ids: [another_theme.id]) }endit "returns how many users are currently using the theme" dodiff --git a/spec/requests/admin/api_controller_spec.rb b/spec/requests/admin/api_controller_spec.rbindex 35364bebe2f..04c74581214 100644--- a/spec/requests/admin/api_controller_spec.rb+++ b/spec/requests/admin/api_controller_spec.rb@@ -498,7 +498,7 @@ RSpec.describe Admin::ApiController doend,).to be_truthy- expect(scopes["users"].find { _1["key"] == "update" }["urls"]).to contain_exactly(+ expect(scopes["users"].find { it["key"] == "update" }["urls"]).to contain_exactly("/users/:username (PUT)","/users/:username/preferences/badge_title (PUT)","/users/:username/preferences/avatar/pick (PUT)",diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex fa08f13e36c..b330bfc0831 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -3732,7 +3732,7 @@ RSpec.describe TopicsController doexpect(response.status).to eq(200)expect(response.parsed_body.has_key?("suggested_topics")).to eq(false)- expect(response.parsed_body["categories"].map { _1["id"] }).to contain_exactly(+ expect(response.parsed_body["categories"].map { it["id"] }).to contain_exactly(topic.category_id,)@@ -3740,7 +3740,7 @@ RSpec.describe TopicsController doexpect(response.status).to eq(200)expect(response.parsed_body.has_key?("suggested_topics")).to eq(true)- expect(response.parsed_body["categories"].map { _1["id"] }).to contain_exactly(+ expect(response.parsed_body["categories"].map { it["id"] }).to contain_exactly(topic.category_id,dest_topic.category_id,)diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rbindex 2f07bea34a9..90c74168a4c 100644--- a/spec/requests/users_controller_spec.rb+++ b/spec/requests/users_controller_spec.rb@@ -4552,7 +4552,7 @@ RSpec.describe UsersController dolinks = response.parsed_body["user_summary"]["links"]- expect(links.map { _1["url"] }).to contain_exactly(+ expect(links.map { it["url"] }).to contain_exactly("https://visible-link.com","https://another-visible-link.com",)diff --git a/spec/support/shared_examples/core_features.rb b/spec/support/shared_examples/core_features.rbindex 8bb6aa02d22..bf6b7f3186f 100644--- a/spec/support/shared_examples/core_features.rb+++ b/spec/support/shared_examples/core_features.rb@@ -159,7 +159,7 @@ RSpec.shared_examples_for "having working core features" do |skip_examples: []|before doSearchIndexer.enable- topics.each { SearchIndexer.index(_1, force: true) }+ topics.each { SearchIndexer.index(it, force: true) }Fabricate(:theme_site_setting_with_service, name: "enable_welcome_banner", value: false)end