A platform for community discussion. Free, open, simple.
DEV: Enable Style/RedundantParentheses rubocop rule (#40095)
Jarek Radosz09d07fc41847
diff --git a/.rubocop.yml b/.rubocop.ymlindex ef498f87d2b..a02a3da8b1b 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -62,3 +62,6 @@ Lint/IdentityComparison:Lint/SymbolConversion:Enabled: true++Style/RedundantParentheses:+ Enabled: truediff --git a/app/controllers/admin/embedding_controller.rb b/app/controllers/admin/embedding_controller.rbindex bbdb975729d..1b572b3b871 100644--- a/app/controllers/admin/embedding_controller.rb+++ b/app/controllers/admin/embedding_controller.rb@@ -8,7 +8,7 @@ class Admin::EmbeddingController < Admin::AdminControllerenddef update- raise InvalidAccess if !(%w[posts_and_topics crawlers].include?(params[:embedding][:type]))+ raise InvalidAccess if !%w[posts_and_topics crawlers].include?(params[:embedding][:type])Embedding.send("#{params[:embedding][:type]}_settings")diff --git a/app/controllers/admin/permalinks_controller.rb b/app/controllers/admin/permalinks_controller.rbindex 3e2461ecab5..fadaaa91237 100644--- a/app/controllers/admin/permalinks_controller.rb+++ b/app/controllers/admin/permalinks_controller.rb@@ -55,7 +55,7 @@ class Admin::PermalinksController < Admin::AdminControllercategory_id: extract_param(permitted_params, "category"),tag_id:extract_param(permitted_params, "tag").then do |tag_name|- (Tag.where(name: tag_name).pluck(:id).first || -1) if tag_name+ Tag.where(name: tag_name).pluck(:id).first || -1 if tag_nameend,user_id: extract_param(permitted_params, "user"),external_url: extract_param(permitted_params, "external_url"),diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rbindex 6e9f46c5cae..33014c5b97f 100644--- a/app/controllers/admin/reports_controller.rb+++ b/app/controllers/admin/reports_controller.rb@@ -18,7 +18,7 @@ class Admin::ReportsController < Admin::StaffControllerargs[:current_user] = current_userreport = nil- report = Report.find_cached(report_type, args) if (report_params[:cache])+ report = Report.find_cached(report_type, args) if report_params[:cache]if Report.hidden?(report_type, guardian: guardian)report = Report._get(report_type, args)@@ -30,7 +30,7 @@ class Admin::ReportsController < Admin::StaffControllerelsereport = Report.find(report_type, args)- Report.cache(report) if (report_params[:cache]) && report+ Report.cache(report) if report_params[:cache] && reportif report.blank?report = Report._get(report_type, args)@@ -55,7 +55,7 @@ class Admin::ReportsController < Admin::StaffControllerargs[:current_user] = current_userreport = nil- report = Report.find_cached(report_type, args) if (params[:cache])+ report = Report.find_cached(report_type, args) if params[:cache]return render_json_dump(report: report) if report@@ -64,7 +64,7 @@ class Admin::ReportsController < Admin::StaffControllerraise Discourse::NotFound if report.blank?- Report.cache(report) if (params[:cache])+ Report.cache(report) if params[:cache]render_json_dump(report: report)enddiff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex e73059f906b..f35e13efc6b 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -304,8 +304,8 @@ class ApplicationController < ActionController::Baseopts ||= {}show_json_errors =- (request.format && request.format.json?) || (request.xhr?) ||- ((params[:external_id] || "").to_s.ends_with?(".json"))+ (request.format && request.format.json?) || request.xhr? ||+ (params[:external_id] || "").to_s.ends_with?(".json")if type == :not_found && opts[:check_permalinks]url = opts[:original_path] || request.fullpath@@ -489,7 +489,7 @@ class ApplicationController < ActionController::Basedef guardian# sometimes we log on a user in the middle of a request so we should throw# away the cached guardian instance when we do that- if (@guardian&.user).blank? && current_user.present?+ if @guardian&.user.blank? && current_user.present?@guardian = Guardian.new(current_user, request)end@guardian ||= Guardian.new(current_user, request)@@ -848,10 +848,8 @@ class ApplicationController < ActionController::Basedef should_enforce_2fa?enforcing_2fa =- (- (SiteSetting.enforce_second_factor == "staff" && current_user.staff?) ||- SiteSetting.enforce_second_factor == "all"- )+ (SiteSetting.enforce_second_factor == "staff" && current_user.staff?) ||+ SiteSetting.enforce_second_factor == "all"!disqualified_from_2fa_enforcement && enforcing_2fa &&!current_user.has_any_second_factor_methods_enabled?end@@ -964,7 +962,7 @@ class ApplicationController < ActionController::Baseenddef add_noindex_header_to_non_canonical- canonical = (@canonical_url || @default_canonical)+ canonical = @canonical_url || @default_canonicalif canonical.present? && canonical != request.url &&!SiteSetting.allow_indexing_non_canonical_urlsresponse.headers["X-Robots-Tag"] ||= "noindex"diff --git a/app/controllers/edit_directory_columns_controller.rb b/app/controllers/edit_directory_columns_controller.rbindex e981bc86c9c..736decc17a9 100644--- a/app/controllers/edit_directory_columns_controller.rb+++ b/app/controllers/edit_directory_columns_controller.rb@@ -30,10 +30,8 @@ class EditDirectoryColumnsController < ApplicationControllerdirectory_column_params[:directory_columns].values.each do |column_data|existing_column = directory_columns.detect { |c| c.id == column_data[:id].to_i }- if (- existing_column.enabled != ActiveModel::Type::Boolean.new.cast(column_data[:enabled]) ||- existing_column.position != column_data[:position].to_i- )+ if existing_column.enabled != ActiveModel::Type::Boolean.new.cast(column_data[:enabled]) ||+ existing_column.position != column_data[:position].to_inew_value, previous_value =staff_action_logger.edit_directory_columns_details(column_data, existing_column)diff --git a/app/controllers/export_csv_controller.rb b/app/controllers/export_csv_controller.rbindex 6ba212b7d5d..f20f6de49a4 100644--- a/app/controllers/export_csv_controller.rb+++ b/app/controllers/export_csv_controller.rb@@ -23,7 +23,7 @@ class ExportCsvController < ApplicationControllerunless current_user.admin ||UserExport.where(user_id: entity_id || current_user.id,- created_at: (Time.zone.now.all_day),+ created_at: Time.zone.now.all_day,).count == 0render_json_error I18n.t("csv_export.rate_limit_error")returndiff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rbindex c7d9945718c..8d7ac528dd9 100644--- a/app/controllers/groups_controller.rb+++ b/app/controllers/groups_controller.rb@@ -687,7 +687,7 @@ class GroupsController < ApplicationControllerdef searchinclude_everyone =- (params[:include_everyone] == "true" || params[:include_pseudogroups] == "true")+ params[:include_everyone] == "true" || params[:include_pseudogroups] == "true"include_pseudogroups = params[:include_pseudogroups] == "true"order = ["name"]groups =diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rbindex a697f4d7402..362715ab2aa 100644--- a/app/controllers/session_controller.rb+++ b/app/controllers/session_controller.rb@@ -288,7 +288,7 @@ class SessionController < ApplicationControllertext = nil# If there's a problem with the email we can explain that- if (e.record.is_a?(User) && e.record.errors[:primary_email].present?)+ if e.record.is_a?(User) && e.record.errors[:primary_email].present?if e.record.email.blank?text = I18n.t("discourse_connect.no_email")elsediff --git a/app/controllers/svg_sprite_controller.rb b/app/controllers/svg_sprite_controller.rbindex 1db07800ef0..ddb0db28e08 100644--- a/app/controllers/svg_sprite_controller.rb+++ b/app/controllers/svg_sprite_controller.rb@@ -19,7 +19,7 @@ class SvgSpriteController < ApplicationControllertheme_id = params[:theme_id].to_i if params[:theme_id].present?if SvgSprite.version(theme_id) != params[:version]- return redirect_to UrlHelper.absolute((SvgSprite.path(theme_id))), allow_other_host: true+ return redirect_to UrlHelper.absolute(SvgSprite.path(theme_id)), allow_other_host: trueendsvg_sprite = "window.__svg_sprite = #{SvgSprite.bundle(theme_id).inspect};"diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rbindex 9164c890979..748e1dc9736 100644--- a/app/controllers/tags_controller.rb+++ b/app/controllers/tags_controller.rb@@ -218,7 +218,7 @@ class TagsController < ::ApplicationControllercanonical_params = params.slice(:category_slug_path_with_id, :tag_slug, :tag_id)canonical_method = url_method(canonical_params)- canonical_url "#{Discourse.base_url_no_prefix}#{public_send(canonical_method, *(canonical_params.values.map { |t| t.force_encoding("UTF-8") }))}"+ canonical_url "#{Discourse.base_url_no_prefix}#{public_send(canonical_method, *canonical_params.values.map { |t| t.force_encoding("UTF-8") })}"if @list.topics.size == 0 && @tag_name != "none" && !Tag.where_name(@tag_name).exists?raise Discourse::NotFound.new("tag not found", check_permalinks: true)diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex 4207af192fe..56c3771000d 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -1204,7 +1204,7 @@ class TopicsController < ApplicationControllerdef reset_newtopic_scope =if current_user.new_new_view_enabled?- if (params[:dismiss_topics] && params[:dismiss_posts])+ if params[:dismiss_topics] && params[:dismiss_posts]TopicQuery.new(current_user).new_and_unread_results(limit: false)elsif params[:dismiss_topics]TopicQuery.new(current_user).new_results(limit: false)@@ -1522,7 +1522,7 @@ class TopicsController < ApplicationControllerhelpers.localize_topic_view_content(@topic_view)end@breadcrumbs = helpers.categories_breadcrumb(@topic_view.topic) || []- @description_meta = (@topic_view.topic.excerpt.presence || @topic_view.summary)+ @description_meta = @topic_view.topic.excerpt.presence || @topic_view.summarystore_preloaded("topic_#{@topic_view.topic.id}", MultiJson.dump(topic_view_serializer))render :showenddiff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rbindex 0c1a9f54dd6..1759fa71d95 100644--- a/app/controllers/uploads_controller.rb+++ b/app/controllers/uploads_controller.rb@@ -95,7 +95,7 @@ class UploadsController < ApplicationControllerparams.permit(short_urls: [])uploads = []- if (params[:short_urls] && params[:short_urls].length > 0)+ if params[:short_urls] && params[:short_urls].length > 0PrettyText::Helpers.lookup_upload_urls(params[:short_urls]).each do |short_url, paths|diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rbindex d0da1a3ff53..338a3f643d0 100644--- a/app/controllers/users_controller.rb+++ b/app/controllers/users_controller.rb@@ -607,7 +607,7 @@ class UsersController < ApplicationControllerenddef changing_case_of_own_username(target_user, username)- target_user && username.downcase == (target_user.username.downcase)+ target_user && username.downcase == target_user.username.downcaseend# Used for checking availability of a username and will return suggestionsdiff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rbindex 0b13d9a6d0a..f86349fbaae 100644--- a/app/controllers/webhooks_controller.rb+++ b/app/controllers/webhooks_controller.rb@@ -27,7 +27,7 @@ class WebhooksController < ActionController::Baseevents = params["_json"] || [params]events.each do |event|- message_id = Email::MessageIdService.message_id_clean((event["smtp-id"] || ""))+ message_id = Email::MessageIdService.message_id_clean(event["smtp-id"] || "")to_address = event["email"]error_code = event["status"]diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 83bcddeb97b..c49e29925b0 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -398,7 +398,7 @@ module ApplicationHelperendprivate def generate_twitter_card_metadata(result, opts)- img_url = (opts[:x_summary_large_image].presence || opts[:image])+ img_url = opts[:x_summary_large_image].presence || opts[:image]# Twitter does not allow SVGs, see https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markupif img_url.ends_with?(".svg")@@ -950,7 +950,7 @@ module ApplicationHelpercookie = cookies[:forced_color_mode]return cookie == "light" if cookie.present?- !!(current_user&.user_option&.light_mode_forced?)+ !!current_user&.user_option&.light_mode_forced?enddef forced_dark_mode?@@ -959,7 +959,7 @@ module ApplicationHelpercookie = cookies[:forced_color_mode]return cookie == "dark" if cookie.present?- !!(current_user&.user_option&.dark_mode_forced?)+ !!current_user&.user_option&.dark_mode_forced?enddef light_color_hex_for_name(name)diff --git a/app/helpers/embed_helper.rb b/app/helpers/embed_helper.rbindex bcd8e8c3587..52ef5887652 100644--- a/app/helpers/embed_helper.rb+++ b/app/helpers/embed_helper.rb@@ -21,7 +21,7 @@ module EmbedHelperdef get_html(post)key = "js.action_codes.#{post.action_code}"- cooked = (post.cooked.presence || I18n.t(key, when: nil).humanize)+ cooked = post.cooked.presence || I18n.t(key, when: nil).humanizeraw PrettyText.format_for_email(cooked, post)enddiff --git a/app/jobs/concerns/skippable.rb b/app/jobs/concerns/skippable.rbindex bb2e0bd2c24..e1ec0ddafd8 100644--- a/app/jobs/concerns/skippable.rb+++ b/app/jobs/concerns/skippable.rb@@ -15,7 +15,7 @@ module Skippableif reason_type == SkippedEmailLog.reason_types[:exceeded_emails_limit]exists =SkippedEmailLog.exists?(- { created_at: (Time.zone.now.all_day) }.merge!(attributes.except(:post_id)),+ { created_at: Time.zone.now.all_day }.merge!(attributes.except(:post_id)),)return if existsdiff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rbindex 3dacea427a9..d97d4f73019 100644--- a/app/jobs/regular/user_email.rb+++ b/app/jobs/regular/user_email.rb@@ -160,7 +160,7 @@ module Jobsemail_args = {}if (post || notification || notification_type || args[:force_respect_seen_recently]) &&- (seen_recently && !user.suspended?)+ seen_recently && !user.suspended?return skip_message(SkippedEmailLog.reason_types[:user_email_seen_recently])enddiff --git a/app/jobs/scheduled/aggregate_web_hooks_events.rb b/app/jobs/scheduled/aggregate_web_hooks_events.rbindex 825dca90b59..8a2fc154aac 100644--- a/app/jobs/scheduled/aggregate_web_hooks_events.rb+++ b/app/jobs/scheduled/aggregate_web_hooks_events.rb@@ -5,7 +5,7 @@ module Jobsevery 1.daydef execute(args = {})- date = (args[:date].presence || Time.zone.now.to_date)+ date = args[:date].presence || Time.zone.now.to_dateWebHook.joins("LEFT JOIN web_hook_events_daily_aggregates ON web_hooks.id = web_hook_events_daily_aggregates.web_hook_id AND web_hook_events_daily_aggregates.date = '#{date}'",diff --git a/app/jobs/scheduled/call_discourse_hub.rb b/app/jobs/scheduled/call_discourse_hub.rbindex 4c1808ade45..5ca9e7baa10 100644--- a/app/jobs/scheduled/call_discourse_hub.rb+++ b/app/jobs/scheduled/call_discourse_hub.rb@@ -6,7 +6,7 @@ module Jobsdef execute(args)if SiteSetting.version_checks? &&- (DiscourseUpdates.updated_at.nil? || DiscourseUpdates.updated_at < (1.minute.ago))+ (DiscourseUpdates.updated_at.nil? || DiscourseUpdates.updated_at < 1.minute.ago)beginprev_missing_versions_count = DiscourseUpdates.missing_versions_count || 0@@ -18,8 +18,8 @@ module JobsDiscourseUpdates.updated_at = Time.zone.nowDiscourseUpdates.missing_versions = json["versions"]- if SiteSetting.new_version_emails && json["missingVersionsCount"] > (0) &&- prev_missing_versions_count < (json["missingVersionsCount"].to_i)+ if SiteSetting.new_version_emails && json["missingVersionsCount"] > 0 &&+ prev_missing_versions_count < json["missingVersionsCount"].to_imessage = VersionMailer.send_noticeEmail::Sender.new(message, :new_version).sendenddiff --git a/app/jobs/scheduled/periodical_updates.rb b/app/jobs/scheduled/periodical_updates.rbindex b58cef4d70f..93818b2641c 100644--- a/app/jobs/scheduled/periodical_updates.rb+++ b/app/jobs/scheduled/periodical_updates.rb@@ -49,7 +49,7 @@ module Jobs)end- offset = (SiteSetting.max_new_topics).to_i+ offset = SiteSetting.max_new_topics.to_ilast_new_topic = Topic.order("created_at desc").offset(offset).select(:created_at).firstSiteSetting.min_new_topics_time = last_new_topic.created_at.to_i if last_new_topicdiff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rbindex 43bf6d68730..6afc47a5a1a 100644--- a/app/mailers/user_notifications.rb+++ b/app/mailers/user_notifications.rb@@ -78,7 +78,7 @@ class UserNotifications < ActionMailer::Basetemplate: "user_notifications.suspicious_login",locale: user_locale(user),client_ip: opts[:client_ip],- location: (location.presence || I18n.t("staff_action_logs.unknown")),+ location: location.presence || I18n.t("staff_action_logs.unknown"),browser: I18n.t("user_auth_tokens.browser.#{browser}"),device: I18n.t("user_auth_tokens.device.#{device}"),os: I18n.t("user_auth_tokens.os.#{os}"),@@ -730,7 +730,7 @@ class UserNotifications < ActionMailer::Baseelsereached_limit = SiteSetting.max_emails_per_day_per_user > 0reached_limit &&=- (EmailLog.where(user_id: user.id).where("created_at > ?", 1.day.ago).count) >=+ EmailLog.where(user_id: user.id).where("created_at > ?", 1.day.ago).count >=(SiteSetting.max_emails_per_day_per_user - 1)in_reply_to_post = post.reply_to_post if user.user_option.email_in_reply_todiff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rbindex 50222713526..3abbb44f78a 100644--- a/app/models/api_key_scope.rb+++ b/app/models/api_key_scope.rb@@ -314,10 +314,8 @@ class ApiKeyScope < ActiveRecord::Baseaction = "#{defaults[:controller]}##{defaults[:action]}"path = route.path.spec.to_s.gsub(/\(\.:format\)/, "")api_supported_path =- (- path.end_with?(".rss") || !route.path.requirements[:format] ||- route.path.requirements[:format].match?("json")- )+ path.end_with?(".rss") || !route.path.requirements[:format] ||+ route.path.requirements[:format].match?("json")excluded_paths = %w[/new-topic /new-message /exception]if actions.include?(action) && api_supported_path && !excluded_paths.include?(path)diff --git a/app/models/category.rb b/app/models/category.rbindex fb4445cc39b..0b8eae747b5 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -983,14 +983,14 @@ class Category < ActiveRecord::Basedef self.query_parent_category(parent_slug)encoded_parent_slug = CGI.escape(parent_slug) if SiteSetting.slug_generation_method == "encoded"- self.where(slug: (encoded_parent_slug || parent_slug), parent_category_id: nil).pick(:id) ||+ self.where(slug: encoded_parent_slug || parent_slug, parent_category_id: nil).pick(:id) ||self.where(id: parent_slug.to_i).pick(:id)enddef self.query_category(slug_or_id, parent_category_id)encoded_slug_or_id = CGI.escape(slug_or_id) if SiteSetting.slug_generation_method == "encoded"self.where(- slug: (encoded_slug_or_id || slug_or_id),+ slug: encoded_slug_or_id || slug_or_id,parent_category_id: parent_category_id,).first || self.where(id: slug_or_id.to_i, parent_category_id: parent_category_id).firstend@@ -1001,7 +1001,7 @@ class Category < ActiveRecord::Basedef has_children?return @has_children if defined?(@has_children)- @has_children = (id && Category.where(parent_category_id: id).exists?)+ @has_children = id && Category.where(parent_category_id: id).exists?enddef uncategorized?diff --git a/app/models/concerns/positionable.rb b/app/models/concerns/positionable.rbindex 66b854f97be..da31d48838d 100644--- a/app/models/concerns/positionable.rb+++ b/app/models/concerns/positionable.rb@@ -8,7 +8,7 @@ module Positionabledef move_to(position_arg)position = [[position_arg, 0].max, self.class.count - 1].min- if self.position.nil? || position > (self.position)+ if self.position.nil? || position > self.positionDB.exec "UPDATE #{self.class.table_name}SET position = position - 1diff --git a/app/models/emoji.rb b/app/models/emoji.rbindex 807e08a8337..5ae30220ac4 100644--- a/app/models/emoji.rb+++ b/app/models/emoji.rb@@ -373,7 +373,7 @@ class Emojicodepoints = code.codepointscodepoints.delete_at(1) if codepoints[1] == 0xfe0f- toned_code = (codepoints.insert(1, scale.to_i(16))).pack("U*")+ toned_code = codepoints.insert(1, scale.to_i(16)).pack("U*")map["#{e["name"]}:t#{index + 2}"] = toned_codeendenddiff --git a/app/models/group.rb b/app/models/group.rbindex 7d3357854be..1146e1659ca 100644--- a/app/models/group.rb+++ b/app/models/group.rb@@ -1065,7 +1065,7 @@ class Group < ActiveRecord::Basedomains =Group.get_valid_email_domains(self.automatic_membership_email_domains) do |domain|- self.errors.add :base, (I18n.t("groups.errors.invalid_domain", domain: domain))+ self.errors.add :base, I18n.t("groups.errors.invalid_domain", domain: domain)endmax_domains = SiteSetting.max_automatic_membership_email_domainsdiff --git a/app/models/incoming_link.rb b/app/models/incoming_link.rbindex 0212cd79b4f..feb47e2e906 100644--- a/app/models/incoming_link.rb+++ b/app/models/incoming_link.rb@@ -39,7 +39,7 @@ class IncomingLink < ActiveRecord::Basepost_id ||=Post.where(topic_id: opts[:topic_id], post_number: opts[:post_number] || 1).pick(:id)- cid = current_user ? (current_user.id) : (nil)+ cid = current_user ? current_user.id : nilip_address = nil if cidunless cid && cid == user_iddiff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rbindex 4cc7de68d5e..28a3b017b1e 100644--- a/app/models/optimized_image.rb+++ b/app/models/optimized_image.rb@@ -37,7 +37,7 @@ class OptimizedImage < ActiveRecord::Basereturn if upload.try(:sha1).blank?# no extension so try to guess it- upload.fix_image_extension if (!upload.extension)+ upload.fix_image_extension if !upload.extensionif !upload.extension.match?(IM_DECODERS)if opts[:raise_on_error]@@ -206,7 +206,7 @@ class OptimizedImage < ActiveRecord::Base# such as generating the loading upload thumbnail, we force the format,# and this allows us to use the forced format in that case.extension = nil- if (opts[:format] && path != ext_path)+ if opts[:format] && path != ext_pathextension = File.extname(path)[1..-1]elseextension = File.extname(opts[:filename] || ext_path || path)[1..-1]diff --git a/app/models/post.rb b/app/models/post.rbindex 5a039627dd6..22cf285253d 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -282,7 +282,7 @@ class Post < ActiveRecord::Basedef matches_recent_post?post_id = Discourse.redis.get(unique_post_key)- post_id != (nil) && post_id.to_i != (id)+ post_id != nil && post_id.to_i != idenddef raw_hashdiff --git a/app/models/report.rb b/app/models/report.rbindex 4f38f290e04..3b1a65095a6 100644--- a/app/models/report.rb+++ b/app/models/report.rb@@ -411,7 +411,7 @@ class Reportreport.total = data.sum(:count)report.prev30Days =- data.where("date >= ? AND date < ?", (report.start_date - 31.days), report.start_date).sum(+ data.where("date >= ? AND date < ?", report.start_date - 31.days, report.start_date).sum(:count,)enddiff --git a/app/models/reviewable_flagged_post.rb b/app/models/reviewable_flagged_post.rbindex a24adfc9faf..a1ce92e0eff 100644--- a/app/models/reviewable_flagged_post.rb+++ b/app/models/reviewable_flagged_post.rb@@ -41,7 +41,7 @@ class ReviewableFlaggedPost < Reviewableenddef post- @post ||= (target || Post.with_deleted.find_by(id: target_id))+ @post ||= target || Post.with_deleted.find_by(id: target_id)enddef build_actions(actions, guardian, args)diff --git a/app/models/reviewable_post.rb b/app/models/reviewable_post.rbindex 8e46077b02f..2ed8b525893 100644--- a/app/models/reviewable_post.rb+++ b/app/models/reviewable_post.rb@@ -127,7 +127,7 @@ class ReviewablePost < Reviewableprivatedef post- @post ||= (target || Post.with_deleted.find_by(id: target_id))+ @post ||= target || Post.with_deleted.find_by(id: target_id)endenddiff --git a/app/models/screened_email.rb b/app/models/screened_email.rbindex 9a09bd8ee07..b1c8ad7f42e 100644--- a/app/models/screened_email.rb+++ b/app/models/screened_email.rb@@ -53,7 +53,7 @@ class ScreenedEmail < ActiveRecord::Basedef self.levenshtein(first, second)matrix = [(0..first.length).to_a]- (1..second.length).each { |j| matrix << [j] + [0] * (first.length) }+ (1..second.length).each { |j| matrix << [j] + [0] * first.length }(1..second.length).each do |i|(1..first.length).each do |j|diff --git a/app/models/sidebar_section_link.rb b/app/models/sidebar_section_link.rbindex 6776a00bec8..5b625ce27b5 100644--- a/app/models/sidebar_section_link.rb+++ b/app/models/sidebar_section_link.rb@@ -28,7 +28,7 @@ class SidebarSectionLink < ActiveRecord::Baseenddef ensure_supported_linkable_type- if (!SUPPORTED_LINKABLE_TYPES.include?(self.linkable_type)) ||+ if !SUPPORTED_LINKABLE_TYPES.include?(self.linkable_type) ||(self.linkable_type == "Tag" && !SiteSetting.tagging_enabled)self.errors.add(:linkable_type,diff --git a/app/models/theme.rb b/app/models/theme.rbindex bf26083820f..bf6b2c2ef62 100644--- a/app/models/theme.rb+++ b/app/models/theme.rb@@ -454,7 +454,7 @@ class Theme < ActiveRecord::Basereturn "" if theme_id.blank?theme_ids = !skip_transformation ? transform_ids(theme_id) : [theme_id]- resolved = (resolve_baked_field(theme_ids, target.to_sym, field) || "")+ resolved = resolve_baked_field(theme_ids, target.to_sym, field) || ""resolved = resolved.gsub(ThemeField::CSP_NONCE_PLACEHOLDER, csp_nonce) if csp_nonceresolved.html_safeenddiff --git a/app/models/topic.rb b/app/models/topic.rbindex f232268f45e..d5b143e08b0 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -196,7 +196,7 @@ class Topic < ActiveRecord::Basemax_emojis: true,unique_among: {unless:- Proc.new { |t| (SiteSetting.allow_duplicate_topic_titles? || t.private_message?) },+ Proc.new { |t| SiteSetting.allow_duplicate_topic_titles? || t.private_message? },message: :has_already_been_used,allow_blank: true,case_sensitive: false,@@ -1468,7 +1468,7 @@ class Topic < ActiveRecord::Basepost = self.ordered_posts.firsthtml = post.cooked- if (guardian && ContentLocalization.show_translated_post?(post, guardian))+ if guardian && ContentLocalization.show_translated_post?(post, guardian)html = post.get_localization&.cooked.presence || htmlend@@ -1716,7 +1716,7 @@ class Topic < ActiveRecord::Baseelsif topic_timer.status_type == TopicTimer.types[:delete_replies]if duration_minutes > 0first_reply_created_at =- (self.ordered_posts.where("post_number > 1").minimum(:created_at) || time_now)+ self.ordered_posts.where("post_number > 1").minimum(:created_at) || time_nowtopic_timer.duration_minutes = duration_minutestopic_timer.execute_at = first_reply_created_at + duration_minutes.minutestopic_timer.created_at = first_reply_created_atdiff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rbindex 81663e991fa..48de799dd34 100644--- a/app/models/topic_embed.rb+++ b/app/models/topic_embed.rb@@ -229,7 +229,7 @@ class TopicEmbed < ActiveRecord::Base.each do |node|url_param = tags[node.name]src = node[url_param]- unless (src.nil? || src.empty?)+ unless src.nil? || src.empty?begin# convert URL to absolute formnode[url_param] = URI.join(url, UrlHelper.normalized_encode(src)).to_sdiff --git a/app/models/topic_list.rb b/app/models/topic_list.rbindex bbb9d58d88c..cc810d51b85 100644--- a/app/models/topic_list.rb+++ b/app/models/topic_list.rb@@ -106,7 +106,7 @@ class TopicListgroup_ids = []@topics.each do |ft|user_ids << ft.user_id << ft.last_post_user_id << ft.featured_user_ids << ft.allowed_user_ids- group_ids |= (ft.allowed_group_ids || [])+ group_ids |= ft.allowed_group_ids || []enduser_ids = TopicList.preload_user_ids(@topics, user_ids, self)diff --git a/app/models/topic_timer.rb b/app/models/topic_timer.rbindex c59d06577e5..1f15469b2d8 100644--- a/app/models/topic_timer.rb+++ b/app/models/topic_timer.rb@@ -38,7 +38,7 @@ class TopicTimer < BaseTimer# which change the topic's status straight away and set a timer to do the# opposite action in the future.after_save do- if (saved_change_to_execute_at? || saved_change_to_user_id?)+ if saved_change_to_execute_at? || saved_change_to_user_id?if status_type == TopicTimer.types[:silent_close] || status_type == TopicTimer.types[:close]topic.update_status("closed", false, user) if topic.closed?enddiff --git a/app/models/topic_tracking_state.rb b/app/models/topic_tracking_state.rbindex b224b74f063..b2f5f6664bf 100644--- a/app/models/topic_tracking_state.rb+++ b/app/models/topic_tracking_state.rb@@ -581,8 +581,8 @@ class TopicTrackingStategroups.each do |group|member = group.members.include?(user_id)- member_writing = (write_event && member)- non_member_reading = (!write_event && !member)+ member_writing = write_event && member+ non_member_reading = !write_event && !membernext if non_member_reading || member_writinggroups_to_update << groupdiff --git a/app/models/trust_level3_requirements.rb b/app/models/trust_level3_requirements.rbindex 54370441a0e..1e2ab4e7927 100644--- a/app/models/trust_level3_requirements.rb+++ b/app/models/trust_level3_requirements.rb@@ -33,7 +33,7 @@ class TrustLevel3Requirementsdef requirements_met?return false if trust_level_locked- ([email protected]?) && ([email protected]?) && penalty_counts.total == 0 &&+ [email protected]? && [email protected]? && penalty_counts.total == 0 &&days_visited >= min_days_visited && num_topics_replied_to >= min_topics_replied_to &&topics_viewed >= min_topics_viewed && posts_read >= min_posts_read &&num_flagged_posts <= max_flagged_posts && num_flagged_by_users <= max_flagged_by_users &&diff --git a/app/models/upload.rb b/app/models/upload.rbindex 2100367cc4f..60c5c2ebd44 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -155,7 +155,7 @@ class Upload < ActiveRecord::Basedef get_optimized_image(width, height, opts = nil)opts ||= {}- fix_image_extension if (!extension || extension.length == 0)+ fix_image_extension if !extension || extension.length == 0opts = opts.merge(raise_on_error: true)begindiff --git a/app/models/user.rb b/app/models/user.rbindex b5a8bae086e..c2e75a5a9f6 100644--- a/app/models/user.rb+++ b/app/models/user.rb@@ -559,14 +559,11 @@ class User < ActiveRecord::Base# Sometimes the system user doesn't have their auto groups# from some strange edge case, this handles it.- if (- is_system_user? &&- (- (- Group.auto_groups_between(:admins, :trust_level_4) - [Group::AUTO_GROUPS[:anonymous]]- ) & group_ids- ).any?- )+ if is_system_user? &&+ (+ (Group.auto_groups_between(:admins, :trust_level_4) - [Group::AUTO_GROUPS[:anonymous]]) &+ group_ids+ ).any?return trueend@@ -873,7 +870,7 @@ class User < ActiveRecord::Basenotification = notifications.visible.order("notifications.created_at desc").firstjson = NotificationSerializer.new(notification).as_json if notification- sql = (<<~SQL)+ sql = <<~SQLSELECT * FROM (SELECT n.id, n.read FROM notifications nLEFT JOIN topics t ON n.topic_id = t.iddiff --git a/app/models/user_archived_message.rb b/app/models/user_archived_message.rbindex ae909608257..f47bccf4432 100644--- a/app/models/user_archived_message.rb+++ b/app/models/user_archived_message.rb@@ -7,13 +7,11 @@ class UserArchivedMessage < ActiveRecord::Basedef self.move_to_inbox!(user_id, topic)topic_id = topic.id- if (- TopicUser.where(- user_id: user_id,- topic_id: topic_id,- notification_level: TopicUser.notification_levels[:muted],- ).exists?- )+ if TopicUser.where(+ user_id: user_id,+ topic_id: topic_id,+ notification_level: TopicUser.notification_levels[:muted],+ ).exists?returnenddiff --git a/app/models/user_auth_token.rb b/app/models/user_auth_token.rbindex 3c5285a8a01..d77e400224d 100644--- a/app/models/user_auth_token.rb+++ b/app/models/user_auth_token.rb@@ -240,8 +240,8 @@ class UserAuthToken < ActiveRecord::Baseenddef rotate!(info = nil)- user_agent = (info && info[:user_agent] || self.user_agent)- client_ip = (info && info[:client_ip] || self.client_ip)+ user_agent = info && info[:user_agent] || self.user_agent+ client_ip = info && info[:client_ip] || self.client_iptoken = SecureRandom.hex(16)diff --git a/app/models/user_profile.rb b/app/models/user_profile.rbindex 8ee06a3e3d1..69081db6fde 100644--- a/app/models/user_profile.rb+++ b/app/models/user_profile.rb@@ -133,7 +133,7 @@ class UserProfile < ActiveRecord::Basetype: type,).create_for(user.id)- if (is_card_background)+ if is_card_backgrounduser.user_profile.upload_card_background(upload)elseuser.user_profile.upload_profile_background(upload)@@ -194,7 +194,7 @@ class UserProfile < ActiveRecord::Basedef website_domain_validatorallowed_domains = SiteSetting.allowed_user_website_domains- return if (allowed_domains.blank? || self.website.blank?)+ return if allowed_domains.blank? || self.website.blank?domain =begin@@ -203,11 +203,9 @@ class UserProfile < ActiveRecord::Baseendif allowed_domains.split("|").exclude?(domain)self.errors.add :base,- (- I18n.t(- "user.website.domain_not_allowed",- domains: allowed_domains.split("|").join(", "),- )+ I18n.t(+ "user.website.domain_not_allowed",+ domains: allowed_domains.split("|").join(", "),)endenddiff --git a/app/serializers/category_badge_serializer.rb b/app/serializers/category_badge_serializer.rbindex 69fa095653f..84168d42883 100644--- a/app/serializers/category_badge_serializer.rb+++ b/app/serializers/category_badge_serializer.rb@@ -20,7 +20,7 @@ class CategoryBadgeSerializer < ApplicationSerializerreturn I18n.t("uncategorized_category_name") if object.uncategorized?translated =- if (ContentLocalization.show_translated_category?(object, scope))+ if ContentLocalization.show_translated_category?(object, scope)object.get_localization&.nameelseobject.namediff --git a/app/serializers/category_detailed_serializer.rb b/app/serializers/category_detailed_serializer.rbindex 39197008e2b..1674e9ff302 100644--- a/app/serializers/category_detailed_serializer.rb+++ b/app/serializers/category_detailed_serializer.rb@@ -57,7 +57,7 @@ class CategoryDetailedSerializer < BasicCategorySerializerdef count_with_subcategories(method)count = object.public_send(method) || 0- object.subcategories.each { |category| count += (category.public_send(method) || 0) }+ object.subcategories.each { |category| count += category.public_send(method) || 0 }countenddiff --git a/app/serializers/detailed_user_badge_serializer.rb b/app/serializers/detailed_user_badge_serializer.rbindex 693ceffb0e1..5bc2cc0dfcb 100644--- a/app/serializers/detailed_user_badge_serializer.rb+++ b/app/serializers/detailed_user_badge_serializer.rb@@ -32,8 +32,7 @@ class DetailedUserBadgeSerializer < BasicUserBadgeSerializerenddef can_favorite- SiteSetting.max_favorite_badges > 0 &&- (scope.current_user.present? && object.user_id == scope.current_user.id) &&- !(1..4).include?(object.badge_id)+ SiteSetting.max_favorite_badges > 0 && scope.current_user.present? &&+ object.user_id == scope.current_user.id && !(1..4).include?(object.badge_id)endenddiff --git a/app/serializers/listable_topic_serializer.rb b/app/serializers/listable_topic_serializer.rbindex 9e1db59ea51..7b67b4ecaa3 100644--- a/app/serializers/listable_topic_serializer.rb+++ b/app/serializers/listable_topic_serializer.rb@@ -113,7 +113,7 @@ class ListableTopicSerializer < BasicTopicSerializerdef excerpte = object.excerpt- if (ContentLocalization.show_translated_topic?(object, scope))+ if ContentLocalization.show_translated_topic?(object, scope)object.get_localization&.excerpt.presence || eelseediff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rbindex d24bde7a61a..011f54523ea 100644--- a/app/serializers/post_serializer.rb+++ b/app/serializers/post_serializer.rb@@ -160,15 +160,15 @@ class PostSerializer < BasicPostSerializerenddef moderator?- !!(object&.user&.moderator?)+ !!object&.user&.moderator?enddef admin?- !!(object&.user&.admin?)+ !!object&.user&.admin?enddef staff?- !!(object&.user&.staff?)+ !!object&.user&.staff?enddef group_moderator@@ -741,7 +741,7 @@ class PostSerializer < BasicPostSerializerenddef user_custom_fields_object- (@topic_view&.user_custom_fields || @options[:user_custom_fields] || {})+ @topic_view&.user_custom_fields || @options[:user_custom_fields] || {}enddef topicdiff --git a/app/serializers/site_category_serializer.rb b/app/serializers/site_category_serializer.rbindex beb9c0cb386..b9ed6e093b2 100644--- a/app/serializers/site_category_serializer.rb+++ b/app/serializers/site_category_serializer.rb@@ -41,7 +41,7 @@ class SiteCategorySerializer < BasicCategorySerializerreturn I18n.t("uncategorized_category_name") if object.uncategorized?translated_name =- if (ContentLocalization.show_translated_category?(object, scope))+ if ContentLocalization.show_translated_category?(object, scope)object.get_localization&.nameelseobject.namediff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rbindex 7b3c35b182f..b99384c0d27 100644--- a/app/services/inline_uploads.rb+++ b/app/services/inline_uploads.rb@@ -23,8 +23,8 @@ class InlineUploadsif node.name == "img"# Do nothingelsif !(- node.children.count == 1 &&- (node.children[0].name != "img" && node.children[0].children.blank?)+ node.children.count == 1 && node.children[0].name != "img" &&+ node.children[0].children.blank?) &&!(node.name == "a" && node.children.count > 1 &&@@ -34,7 +34,7 @@ class InlineUploadsendif seen_link = matched_uploads(node).first- if (actual_link = (node.attributes["href"]&.value || node.attributes["src"]&.value))+ if (actual_link = node.attributes["href"]&.value || node.attributes["src"]&.value)link_occurrences << { link: actual_link, is_valid: true }elsif node.name != "p"link_occurrences << { link: seen_link, is_valid: false }@@ -171,7 +171,7 @@ class InlineUploads# matches [img=WxH]url[/img] and [img width=W height=H]url[/img]# in addition to [img]url[/img]markdown.scan(%r{(\[img\b[^\]]*\]\s*([^\[\]\s]+)\s*\[/img\])}i) do |match|- if (external_src || (matched_uploads(match[1]).present?)) && block_given?+ if (external_src || matched_uploads(match[1]).present?) && block_given?yield(match[0], match[1], +"", $~.offset(0)[0])endenddiff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rbindex c1dad02d62f..6e7c8b39aa7 100644--- a/app/services/push_notification_pusher.rb+++ b/app/services/push_notification_pusher.rb@@ -143,7 +143,7 @@ class PushNotificationPusherp256dh = parsed_data.dig("keys", "p256dh")auth = parsed_data.dig("keys", "auth")- if (endpoint.blank? || p256dh.blank? || auth.blank?)+ if endpoint.blank? || p256dh.blank? || auth.blank?subscription.destroy!returnenddiff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rbindex 3ce8c50b8e9..b721b784919 100644--- a/app/services/themes_install_task.rb+++ b/app/services/themes_install_task.rb@@ -80,7 +80,7 @@ class ThemesInstallTaskenddef add_component_to_all_themes- return if ([email protected](:add_to_all_themes, false) || [email protected])+ return if [email protected](:add_to_all_themes, false) || [email protected]Theme.where(component: false)diff --git a/app/services/topic_status_updater.rb b/app/services/topic_status_updater.rbindex 7a5c634f664..42ec7f581b8 100644--- a/app/services/topic_status_updater.rb+++ b/app/services/topic_status_updater.rb@@ -90,10 +90,8 @@ TopicStatusUpdater =# remove featured topics if we close/archive/make them invisible. Previously we used# to run the whole featuring logic but that could be very slow and have concurrency# errors on large sites with many autocloses and topics being created.- if (- (status.enabled? && (status.autoclosed? || status.closed? || status.archived?)) ||- (status.disabled? && status.visible?)- )+ if (status.enabled? && (status.autoclosed? || status.closed? || status.archived?)) ||+ (status.disabled? && status.visible?)CategoryFeaturedTopic.where(topic_id: topic.id).delete_allenddiff --git a/app/services/user_updater.rb b/app/services/user_updater.rbindex c00df7226d4..2d397a71b52 100644--- a/app/services/user_updater.rb+++ b/app/services/user_updater.rb@@ -252,7 +252,7 @@ class UserUpdater(user_notification_schedule.nil? || user_notification_schedule.save) &&user_profile.save && user.save- if saved && (name_changed && old_user_name.casecmp(attributes.fetch(:name)) != 0)+ if saved && name_changed && old_user_name.casecmp(attributes.fetch(:name)) != 0StaffActionLogger.new(@actor).log_name_change(user.id,old_user_name,diff --git a/config/initializers/004-message_bus.rb b/config/initializers/004-message_bus.rbindex 3ac1fdef585..c9c8cdba35c 100644--- a/config/initializers/004-message_bus.rb+++ b/config/initializers/004-message_bus.rb@@ -19,7 +19,7 @@ def setup_message_bus_env(env)if (queue_time = env[Middleware::ProcessingRequest::REQUEST_QUEUE_SECONDS_ENV_KEY]) &&Discourse.redis.get("docker_manager:upgrade:server_restarting").blank?- if queue_time > (GlobalSetting.reject_message_bus_queue_seconds).to_f+ if queue_time > GlobalSetting.reject_message_bus_queue_seconds.to_fraise RateLimiter::LimitExceeded, 30 + (rand * 120).to_iendenddiff --git a/config/initializers/008-rack-cors.rb b/config/initializers/008-rack-cors.rbindex bfd8422da9d..857a82d56c6 100644--- a/config/initializers/008-rack-cors.rb+++ b/config/initializers/008-rack-cors.rb@@ -17,7 +17,7 @@ class Discourse::Corscors_origins += SiteSetting.cors_origins.split("|") if SiteSetting.cors_origins.present?cors_origins = cors_origins.presence- if env["REQUEST_METHOD"] == ("OPTIONS") && env["HTTP_ACCESS_CONTROL_REQUEST_METHOD"]+ if env["REQUEST_METHOD"] == "OPTIONS" && env["HTTP_ACCESS_CONTROL_REQUEST_METHOD"]return 200, Discourse::Cors.apply_headers(cors_origins, env, {}), []enddiff --git a/config/initializers/100-logster.rb b/config/initializers/100-logster.rbindex c7360abe673..8147a281753 100644--- a/config/initializers/100-logster.rb+++ b/config/initializers/100-logster.rb@@ -7,7 +7,7 @@ if GlobalSetting.skip_redis?returnend-if (Rails.env.local?) && ENV["FORCE_RAILS_LOGS_STDOUT"] == "1"+if Rails.env.local? && ENV["FORCE_RAILS_LOGS_STDOUT"] == "1"Rails.logger = Logger.new(STDOUT)returnenddiff --git a/config/initializers/100-session_store.rb b/config/initializers/100-session_store.rbindex 42868c72ab2..de12a6f4609 100644--- a/config/initializers/100-session_store.rb+++ b/config/initializers/100-session_store.rb@@ -7,7 +7,7 @@ Rails.application.config.session_store(key: "_forum_session",path:(- if (Rails.application.config.relative_url_root.nil?)+ if Rails.application.config.relative_url_root.nil?"/"elseRails.application.config.relative_url_rootdiff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rbindex 32e9770da36..542e744455e 100644--- a/config/initializers/101-lograge.rb+++ b/config/initializers/101-lograge.rb@@ -118,7 +118,7 @@ if DiscourseLograge.enabled?output["request.headers.http_accept_language"] = http_accept_language_request_headerend- if data = (Thread.current[:_method_profiler] || event.payload[:timings])+ if data = Thread.current[:_method_profiler] || event.payload[:timings]if sql = data[:sql]output[:db] = sql[:duration] * 1000output[:db_calls] = sql[:calls]diff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rbindex dd014550dac..9c9928e91ad 100644--- a/config/initializers/200-first_middlewares.rb+++ b/config/initializers/200-first_middlewares.rb@@ -61,14 +61,12 @@ if Rails.env.test?def call(env)request = Rack::Request.new(env)- if (- @@block_requests ||- (- request.xhr? && self.class.current_example_location.present? &&- self.class.current_example_location !=- request.cookies[RSPEC_CURRENT_EXAMPLE_COOKIE_STRING]- )- )+ if @@block_requests ||+ (+ request.xhr? && self.class.current_example_location.present? &&+ self.class.current_example_location !=+ request.cookies[RSPEC_CURRENT_EXAMPLE_COOKIE_STRING]+ )return [503,{ "Content-Type" => "text/plain" },diff --git a/config/locales/plurals.rb b/config/locales/plurals.rbindex d179e168930..6e5d1225354 100644--- a/config/locales/plurals.rb+++ b/config/locales/plurals.rb@@ -130,15 +130,13 @@(n.to_f % 10 == 1 && n.to_f % 100 != 11) ?:one :(- (((n.to_f % 10) % 1).zero? && (2..4).include?(n.to_f % 10)) &&- (((n.to_f % 100) % 1).zero? && !(12..14).include?(n.to_f % 100))+ ((n.to_f % 10) % 1).zero? && (2..4).include?(n.to_f % 10) &&+ ((n.to_f % 100) % 1).zero? && !(12..14).include?(n.to_f % 100)) ?:few :- if (- n.to_f % 10 == 0 ||+ if n.to_f % 10 == 0 ||(((n.to_f % 10) % 1).zero? && (5..9).include?(n.to_f % 10)) ||(((n.to_f % 100) % 1).zero? && (11..14).include?(n.to_f % 100))- ):manyelse:other@@ -223,15 +221,9 @@(n.to_f % 10) == 9 ||(((n.to_f % 10) % 1).zero? && (3..4).include?(n.to_f % 10))) &&- (- (- ((n.to_f % 100) % 1).zero? &&- (- !(10..19).include?(n.to_f % 100) && !(70..79).include?(n.to_f % 100) &&+ ((n.to_f % 100) % 1).zero? &&+ !(10..19).include?(n.to_f % 100) && !(70..79).include?(n.to_f % 100) &&!(90..99).include?(n.to_f % 100)- )- )- )) ?:few :(n.to_f != 0 && n.to_f % 1_000_000 == 0) ? :many : :other@@ -270,7 +262,6 @@) ?:one :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(2..4).include?(n.to_i % 10) && !(12..14).include?(n.to_i % 100)) ||@@ -278,7 +269,6 @@(2..4).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10) &&!(12..14).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100))- ):fewelse:other@@ -306,8 +296,7 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && [1, 2, 3].include?(n.to_i)) ||+ if (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && [1, 2, 3].include?(n.to_i)) ||(((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&![4, 6, 9].include?(n.to_i % 10)@@ -316,7 +305,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) != 0 &&![4, 6, 9].include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10))- ):oneelse:other@@ -412,13 +400,11 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- if (- n.to_f == 1 ||+ if n.to_f == 1 ||(((t = n.to_s.split(".")[1]) ? t.gsub(/0+$/, "").to_i : 0) != 0 &&[0, 1].include?(n.to_i))- ):oneelse:other@@ -469,11 +455,9 @@) ?:two :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(3..4).include?(n.to_i % 100)) || (3..4).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100)- ):fewelse:other@@ -564,11 +548,9 @@n.to_f == 1 ?:one :if (- ((e = 0) == 0 && n.to_i != 0 && n.to_i % 1_000_000 == 0 &&((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) || !(0..5).include?(e = 0)- ):manyelse:other@@ -632,8 +614,7 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && [1, 2, 3].include?(n.to_i)) ||+ if (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && [1, 2, 3].include?(n.to_i)) ||(((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&![4, 6, 9].include?(n.to_i % 10)@@ -642,7 +623,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) != 0 &&![4, 6, 9].include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10))- ):oneelse:other@@ -685,11 +665,9 @@[0, 1].include?(n.to_i) ?:one :if (- ((e = 0) == 0 && n.to_i != 0 && n.to_i % 1_000_000 == 0 &&((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) || !(0..5).include?(e = 0)- ):manyelse:other@@ -751,7 +729,7 @@:one :[2, 12].include?(n.to_f) ?:two :- if (((n.to_f % 1).zero? && ((3..10).include?(n.to_f) || (13..19).include?(n.to_f))))+ if (n.to_f % 1).zero? && ((3..10).include?(n.to_f) || (13..19).include?(n.to_f)):fewelse:other@@ -852,10 +830,8 @@:one :(n.to_i == 2 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ?:two :- if (- ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&- ((n.to_f % 1).zero? && !(0..10).include?(n.to_f)) && n.to_f % 10 == 0- )+ if ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&+ (n.to_f % 1).zero? && !(0..10).include?(n.to_f) && n.to_f % 10 == 0:manyelse:other@@ -895,7 +871,6 @@) ?:one :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(2..4).include?(n.to_i % 10) && !(12..14).include?(n.to_i % 100)) ||@@ -903,7 +878,6 @@(2..4).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10) &&!(12..14).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100))- ):fewelse:other@@ -930,11 +904,9 @@) ?:two :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(3..4).include?(n.to_i % 100)) || (3..4).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100)- ):fewelse:other@@ -1023,11 +995,9 @@lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)if (- (((t = n.to_s.split(".")[1]) ? t.gsub(/0+$/, "").to_i : 0) == 0 &&n.to_i % 10 == 1 && n.to_i % 100 != 11) || ((t = n.to_s.split(".")[1]) ? t.gsub(/0+$/, "").to_i : 0) != 0- ):oneelse:other@@ -1046,11 +1016,9 @@(n.to_i == 1 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ?:one :if (- ((e = 0) == 0 && n.to_i != 0 && n.to_i % 1_000_000 == 0 &&((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) || !(0..5).include?(e = 0)- ):manyelse:other@@ -1398,11 +1366,11 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- (n.to_f % 10 == 1 && (((n.to_f % 100) % 1).zero? && !(11..19).include?(n.to_f % 100))) ?+ (n.to_f % 10 == 1 && ((n.to_f % 100) % 1).zero? && !(11..19).include?(n.to_f % 100)) ?:one :(- (((n.to_f % 10) % 1).zero? && (2..9).include?(n.to_f % 10)) &&- (((n.to_f % 100) % 1).zero? && !(11..19).include?(n.to_f % 100))+ ((n.to_f % 10) % 1).zero? && (2..9).include?(n.to_f % 10) &&+ ((n.to_f % 100) % 1).zero? && !(11..19).include?(n.to_f % 100)) ?:few :((f = n.to_s.split(".")[1]) ? f.to_i : 0) != 0 ? :many : :other@@ -1425,8 +1393,7 @@)) ?:zero :- if (- (n.to_f % 10 == 1 && n.to_f % 100 != 11) ||+ if (n.to_f % 10 == 1 && n.to_f % 100 != 11) ||(((v = n.to_s.split(".")[1]) ? v.length : 0) == 2 &&((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10 == 1 &&@@ -1436,7 +1403,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) != 2 &&((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10 == 1)- ):oneelse:other@@ -1489,7 +1455,6 @@lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 10 == 1 &&n.to_i % 100 != 11) ||@@ -1497,7 +1462,6 @@((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10 == 1 &&((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100 != 11)- ):oneelse:other@@ -1765,7 +1729,6 @@) ?:few :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i != 1 &&(0..1).include?(n.to_i % 10)) ||@@ -1777,7 +1740,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(12..14).include?(n.to_i % 100))- ):manyelse:other@@ -1808,11 +1770,9 @@(0..1).include?(n.to_i) ?:one :if (- ((e = 0) == 0 && n.to_i != 0 && n.to_i % 1_000_000 == 0 &&((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) || !(0..5).include?(e = 0)- ):manyelse:other@@ -1831,11 +1791,9 @@(n.to_i == 1 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ?:one :if (- ((e = 0) == 0 && n.to_i != 0 && n.to_i % 1_000_000 == 0 &&((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) || !(0..5).include?(e = 0)- ):manyelse:other@@ -1877,10 +1835,8 @@n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)(n.to_i == 1 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ?:one :- if (- ((v = n.to_s.split(".")[1]) ? v.length : 0) != 0 || n.to_f == 0 ||+ if ((v = n.to_s.split(".")[1]) ? v.length : 0) != 0 || n.to_f == 0 ||(((n.to_f % 100) % 1).zero? && (2..19).include?(n.to_f % 100))- ):fewelse:other@@ -1906,8 +1862,7 @@!(12..14).include?(n.to_i % 100)) ?:few :- if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 10 == 0) ||+ if (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 10 == 0) ||(((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(5..9).include?(n.to_i % 10)@@ -1916,7 +1871,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(11..14).include?(n.to_i % 100))- ):manyelse:other@@ -2066,10 +2020,8 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- if (- [0, 1].include?(n.to_f) ||+ if [0, 1].include?(n.to_f) ||(n.to_i == 0 && ((f = n.to_s.split(".")[1]) ? f.to_i : 0) == 1)- ):oneelse:other@@ -2106,11 +2058,9 @@(((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 100 == 2) ?:two :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(3..4).include?(n.to_i % 100)) || ((v = n.to_s.split(".")[1]) ? v.length : 0) != 0- ):fewelse:other@@ -2186,7 +2136,6 @@) ?:one :if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(2..4).include?(n.to_i % 10) && !(12..14).include?(n.to_i % 100)) ||@@ -2194,7 +2143,6 @@(2..4).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 10) &&!(12..14).include?(((f = n.to_s.split(".")[1]) ? f.to_i : 0) % 100))- ):fewelse:other@@ -2342,10 +2290,8 @@rule:lambda do |n|n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1, m.length] : m)- if (- ((n.to_f % 1).zero? && (0..1).include?(n.to_f)) ||+ if ((n.to_f % 1).zero? && (0..1).include?(n.to_f)) ||((n.to_f % 1).zero? && (11..99).include?(n.to_f))- ):oneelse:other@@ -2383,8 +2329,7 @@!(12..14).include?(n.to_i % 100)) ?:few :- if (- (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 10 == 0) ||+ if (((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 && n.to_i % 10 == 0) ||(((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(5..9).include?(n.to_i % 10)@@ -2393,7 +2338,6 @@((v = n.to_s.split(".")[1]) ? v.length : 0) == 0 &&(11..14).include?(n.to_i % 100))- ):manyelse:otherdiff --git a/config/pitchfork.conf.rb b/config/pitchfork.conf.rbindex 675a0c6eb52..26d953a1182 100644--- a/config/pitchfork.conf.rb+++ b/config/pitchfork.conf.rb@@ -29,7 +29,7 @@ endworker_processes (ENV["UNICORN_WORKERS"] || 3).to_i# stree-ignore-listen ENV["UNICORN_LISTENER"] || "#{(ENV["UNICORN_BIND_ALL"] ? "" : "127.0.0.1:")}#{(ENV["UNICORN_PORT"] || 3000).to_i}", reuseport: true+listen ENV["UNICORN_LISTENER"] || "#{ENV["UNICORN_BIND_ALL"] ? "" : "127.0.0.1:"}#{(ENV["UNICORN_PORT"] || 3000).to_i}", reuseport: trueif ENV["RAILS_ENV"] == "production"# nuke workers after 30 seconds instead of 20 seconds (the default)diff --git a/config/routes.rb b/config/routes.rbindex 1310d3e8ec8..94bf9621dcc 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -14,10 +14,7 @@ Discourse::Application.routes.draw doscope path: nil, constraints: { format: %r{(json|html|\*/\*)} } dorelative_url_root =(- if (- defined?(Rails.configuration.relative_url_root) &&- Rails.configuration.relative_url_root- )+ if defined?(Rails.configuration.relative_url_root) && Rails.configuration.relative_url_rootRails.configuration.relative_url_root + "/"else"/"diff --git a/db/migrate/20121204183855_fix_link_post_id.rb b/db/migrate/20121204183855_fix_link_post_id.rbindex bc99f99baa3..5c4423405c6 100644--- a/db/migrate/20121204183855_fix_link_post_id.rb+++ b/db/migrate/20121204183855_fix_link_post_id.rb@@ -11,7 +11,7 @@ class FixLinkPostId < ActiveRecord::Migration[4.2]parsed = URI.parse(tl.url)route = Rails.application.routes.recognize_path(parsed.path)if route[:topic_id].present?- post = Post.find_by(topic_id: route[:topic_id], post_number: (route[:post_number] || 1))+ post = Post.find_by(topic_id: route[:topic_id], post_number: route[:post_number] || 1)tl.update_column(:link_post_id, post.id) if post.present?endrescue ActionController::RoutingErrordiff --git a/db/migrate/20130625170842_remove_access_password.rb b/db/migrate/20130625170842_remove_access_password.rbindex 9b4da8619b0..1874a087524 100644--- a/db/migrate/20130625170842_remove_access_password.rb+++ b/db/migrate/20130625170842_remove_access_password.rb@@ -6,7 +6,7 @@ class RemoveAccessPassword < ActiveRecord::Migration[4.2]execute("SELECT count(*) FROM site_settings where name='access_password' and char_length(value) > 0",)- if result[0] && result[0]["count"].to_i > (0)+ if result[0] && result[0]["count"].to_i > 0execute "DELETE FROM site_settings where name='access_password'"SiteSetting.login_required = trueSiteSetting.must_approve_users = truediff --git a/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb b/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rbindex 4bc76152cc4..289b74f53b6 100644--- a/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb+++ b/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb@@ -8,7 +8,7 @@ class AddShowSubcategoryListToCategories < ActiveRecord::Migration[4.2]execute("select count(1) from site_settings where name = 'show_subcategory_list' and value = 't'",)- if result[0] && result[0]["count"].to_i > (0)+ if result[0] && result[0]["count"].to_i > 0execute "UPDATE categories SET show_subcategory_list = true WHERE parent_category_id IS NULL"endenddiff --git a/lib/auth/default_current_user_provider.rb b/lib/auth/default_current_user_provider.rbindex e1a79c2a9f5..acfc07c0c01 100644--- a/lib/auth/default_current_user_provider.rb+++ b/lib/auth/default_current_user_provider.rb@@ -369,12 +369,12 @@ class Auth::DefaultCurrentUserProvider# api has special rights return true if api was detecteddef is_api?current_user- !!(@env[API_KEY_ENV])+ !!@env[API_KEY_ENV]enddef is_user_api?current_user- !!(@env[USER_API_KEY_ENV])+ !!@env[USER_API_KEY_ENV]enddef has_auth_cookie?diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rbindex e9e1481eafa..435939f83fb 100644--- a/lib/composer_messages_finder.rb+++ b/lib/composer_messages_finder.rb@@ -191,7 +191,7 @@ class ComposerMessagesFinderprivatedef educate_reply?(type)- replying? && @details[:topic_id] && (@topic.present? && [email protected]_message?) &&+ replying? && @details[:topic_id] && @topic.present? && [email protected]_message? &&(@user.post_count >= SiteSetting.educate_until_posts) &&!UserHistory.exists_for_user?(@user, type, topic_id: @details[:topic_id])enddiff --git a/lib/cooked_processor_mixin.rb b/lib/cooked_processor_mixin.rbindex 8db836d9520..646887a95a7 100644--- a/lib/cooked_processor_mixin.rb+++ b/lib/cooked_processor_mixin.rb@@ -429,7 +429,7 @@ module CookedProcessorMixinoriginal_width, original_height = nil- if (upload.present?)+ if upload.present?original_width = upload.width || 0original_height = upload.height || 0elsediff --git a/lib/discourse.rb b/lib/discourse.rbindex 908cf05554c..e5c35535256 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -944,7 +944,7 @@ module DiscourseUser.find_by(username_lower: SiteSetting.site_contact_username.downcase,) if SiteSetting.site_contact_username.present?- user ||= (system_user || User.admins.real.order(:id).first)+ user ||= system_user || User.admins.real.order(:id).firstendSYSTEM_USER_ID = -1diff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex eef09a8179b..6dc9c004e1b 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -963,7 +963,7 @@ module Emailendtarget_post = post_ids.any? && Post.where(id: post_ids).order(:created_at).last- too_old_for_group_smtp = (destination_too_old?(target_post) && group.smtp_enabled)+ too_old_for_group_smtp = destination_too_old?(target_post) && group.smtp_enabledif target_post.blank? || too_old_for_group_smtpcreate_topic(diff --git a/lib/email/styles.rb b/lib/email/styles.rbindex 89f34680ac3..b8dab999fb9 100644--- a/lib/email/styles.rb+++ b/lib/email/styles.rb@@ -77,7 +77,7 @@ module Emailimg["width"] = img["height"] = 20else# use dimensions of original iPhone screen for 'too big, let device rescale'- if img["width"].to_i > (320) || img["height"].to_i > (480)+ if img["width"].to_i > 320 || img["height"].to_i > 480img["width"] = img["height"] = "auto"endend@@ -574,7 +574,7 @@ module Email.css("a").each do |inner|# we want the first footer link to be specially highlighted as IMPORTANT- if footernum == (0) && linknum == (0)+ if footernum == 0 && linknum == 0bg_color = SiteSetting.email_accent_bg_colorinner["style"diff --git a/lib/freedom_patches/request_server_session.rb b/lib/freedom_patches/request_server_session.rbindex 6a850279027..c153f4e2b15 100644--- a/lib/freedom_patches/request_server_session.rb+++ b/lib/freedom_patches/request_server_session.rb@@ -2,7 +2,7 @@module RequestServerSessiondef server_session- session[:server_session_id] ||= (session.delete(:secure_session_id) || SecureRandom.hex)+ session[:server_session_id] ||= session.delete(:secure_session_id) || SecureRandom.hexServerSession.new(session[:server_session_id])endenddiff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rbindex 46341122fa3..329970c9932 100644--- a/lib/guardian/post_guardian.rb+++ b/lib/guardian/post_guardian.rb@@ -35,7 +35,7 @@ module PostGuardiantaken = opts[:taken_actions].try(:keys).to_apost_action_type_view = opts[:post_action_type_view] || PostActionTypeView.newis_flag =- if (opts[:notify_flag_types] && opts[:additional_message_types])+ if opts[:notify_flag_types] && opts[:additional_message_types]opts[:notify_flag_types][action_key] || opts[:additional_message_types][action_key]elsepost_action_type_view.notify_flag_types[action_key] ||@@ -63,7 +63,7 @@ module PostGuardianreturn false if is_flag && post.hidden?# post made by staff, but we don't allow staff flags- return false if is_flag && (!SiteSetting.allow_flagging_staff?) && post&.user&.staff?+ return false if is_flag && !SiteSetting.allow_flagging_staff? && post&.user&.staff?if is_flag && post_action_type_view.disabled_flag_types.keys.include?(action_key)return false@@ -170,11 +170,9 @@ module PostGuardianreturn false if post.topic&.archived? || post.user_deleted || post.deleted_at# Editing a shared draft.- if (- can_see_post?(post) && can_create_post?(post.topic) &&- post.topic.category_id == SiteSetting.shared_drafts_category.to_i &&- can_see_category?(post.topic.category) && can_see_shared_draft?- )+ if can_see_post?(post) && can_create_post?(post.topic) &&+ post.topic.category_id == SiteSetting.shared_drafts_category.to_i &&+ can_see_category?(post.topic.category) && can_see_shared_draft?return trueend@@ -236,10 +234,7 @@ module PostGuardian# You can delete your own postsif is_my_own?(post)- if (- SiteSetting.max_post_deletions_per_minute < 1 ||- SiteSetting.max_post_deletions_per_day < 1- )+ if SiteSetting.max_post_deletions_per_minute < 1 || SiteSetting.max_post_deletions_per_day < 1return falseendreturn true if !post.user_deleted?@@ -264,14 +259,11 @@ module PostGuardianreturn false unless post# PERF, vast majority of the time topic will not be deleted- topic = (post.topic || Topic.with_deleted.find(post.topic_id)) if post.topic_id+ topic = post.topic || Topic.with_deleted.find(post.topic_id) if post.topic_idreturn true if can_moderate_topic?(topic) && !!post.deleted_atif is_my_own?(post)- if (- SiteSetting.max_post_deletions_per_minute < 1 ||- SiteSetting.max_post_deletions_per_day < 1- )+ if SiteSetting.max_post_deletions_per_minute < 1 || SiteSetting.max_post_deletions_per_day < 1return falseendreturn true if post.user_deleted && !post.deleted_atdiff --git a/lib/guardian/topic_guardian.rb b/lib/guardian/topic_guardian.rbindex cbc186a792d..c761a5a3ad0 100644--- a/lib/guardian/topic_guardian.rb+++ b/lib/guardian/topic_guardian.rb@@ -4,7 +4,7 @@module TopicGuardiandef can_remove_allowed_users?(topic, target_user = nil)is_staff? || (is_my_own?(topic) && @user.has_trust_level?(TrustLevel[2])) ||- (topic.allowed_users.count > 1 && topic.user != target_user && !!(is_me?(target_user)))+ (topic.allowed_users.count > 1 && topic.user != target_user && !!is_me?(target_user))enddef can_review_topic?(topic)@@ -102,33 +102,25 @@ module TopicGuardian# can't edit topics in secured categories where you don't have permission to create topics# except for a tiny edge case where the topic is uncategorized and you are trying# to fix it but uncategorized is disabled- if (- SiteSetting.allow_uncategorized_topics ||- topic.category_id != SiteSetting.uncategorized_category_id- )+ if SiteSetting.allow_uncategorized_topics ||+ topic.category_id != SiteSetting.uncategorized_category_idreturn false if !can_create_topic_on_category?(topic.category)end# Editing a shared draft.- if (- !topic.archived && !topic.private_message? &&- topic.category_id == SiteSetting.shared_drafts_category.to_i &&- can_see_category?(topic.category) && can_see_shared_draft? && can_create_post?(topic)- )+ if !topic.archived && !topic.private_message? &&+ topic.category_id == SiteSetting.shared_drafts_category.to_i &&+ can_see_category?(topic.category) && can_see_shared_draft? && can_create_post?(topic)return trueend- if (- is_in_edit_post_groups? && topic.archived && !topic.private_message? &&- can_create_post?(topic)- )+ if is_in_edit_post_groups? && topic.archived && !topic.private_message? &&+ can_create_post?(topic)return trueend- if (- is_in_edit_topic_groups? && !topic.archived && !topic.private_message? &&- can_create_post?(topic)- )+ if is_in_edit_topic_groups? && !topic.archived && !topic.private_message? &&+ can_create_post?(topic)return trueenddiff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rbindex bf66211908f..2093bdf3e67 100644--- a/lib/new_post_manager.rb+++ b/lib/new_post_manager.rb@@ -88,10 +88,8 @@ class NewPostManagerreturn :email_spam if manager.args[:email_spam]- if (- user.trust_level <= TrustLevel.levels[:basic] &&- (user.post_count + user.topic_count) < SiteSetting.approve_post_count- )+ if user.trust_level <= TrustLevel.levels[:basic] &&+ (user.post_count + user.topic_count) < SiteSetting.approve_post_countreturn :post_countend@@ -99,10 +97,8 @@ class NewPostManagerreturn :groupend- if (- manager.args[:title].present? && !user.staged? &&- !user.in_any_groups?(SiteSetting.approve_new_topics_unless_allowed_groups_map)- )+ if manager.args[:title].present? && !user.staged? &&+ !user.in_any_groups?(SiteSetting.approve_new_topics_unless_allowed_groups_map)return :new_topics_unless_allowed_groupsend@@ -118,10 +114,8 @@ class NewPostManagerreturn :category if post_needs_approval_in_its_category?(manager)- if (- manager.args[:image_sizes].present? &&- !user.in_any_groups?(SiteSetting.skip_review_media_groups_map)- )+ if manager.args[:image_sizes].present? &&+ !user.in_any_groups?(SiteSetting.skip_review_media_groups_map)return :contains_mediaend@@ -209,13 +203,9 @@ class NewPostManagerdef self.queue_enabled?SiteSetting.approve_post_count > 0 ||- !(- SiteSetting.approve_unless_allowed_groups_map.include?(Group::AUTO_GROUPS[:trust_level_0])- ) ||- !(- SiteSetting.approve_new_topics_unless_allowed_groups_map.include?(- Group::AUTO_GROUPS[:trust_level_0],- )+ !SiteSetting.approve_unless_allowed_groups_map.include?(Group::AUTO_GROUPS[:trust_level_0]) ||+ !SiteSetting.approve_new_topics_unless_allowed_groups_map.include?(+ Group::AUTO_GROUPS[:trust_level_0],) || SiteSetting.approve_unless_staged ||WordWatcher.words_for_action_exist?(:require_approval) || handlers.size > 1enddiff --git a/lib/onebox/engine/allowlisted_generic_onebox.rb b/lib/onebox/engine/allowlisted_generic_onebox.rbindex b2cdc04783c..622ac8d74ea 100644--- a/lib/onebox/engine/allowlisted_generic_onebox.rb+++ b/lib/onebox/engine/allowlisted_generic_onebox.rb@@ -73,9 +73,9 @@ module Oneboxenddef placeholder_html- return article_html if (is_article? || force_article_html?)+ return article_html if is_article? || force_article_html?return image_html if is_image?- return Onebox::Helpers.video_placeholder_html if (is_video? || is_card?)+ return Onebox::Helpers.video_placeholder_html if is_video? || is_card?return Onebox::Helpers.generic_placeholder_html if is_embedded?to_htmlend@@ -184,13 +184,13 @@ module Oneboxenddef generic_html- return article_html if (is_article? || force_article_html?)+ return article_html if is_article? || force_article_html?return video_html if is_video?return image_html if is_image?return embedded_html if is_embedded?return card_html if is_card?- article_html if (has_text? || is_image_article?)+ article_html if has_text? || is_image_article?enddef is_card?diff --git a/lib/onebox/engine/amazon_onebox.rb b/lib/onebox/engine/amazon_onebox.rbindex 9d9830d72e3..20349dbcd3c 100644--- a/lib/onebox/engine/amazon_onebox.rb+++ b/lib/onebox/engine/amazon_onebox.rb@@ -183,7 +183,7 @@ module Onebox"//div[@id='a-popover-mobile-udp-contributor-popover-id']//span[contains(@class,'a-text-bold')]",)else- (raw.at("#byline")&.inner_text&.strip || raw.at("#bylineInfo")&.inner_text&.strip)+ raw.at("#byline")&.inner_text&.strip || raw.at("#bylineInfo")&.inner_text&.stripend)rating =diff --git a/lib/onebox/engine/pubmed_onebox.rb b/lib/onebox/engine/pubmed_onebox.rbindex 79139d194db..d9d001a5f2a 100644--- a/lib/onebox/engine/pubmed_onebox.rb+++ b/lib/onebox/engine/pubmed_onebox.rb@@ -24,7 +24,7 @@ module Oneboxdef authorsinitials = xml.css("Initials").map { |x| x.content }last_names = xml.css("LastName").map { |x| x.content }- author_list = (initials.zip(last_names)).map { |i, l| i + " " + l }+ author_list = initials.zip(last_names).map { |i, l| i + " " + l }if author_list.length > 1author_list[-2] = author_list[-2] + " and " + author_list[-1]author_list.popdiff --git a/lib/onebox/engine/standard_embed.rb b/lib/onebox/engine/standard_embed.rbindex ea6516cebb8..55ef89c26e7 100644--- a/lib/onebox/engine/standard_embed.rb+++ b/lib/onebox/engine/standard_embed.rb@@ -86,7 +86,7 @@ module Oneboxif (m["property"] && m["property"][/^twitter:(.+)$/i]) ||(m["name"] && m["name"][/^twitter:(.+)$/i])value = (m["content"] || m["value"]).to_s- twitter[$1.tr("-:", "_").to_sym] ||= value if (value.present? && value != "0 minutes")+ twitter[$1.tr("-:", "_").to_sym] ||= value if value.present? && value != "0 minutes"endenddiff --git a/lib/onebox/engine/wikipedia_onebox.rb b/lib/onebox/engine/wikipedia_onebox.rbindex 5a23ec54d02..59a11009437 100644--- a/lib/onebox/engine/wikipedia_onebox.rb+++ b/lib/onebox/engine/wikipedia_onebox.rb@@ -47,13 +47,11 @@ module Onebox# div tag is commonly used as an assets wraper in an article section. often as the first element holding an image.# ul support will imporve the output generated for a section with a list as the main content (for example: an Author Bibliography, A musician Discography, etc)first_p_found = nil- while (- ((next_sibling = cur_element.next_sibling).name =~ /p|text|div|ul/) ||- first_p_found.nil?- )+ while ((next_sibling = cur_element.next_sibling).name =~ /p|text|div|ul/) ||+ first_p_found.nil?# from section header get the next sibling until it is a breaker tagcur_element = next_sibling- if (cur_element.name == "p" || cur_element.name == "ul") #we treat a list as we detect a p to avoid showing+ if cur_element.name == "p" || cur_element.name == "ul" #we treat a list as we detect a p to avoid showingfirst_p_found = trueparas.push(cur_element)enddiff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rbindex 453f94fe7ab..de7b77e9d11 100644--- a/lib/onebox/helpers.rb+++ b/lib/onebox/helpers.rb@@ -169,7 +169,7 @@ module Oneboxscale = 1024ndx = 1- return "#{(size)} #{conv[ndx - 1]}" if (size < 2 * (scale**ndx))+ return "#{size} #{conv[ndx - 1]}" if (size < 2 * (scale**ndx))size = size.to_f[2, 3, 4, 5, 6, 7].each do |i|return "#{"%.2f" % (size / (scale**(i - 1)))} #{conv[i - 1]}" if (size < 2 * (scale**i))diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex 044b2ecf3ba..aa6c0ed879d 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -69,10 +69,8 @@ class PostCreatoropts[:title] = pg_clean_up(opts[:title]) if opts[:title]&.include?("\u0000")opts[:raw] = pg_clean_up(opts[:raw]) if opts[:raw]&.include?("\u0000")- opts[:visible] = false if (- (opts[:visible].nil? && opts[:hidden_reason_id].present?) ||- (opts[:embed_url].present? && SiteSetting.embed_unlisted?)- )+ opts[:visible] = false if (opts[:visible].nil? && opts[:hidden_reason_id].present?) ||+ (opts[:embed_url].present? && SiteSetting.embed_unlisted?)opts.delete(:reply_to_post_number) unless opts[:topic_id]end@@ -235,7 +233,7 @@ class PostCreatorendif !opts[:import_mode] && !opts[:reviewed_queued_post]- handle_spam if (@spam || @post)+ handle_spam if @spam || @postReviewablePost.queue_for_review_if_possible(@post, @user) if !@spam && @post && errors.blank?enddiff --git a/lib/post_revisor.rb b/lib/post_revisor.rbindex 5bb5aea7a8c..d3d980d0b96 100644--- a/lib/post_revisor.rb+++ b/lib/post_revisor.rb@@ -346,23 +346,19 @@ class PostRevisorreturn false if !successfully_saved_post_and_topic# Lock the post by default if the appropriate setting is true- if (- SiteSetting.staff_edit_locks_post? && [email protected]? && @fields.has_key?("raw") &&- @editor.staff? && @editor != Discourse.system_user && [email protected]&.staff?- )+ if SiteSetting.staff_edit_locks_post? && [email protected]? && @fields.has_key?("raw") &&+ @editor.staff? && @editor != Discourse.system_user && [email protected]&.staff?PostLocker.new(@post, @editor).lockend# We log staff/group moderator edits to postsif (- (- @editor.staff? ||- (- @post.is_category_description? &&- guardian.can_edit_category_description?(@post.topic.category)- )- ) && @editor.id != @post.user_id && @fields.has_key?("raw") && !@opts[:skip_staff_log]- )+ @editor.staff? ||+ (+ @post.is_category_description? &&+ guardian.can_edit_category_description?(@post.topic.category)+ )+ ) && @editor.id != @post.user_id && @fields.has_key?("raw") && !@opts[:skip_staff_log]StaffActionLogger.new(@editor).log_post_edit(@post, old_raw: old_raw)enddiff --git a/lib/pretty_text.rb b/lib/pretty_text.rbindex d9ce78619b1..54fe655f738 100644--- a/lib/pretty_text.rb+++ b/lib/pretty_text.rb@@ -259,7 +259,7 @@ module PrettyTextbuffer << "__pt = __DiscourseMarkdownIt.withCustomFeatures(__pluginFeatures).withOptions(__optInput);"# Be careful disabling sanitization. We allow for custom emails- buffer << ("__pt.disableSanitizer();") if opts[:sanitize] == false+ buffer << "__pt.disableSanitizer();" if opts[:sanitize] == falseopts = context.eval(buffer)diff --git a/lib/pretty_text/helpers.rb b/lib/pretty_text/helpers.rbindex 64c31ec1d71..d5ecfd10a35 100644--- a/lib/pretty_text/helpers.rb+++ b/lib/pretty_text/helpers.rb@@ -44,7 +44,7 @@ module PrettyTexturls.each do |url|sha1 = Upload.sha1_from_short_url(url)- if (url.split(".")[1].nil?) # video sha1 without extension for thumbnail+ if url.split(".")[1].nil? # video sha1 without extension for thumbnailthumbnail = Upload.where("original_filename LIKE ?", "#{sha1}.%").last if sha1# Fallback for old posts that don't contain data-video-base62-sha1thumbnail = Upload.where("original_filename LIKE ?", "#{url}.%").last if thumbnail.nil? &&diff --git a/lib/scheduler/defer.rb b/lib/scheduler/defer.rbindex 6d088241bf4..8cf296cace8 100644--- a/lib/scheduler/defer.rb+++ b/lib/scheduler/defer.rb@@ -113,7 +113,7 @@ module Scheduler@thread =Thread.new doThread.current.abort_on_exception = true if Rails.env.test?- do_work while (!@finish || [email protected]?)+ do_work while !@finish || [email protected]?end if !@thread&.alive?endenddiff --git a/lib/search.rb b/lib/search.rbindex 1e20e4ff7af..e1fc09406e3 100644--- a/lib/search.rb+++ b/lib/search.rb@@ -206,7 +206,7 @@ class Searchreturn Time.zone.now.beginning_of_week(str.downcase.to_sym)end- if idx = (Date::MONTHNAMES.find_index(titlecase) || Date::ABBR_MONTHNAMES.find_index(titlecase))+ if idx = Date::MONTHNAMES.find_index(titlecase) || Date::ABBR_MONTHNAMES.find_index(titlecase)delta = Time.zone.now.month - idxdelta += 12 if delta < 0Time.zone.now.beginning_of_month.months_ago(delta)@@ -677,7 +677,7 @@ class Search# try a possible tag matchtag_id, target_tag_id = Tag.where_name(category_slug).pick(:id, :target_tag_id)tag_id = target_tag_id || tag_id- if (tag_id)+ if tag_idposts.where(<<~SQL, tag_id)topics.id IN (SELECT DISTINCT(tt.topic_id)diff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rbindex 69a08f5ac1c..03830d37712 100644--- a/lib/search/grouped_search_results.rb+++ b/lib/search/grouped_search_results.rb@@ -114,7 +114,7 @@ class Searchelsif @is_header_search && public_send(type).length == Search.per_facetinstance_variable_set(:"@more_#{type}", true)else- (self.public_send(type)) << object+ self.public_send(type) << objectendif can_lazy_load_categoriesdiff --git a/lib/site_settings/defaults_provider.rb b/lib/site_settings/defaults_provider.rbindex c10d5615938..484e1b00f88 100644--- a/lib/site_settings/defaults_provider.rb+++ b/lib/site_settings/defaults_provider.rb@@ -18,7 +18,7 @@ class SiteSettings::DefaultsProvidername = name_arg.to_sym@defaults[DEFAULT_LOCALE.to_sym][name] = value- if (locale_defaults)+ if locale_defaultslocale_defaults.each do |locale, v|locale = locale.to_sym@defaults[locale] ||= {}diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rbindex 3322fe11151..ab36d9b2f81 100644--- a/lib/site_settings/type_supervisor.rb+++ b/lib/site_settings/type_supervisor.rb@@ -158,7 +158,7 @@ class SiteSettings::TypeSupervisor@types[name] = get_data_type(name, @defaults_provider[name])opts[:validator] = opts[:validator].try(:constantize)- if (validator_type = (opts[:validator] || validator_for(@types[name])))+ if (validator_type = opts[:validator] || validator_for(@types[name]))validator_opts = opts.slice(*VALIDATOR_OPTS)validator_opts[:name] = name@validators[name] = { class: validator_type, opts: validator_opts }@@ -183,7 +183,7 @@ class SiteSettings::TypeSupervisordef to_rb_value(name, value, override_type = nil)name = name.to_sym@types[name] = (@types[name] || get_data_type(name, value))- type = (override_type || @types[name])+ type = override_type || @types[name]case typewhen self.class.types[:float]value.to_fdiff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rbindex a1c6fd3b761..249674595db 100644--- a/lib/stylesheet/importer.rb+++ b/lib/stylesheet/importer.rb@@ -164,7 +164,7 @@ module Stylesheetrescue StandardErrorColorScheme.base_colorsend- elsif (@theme_id && !theme.component)+ elsif @theme_id && !theme.componentcolors = theme&.color_scheme&.resolved_colors || ColorScheme.base_colorselse# this is a slightly ugly backwards compatibility fix,diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rakeindex a5fa3266af6..874a1473d27 100644--- a/lib/tasks/admin.rake+++ b/lib/tasks/admin.rake@@ -51,7 +51,7 @@ task "admin:create" => :environment doask("User with this email already exists! Do you want to reset the password for this email? (Y/n) ",)- if (reset_password == "" || reset_password.downcase == "y")+ if reset_password == "" || reset_password.downcase == "y"beginpassword = ask("Password: ") { |q| q.echo = false }password_confirmation = ask("Repeat password: ") { |q| q.echo = false }@@ -101,7 +101,7 @@ task "admin:create" => :environment do# grant admin privilegesgrant_admin = ask("Do you want to grant Admin privileges to this account? (Y/n) ")- if (grant_admin == "" || grant_admin.downcase == "y")+ if grant_admin == "" || grant_admin.downcase == "y"admin.grant_admin!admin.change_trust_level!(1) if admin.trust_level < 1admin.email_tokens.update_all confirmed: truediff --git a/lib/tasks/db.rake b/lib/tasks/db.rakeindex 3d0d7c9d6ed..80121b37dd0 100644--- a/lib/tasks/db.rake+++ b/lib/tasks/db.rake@@ -5,7 +5,7 @@ task "set_locale" dobeginI18n.locale =begin- (SiteSetting.default_locale || :en)+ SiteSetting.default_locale || :enrescue StandardError:enend@@ -406,7 +406,7 @@ task "db:validate_indexes", [:arg] => %w[db:ensure_post_migrations environment]puts- fix_indexes = (ENV["FIX_INDEXES"] == "1" || args[:arg] == "fix")+ fix_indexes = ENV["FIX_INDEXES"] == "1" || args[:arg] == "fix"inconsistency_found = falseRailsMultisite::ConnectionManagement.each_connection do |db_name|diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rakeindex 91c6df22fca..4fce2dadde2 100644--- a/lib/tasks/dev.rake+++ b/lib/tasks/dev.rake@@ -40,7 +40,7 @@ task "dev:repopulate" => ["db:load_config"] do |_, args|"Do you want to repopulate the database with fresh data? It will recreate DBs and run migration from scratch before generating all the samples. (Y/n) ",)- if (answer == "" || answer.downcase == "y")+ if answer == "" || answer.downcase == "y"Rake::Task["dev:reset"].invokeelseputs "You can run `bin/rails dev:reset` to repopulate anytime."diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rakeindex 349aab8a8d4..75de514490d 100644--- a/lib/tasks/posts.rake+++ b/lib/tasks/posts.rake@@ -289,7 +289,7 @@ task "posts:remap", %i[find replace type ignore_case] => [:environment] do |_, aask("Are you sure you want to replace all #{type} occurrences of '#{find}' with '#{replace}'? (Y/n)",)- exit 1 unless (confirm_replace == "" || confirm_replace.downcase == "y")+ exit 1 unless confirm_replace == "" || confirm_replace.downcase == "y"endputs "Remapping"@@ -318,7 +318,7 @@ task "posts:delete_word", %i[find type ignore_case] => [:environment] do |_, argelseconfirm_delete =ask("Are you sure you want to remove all #{type} occurrences of '#{find}'? (Y/n)")- exit 1 unless (confirm_delete == "" || confirm_delete.downcase == "y")+ exit 1 unless confirm_delete == "" || confirm_delete.downcase == "y"endputs "Processing"diff --git a/lib/tasks/site_settings.rake b/lib/tasks/site_settings.rakeindex f3547948bee..78c8901d375 100644--- a/lib/tasks/site_settings.rake+++ b/lib/tasks/site_settings.rake@@ -10,7 +10,7 @@ enddesc "Imports site settings"task "site_settings:import" => :environment do- yml = (STDIN.tty?) ? "" : STDIN.read+ yml = STDIN.tty? ? "" : STDIN.readif yml == ""putsputs "Please specify a settings yml file"diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rakeindex 3aca548f30d..4adbd81cee9 100644--- a/lib/tasks/themes.rake+++ b/lib/tasks/themes.rake@@ -249,7 +249,7 @@ enddesc "Install themes & theme components"task "themes:install" => :environment do |task, args|- theme_args = (STDIN.tty?) ? "" : STDIN.read+ theme_args = STDIN.tty? ? "" : STDIN.readuse_json = theme_args == ""theme_args =diff --git a/lib/tasks/typepad.thor b/lib/tasks/typepad.thorindex 87312d47c57..fba9ae1d8bb 100644--- a/lib/tasks/typepad.thor+++ b/lib/tasks/typepad.thor@@ -216,7 +216,7 @@ class Typepad < Thorcomment[:author].each_char do |c|is_upper = /[[:upper:]]/.match(c)- if (current.size > 1 && is_upper != last_upper)+ if current.size > 1 && is_upper != last_uppersegments << currentcurrent = ""enddiff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rakeindex 83b171f6d1a..275790a6218 100644--- a/lib/tasks/uploads.rake+++ b/lib/tasks/uploads.rake@@ -227,8 +227,8 @@ def clean_up_uploadssha1 = Upload.generate_digest(file_path)url = file_path.split(public_directory, 2)[1]- if (Upload.where(sha1: sha1).empty? && Upload.where(url: url).empty?) &&- (OptimizedImage.where(sha1: sha1).empty? && OptimizedImage.where(url: url).empty?)+ if Upload.where(sha1: sha1).empty? && Upload.where(url: url).empty? &&+ OptimizedImage.where(sha1: sha1).empty? && OptimizedImage.where(url: url).empty?FileUtils.rm(file_path)putc "#"elsediff --git a/lib/tasks/users.rake b/lib/tasks/users.rakeindex 6d6a991185c..0b438d19b9a 100644--- a/lib/tasks/users.rake+++ b/lib/tasks/users.rake@@ -174,7 +174,7 @@ task "users:anonymize_all" => :environment doanonymized = 0confirm_anonymize = ask("Are you sure you want to anonymize #{total} users? (Y/n)")- exit 1 unless (confirm_anonymize == "" || confirm_anonymize.downcase == "y")+ exit 1 unless confirm_anonymize == "" || confirm_anonymize.downcase == "y"system_user = Discourse.system_usernon_staff_users.each do |user|diff --git a/lib/theme_settings_manager/bool.rb b/lib/theme_settings_manager/bool.rbindex b2b8c4c87ad..66a79265b65 100644--- a/lib/theme_settings_manager/bool.rb+++ b/lib/theme_settings_manager/bool.rb@@ -10,7 +10,7 @@ class ThemeSettingsManager::Bool < ThemeSettingsManagerenddef value=(new_value)- new_value = (self.class.cast(new_value)).to_s+ new_value = self.class.cast(new_value).to_ssuper(new_value)endenddiff --git a/lib/topic_creator.rb b/lib/topic_creator.rbindex 0a1b99040d0..18e01df7af2 100644--- a/lib/topic_creator.rb+++ b/lib/topic_creator.rb@@ -172,7 +172,7 @@ class TopicCreatortopic_params[:subtype] = TopicSubtype.moderator_warning if @opts[:is_warning]category = find_category- unless (@opts[:skip_validations] || @opts[:archetype] == Archetype.private_message)+ unless @opts[:skip_validations] || @opts[:archetype] == Archetype.private_message@guardian.ensure_can_create!(Topic, category)enddiff --git a/lib/topic_query.rb b/lib/topic_query.rbindex 7e9980a9207..9a2e32a23a6 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -846,7 +846,7 @@ class TopicQueryresult = result.references(:categories)if !@options[:order]- filter = (options[:filter] || options[:f])+ filter = options[:filter] || options[:f]# category default sort ordersort_order, sort_ascending =Category.where(id: category_id).pick(:sort_order, :sort_ascending)@@ -959,7 +959,7 @@ class TopicQuery)end- if (filter = (options[:filter] || options[:f])) && @user+ if (filter = options[:filter] || options[:f]) && @useraction = (PostActionType.types[:like] if filter == "liked")if actionresult =@@ -1195,8 +1195,8 @@ class TopicQueryenddef allowed_messages(messages, params)- user_ids = (params[:target_user_ids] || [])- group_ids = ((params[:target_group_ids] - params[:my_group_ids]) || [])+ user_ids = params[:target_user_ids] || []+ group_ids = (params[:target_group_ids] - params[:my_group_ids]) || []if user_ids.present?messages =diff --git a/lib/topic_retriever.rb b/lib/topic_retriever.rbindex a156e70b39a..5e7945e3a58 100644--- a/lib/topic_retriever.rb+++ b/lib/topic_retriever.rb@@ -7,7 +7,7 @@ class TopicRetrieverenddef retrieve- perform_retrieve unless (invalid_url? || retrieved_recently?)+ perform_retrieve unless invalid_url? || retrieved_recently?endprivatediff --git a/lib/upload_creator.rb b/lib/upload_creator.rbindex 9d8dc708c56..ded3944d7ca 100644--- a/lib/upload_creator.rb+++ b/lib/upload_creator.rb@@ -169,7 +169,7 @@ class UploadCreator@upload.filesize = filesize@upload.sha1 =(- if (SiteSetting.secure_uploads? || external_upload_too_big || is_thumbnail)+ if SiteSetting.secure_uploads? || external_upload_too_big || is_thumbnailunique_hashelsesha1diff --git a/lib/upload_recovery.rb b/lib/upload_recovery.rbindex 34f9ffe6682..7f2c52d6e60 100644--- a/lib/upload_recovery.rb+++ b/lib/upload_recovery.rb@@ -28,7 +28,7 @@ class UploadRecoveryelserecover_post_upload(post, Upload.sha1_from_short_url(orig_src))end- elsif url = (media["href"] || media["src"])+ elsif url = media["href"] || media["src"]data = Upload.extract_url(url)next unless datadiff --git a/lib/user_comm_screener.rb b/lib/user_comm_screener.rbindex 4a4a59dcfde..e906e81d297 100644--- a/lib/user_comm_screener.rb+++ b/lib/user_comm_screener.rb@@ -263,7 +263,7 @@ class UserCommScreenerenddisallowed_pms_from =if acting_user.user_option.enable_allowed_pm_users- (user_ids_by_preference_type["disallowed_pm"] || [])+ user_ids_by_preference_type["disallowed_pm"] || []else[]enddiff --git a/lib/user_name_suggester.rb b/lib/user_name_suggester.rbindex d7fcd2c7071..1b341bfdbbf 100644--- a/lib/user_name_suggester.rb+++ b/lib/user_name_suggester.rb@@ -40,7 +40,7 @@ module UserNameSuggesteroriginal_allowed_username = current_usernamecurrent_username = User.normalize_username(current_username) if current_username- until (normalized_attempt == current_username || User.username_available?(attempt) || i > 100)+ until normalized_attempt == current_username || User.username_available?(attempt) || i > 100if offset.nil?normalized = User.normalize_username(name)similar = "#{normalized}(0|1|2|3|4|5|6|7|8|9)+"diff --git a/lib/validators/integer_setting_validator.rb b/lib/validators/integer_setting_validator.rbindex 364538c62d0..b516b9ed563 100644--- a/lib/validators/integer_setting_validator.rb+++ b/lib/validators/integer_setting_validator.rb@@ -12,8 +12,8 @@ class IntegerSettingValidatordef valid_value?(val)return false if val.to_i.to_s != val.to_s- return false if @opts[:min] && @opts[:min].to_i > (val.to_i)- return false if @opts[:max] && @opts[:max].to_i < (val.to_i)+ return false if @opts[:min] && @opts[:min].to_i > val.to_i+ return false if @opts[:max] && @opts[:max].to_i < val.to_itrueenddiff --git a/lib/validators/string_setting_validator.rb b/lib/validators/string_setting_validator.rbindex 2b218b90d00..d4b78e80269 100644--- a/lib/validators/string_setting_validator.rb+++ b/lib/validators/string_setting_validator.rb@@ -11,13 +11,13 @@ class StringSettingValidatordef valid_value?(val)return true if !val.present?- if (@opts[:min] && @opts[:min].to_i > (val.length)) ||- (@opts[:max] && @opts[:max].to_i < (val.length))+ if (@opts[:min] && @opts[:min].to_i > val.length) ||+ (@opts[:max] && @opts[:max].to_i < val.length)@length_fail = truereturn falseend- return valid_json?(val) if (@opts[:json_schema])+ return valid_json?(val) if @opts[:json_schema]regex_match?(val)enddiff --git a/lib/validators/upload_validator.rb b/lib/validators/upload_validator.rbindex 77ab7ce7a7a..2be4c5862b9 100644--- a/lib/validators/upload_validator.rb+++ b/lib/validators/upload_validator.rb@@ -5,7 +5,7 @@ require "file_helper"class UploadValidator < ActiveModel::Validatordef validate(upload)# staff can upload any file in PM- if (upload.for_private_message && SiteSetting.allow_staff_to_upload_any_file_in_pm)+ if upload.for_private_message && SiteSetting.allow_staff_to_upload_any_file_in_pmreturn true if upload.user&.staff?enddiff --git a/plugins/automation/app/models/discourse_automation/field.rb b/plugins/automation/app/models/discourse_automation/field.rbindex 9d5f479116d..ab8666ae322 100644--- a/plugins/automation/app/models/discourse_automation/field.rb+++ b/plugins/automation/app/models/discourse_automation/field.rb@@ -56,7 +56,7 @@ module DiscourseAutomationvalidate :metadata_schemadef metadata_schema- if !(targetable.components.include?(component.to_sym))+ if !targetable.components.include?(component.to_sym)errors.add(:base,I18n.t(diff --git a/plugins/automation/app/serializers/discourse_automation/trigger_serializer.rb b/plugins/automation/app/serializers/discourse_automation/trigger_serializer.rbindex 2c7edb3b6bd..dac05e9a2a5 100644--- a/plugins/automation/app/serializers/discourse_automation/trigger_serializer.rb+++ b/plugins/automation/app/serializers/discourse_automation/trigger_serializer.rb@@ -5,7 +5,7 @@ module DiscourseAutomationattributes :id, :name, :metadatadef metadata- ((options[:trigger_metadata] || {}).stringify_keys).merge(object.metadata || {})+ (options[:trigger_metadata] || {}).stringify_keys.merge(object.metadata || {})endendenddiff --git a/plugins/automation/lib/discourse_automation/scriptable.rb b/plugins/automation/lib/discourse_automation/scriptable.rbindex 42390b0c911..2bdc2714b9b 100644--- a/plugins/automation/lib/discourse_automation/scriptable.rb+++ b/plugins/automation/lib/discourse_automation/scriptable.rb@@ -28,7 +28,7 @@ module DiscourseAutomation@version = 0@fields = []@placeholders = []- @triggerables = (@@plugin_triggerables[name&.to_sym] || [])+ @triggerables = @@plugin_triggerables[name&.to_sym] || []@script = proc {}@on_reset = proc {}@not_found = falsediff --git a/plugins/chat/app/models/chat/reviewable_message.rb b/plugins/chat/app/models/chat/reviewable_message.rbindex 0b9b4d69079..ba68ef0503b 100644--- a/plugins/chat/app/models/chat/reviewable_message.rb+++ b/plugins/chat/app/models/chat/reviewable_message.rb@@ -25,7 +25,7 @@ module Chatenddef chat_message- @chat_message ||= (target || Chat::Message.with_deleted.find_by(id: target_id))+ @chat_message ||= target || Chat::Message.with_deleted.find_by(id: target_id)enddef chat_message_creatordiff --git a/plugins/chat/app/serializers/chat/message_user_serializer.rb b/plugins/chat/app/serializers/chat/message_user_serializer.rbindex ddfa3872f7b..3510f17119e 100644--- a/plugins/chat/app/serializers/chat/message_user_serializer.rb+++ b/plugins/chat/app/serializers/chat/message_user_serializer.rb@@ -5,15 +5,15 @@ module Chatattributes :moderator?, :admin?, :staff?, :moderator?, :new_user?, :primary_group_namedef moderator?- !!(object&.moderator?)+ !!object&.moderator?enddef admin?- !!(object&.admin?)+ !!object&.admin?enddef staff?- !!(object&.staff?)+ !!object&.staff?enddef new_user?diff --git a/plugins/chat/lib/chat/notification_consolidation_extension.rb b/plugins/chat/lib/chat/notification_consolidation_extension.rbindex 04ff54e5434..d68c8a9d0d5 100644--- a/plugins/chat/lib/chat/notification_consolidation_extension.rb+++ b/plugins/chat/lib/chat/notification_consolidation_extension.rb@@ -53,7 +53,7 @@ module Chatdata.merge(username: consolidated_data[:username],username2: consolidated_data[:username2],- user_ids: (consolidated_data[:user_ids].concat(data[:user_ids])).uniq,+ user_ids: consolidated_data[:user_ids].concat(data[:user_ids]).uniq,)endend,diff --git a/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rb b/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rbindex bce65bfe6e3..865311773e5 100644--- a/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rb+++ b/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rb@@ -17,7 +17,7 @@ class ReviewableAiChatMessage < Reviewableenddef chat_message- @chat_message ||= (target || Chat::Message.with_deleted.find_by(id: target_id))+ @chat_message ||= target || Chat::Message.with_deleted.find_by(id: target_id)enddef chat_message_creatordiff --git a/plugins/discourse-ai/app/models/reviewable_ai_post.rb b/plugins/discourse-ai/app/models/reviewable_ai_post.rbindex f622c09c918..c45880c4dd2 100644--- a/plugins/discourse-ai/app/models/reviewable_ai_post.rb+++ b/plugins/discourse-ai/app/models/reviewable_ai_post.rb@@ -168,7 +168,7 @@ class ReviewableAiPost < Reviewableprivatedef post- @post ||= (target || Post.with_deleted.find_by(id: target_id))+ @post ||= target || Post.with_deleted.find_by(id: target_id)enddef destroyer(performed_by)diff --git a/plugins/discourse-ai/app/serializers/ai_spam_serializer.rb b/plugins/discourse-ai/app/serializers/ai_spam_serializer.rbindex d10fe2bdd3c..d04a596ab2a 100644--- a/plugins/discourse-ai/app/serializers/ai_spam_serializer.rb+++ b/plugins/discourse-ai/app/serializers/ai_spam_serializer.rb@@ -63,6 +63,6 @@ class AiSpamSerializer < ApplicationSerializerdef spam_scanning_useruser = DiscourseAi::AiModeration::SpamScanner.flagging_user- (user.presence&.serializable_hash(only: %i[id username name admin]))+ user.presence&.serializable_hash(only: %i[id username name admin])endenddiff --git a/plugins/discourse-ai/app/serializers/llm_model_serializer.rb b/plugins/discourse-ai/app/serializers/llm_model_serializer.rbindex 8d7f8e4b1b7..3281f663682 100644--- a/plugins/discourse-ai/app/serializers/llm_model_serializer.rb+++ b/plugins/discourse-ai/app/serializers/llm_model_serializer.rb@@ -40,7 +40,7 @@ class LlmModelSerializer < ApplicationSerializerdef used_byllm_usage =(- if (scope && scope[:llm_usage])+ if scope && scope[:llm_usage]scope[:llm_usage]elseDiscourseAi::Configuration::LlmEnumerator.global_usagediff --git a/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rb b/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rbindex 1356208dbba..03fcbcfc3ce 100644--- a/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rb+++ b/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rb@@ -66,12 +66,12 @@ module DiscourseAitopics.each do |topic|if params.type == "gist"summarizer = DiscourseAi::Summarization.topic_gist(topic)- (summarizer.presence&.delete_cached_summaries!)+ summarizer.presence&.delete_cached_summaries!Jobs.enqueue(:fast_track_topic_gist, topic_id: topic.id, force_regenerate: true)elsesummarizer = DiscourseAi::Summarization.topic_summary(topic)- (summarizer.presence&.delete_cached_summaries!)+ summarizer.presence&.delete_cached_summaries!Jobs.enqueue(:stream_topic_ai_summary,diff --git a/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb b/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rbindex 92581bb3a29..943bbea7854 100644--- a/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb+++ b/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb@@ -42,8 +42,7 @@ class ProblemCheck::AiLlmStatus < ProblemCheckreturn no_problem if failed_calls < MIN_FAILED_CALLSreturn no_problem if failure_rate(total_calls, failed_calls) < FAILURE_RATE_THRESHOLD- details =- self.class.problem_details(model, failed_calls, total_calls, (LOOKBACK_WINDOW / 1.hour))+ details = self.class.problem_details(model, failed_calls, total_calls, LOOKBACK_WINDOW / 1.hour)problem(model, override_data: details, details: details)enddiff --git a/plugins/discourse-ai/lib/agents/agent.rb b/plugins/discourse-ai/lib/agents/agent.rbindex ee45a06392c..950858e8d82 100644--- a/plugins/discourse-ai/lib/agents/agent.rb+++ b/plugins/discourse-ai/lib/agents/agent.rb@@ -70,10 +70,8 @@ module DiscourseAiif agent.systeminstance = agent.new- (- instance.required_tools == [] ||- (instance.required_tools - all_available_tools).empty?- )+ instance.required_tools == [] ||+ (instance.required_tools - all_available_tools).empty?elsetrueenddiff --git a/plugins/discourse-ai/lib/agents/sql_helper.rb b/plugins/discourse-ai/lib/agents/sql_helper.rbindex 329fa65d765..6dca26aa685 100644--- a/plugins/discourse-ai/lib/agents/sql_helper.rb+++ b/plugins/discourse-ai/lib/agents/sql_helper.rb@@ -24,7 +24,7 @@ module DiscourseAiorder by table_nameSQL- priority = +(priority_tables.map { |name| "#{name}(#{tables[name].join(",")})" }.join("\n"))+ priority = +priority_tables.map { |name| "#{name}(#{tables[name].join(",")})" }.join("\n")other_tables = +""tables.each do |table_name, _|diff --git a/plugins/discourse-ai/lib/agents/tools/create_artifact.rb b/plugins/discourse-ai/lib/agents/tools/create_artifact.rbindex 6276d385bcd..36cbf602f8c 100644--- a/plugins/discourse-ai/lib/agents/tools/create_artifact.rb+++ b/plugins/discourse-ai/lib/agents/tools/create_artifact.rb@@ -90,7 +90,7 @@ module DiscourseAienddef in_progress(specification:, source: nil)- source = (<<~HTML) if source.present?+ source = <<~HTML if source.present?### Source````diff --git a/plugins/discourse-ai/lib/agents/tools/discourse_meta_search.rb b/plugins/discourse-ai/lib/agents/tools/discourse_meta_search.rbindex 01cee1566a6..4416bffcc30 100644--- a/plugins/discourse-ai/lib/agents/tools/discourse_meta_search.rb+++ b/plugins/discourse-ai/lib/agents/tools/discourse_meta_search.rb@@ -119,7 +119,7 @@ module DiscourseAiself.class.categoriesend- topics = (json["topics"]).index_by { it["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/agents/tools/github_search_code.rb b/plugins/discourse-ai/lib/agents/tools/github_search_code.rbindex 3994c69bdce..e05cd559452 100644--- a/plugins/discourse-ai/lib/agents/tools/github_search_code.rb+++ b/plugins/discourse-ai/lib/agents/tools/github_search_code.rb@@ -105,7 +105,7 @@ module DiscourseAiif total_count <= 01else- [((total_count.to_f / PER_PAGE).ceil), MAX_ALLOWED_PAGE].min+ [(total_count.to_f / PER_PAGE).ceil, MAX_ALLOWED_PAGE].minendresult = { search_results: trimmed }diff --git a/plugins/discourse-ai/lib/agents/tools/researcher.rb b/plugins/discourse-ai/lib/agents/tools/researcher.rbindex a425a96efd4..fdc0a04d930 100644--- a/plugins/discourse-ai/lib/agents/tools/researcher.rb+++ b/plugins/discourse-ai/lib/agents/tools/researcher.rb@@ -61,13 +61,11 @@ module DiscourseAienddef assign_tip- if SiteSetting.respond_to?(:assign_enabled) && SiteSetting.assign_enabled- (<<~TEXT).strip+ <<~TEXT.strip if SiteSetting.respond_to?(:assign_enabled) && SiteSetting.assign_enabledassigned_to:username or assigned_to:username1,username2 - topics assigned to a specific userassigned_to:* - topics assigned to any userassigned_to:nobody - topics not assigned to any userTEXT- endenddef namediff --git a/plugins/discourse-ai/lib/agents/tools/update_artifact.rb b/plugins/discourse-ai/lib/agents/tools/update_artifact.rbindex a2a1c2ac017..d3df695dc10 100644--- a/plugins/discourse-ai/lib/agents/tools/update_artifact.rb+++ b/plugins/discourse-ai/lib/agents/tools/update_artifact.rb@@ -89,7 +89,7 @@ module DiscourseAienddef in_progress(instructions:, source: nil)- source = (<<~HTML) if source.present?+ source = <<~HTML if source.present?### Source````diff --git a/plugins/discourse-ai/lib/ai_bot/playground.rb b/plugins/discourse-ai/lib/ai_bot/playground.rbindex 968380d2c80..6e66d2c0381 100644--- a/plugins/discourse-ai/lib/ai_bot/playground.rb+++ b/plugins/discourse-ai/lib/ai_bot/playground.rb@@ -439,7 +439,7 @@ module DiscourseAipost_type =(- if (whisper || post.post_type == Post.types[:whisper])+ if whisper || post.post_type == Post.types[:whisper]Post.types[:whisper]elsePost.types[:regular]diff --git a/plugins/discourse-ai/lib/completions/dialects/xml_tools.rb b/plugins/discourse-ai/lib/completions/dialects/xml_tools.rbindex 7af04df113d..f250507bbdd 100644--- a/plugins/discourse-ai/lib/completions/dialects/xml_tools.rb+++ b/plugins/discourse-ai/lib/completions/dialects/xml_tools.rb@@ -49,7 +49,7 @@ module DiscourseAibeginhas_arrays = raw_tools.any? { |tool| tool.parameters&.any? { |p| p.type == "array" } }- (<<~TEXT).strip+ <<~TEXT.strip#{tool_preamble(include_array_tip: has_arrays)}<tools>#{translated_tools}</tools>@@ -61,7 +61,7 @@ module DiscourseAi"Regardless of what you think, REPLY IMMEDIATELY, WITHOUT MAKING ANY FURTHER TOOL CALLS, YOU ARE OUT OF TOOL CALL QUOTA!"def from_raw_tool(raw_message)- result = (<<~TEXT).strip+ result = <<~TEXT.strip<function_results><result><tool_name>#{raw_message[:name] || raw_message[:id]}</tool_name>@@ -89,7 +89,7 @@ module DiscourseAiparameters << "</parameters>\n"end- (<<~TEXT).strip+ <<~TEXT.strip<function_calls><invoke><tool_name>#{raw_message[:name] || parsed[:name]}</tool_name>diff --git a/plugins/discourse-ai/lib/completions/endpoints/base.rb b/plugins/discourse-ai/lib/completions/endpoints/base.rbindex 4a462a4025b..d6ef59f6147 100644--- a/plugins/discourse-ai/lib/completions/endpoints/base.rb+++ b/plugins/discourse-ai/lib/completions/endpoints/base.rb@@ -472,7 +472,7 @@ module DiscourseAiProblemCheck::AiLlmStatus.fast_track_problem!(llm_model,failures_count,- (FAIL_TTL / 1.hour),+ FAIL_TTL / 1.hour,)enddiff --git a/plugins/discourse-ai/lib/completions/endpoints/gemini.rb b/plugins/discourse-ai/lib/completions/endpoints/gemini.rbindex 6f568f3c400..ef44d06f83a 100644--- a/plugins/discourse-ai/lib/completions/endpoints/gemini.rb+++ b/plugins/discourse-ai/lib/completions/endpoints/gemini.rb@@ -186,7 +186,7 @@ module DiscourseAi.compactif keep_last- @buffer = +(keep_last)+ @buffer = +keep_lastelse@buffer = +""enddiff --git a/plugins/discourse-ai/lib/completions/json_stream_decoder.rb b/plugins/discourse-ai/lib/completions/json_stream_decoder.rbindex e575a3b787f..db2c7ede277 100644--- a/plugins/discourse-ai/lib/completions/json_stream_decoder.rb+++ b/plugins/discourse-ai/lib/completions/json_stream_decoder.rb@@ -21,7 +21,7 @@ module DiscourseAisplit = @buffer.scan(/.*\n?/)split.pop if split.last.blank?- @buffer = +(split.pop.to_s)+ @buffer = +split.pop.to_ssplit.each do |line|matches = line.match(@line_regex)diff --git a/plugins/discourse-ai/lib/translation/content_splitter.rb b/plugins/discourse-ai/lib/translation/content_splitter.rbindex 1885317e2c6..e2d2a069818 100644--- a/plugins/discourse-ai/lib/translation/content_splitter.rb+++ b/plugins/discourse-ai/lib/translation/content_splitter.rb@@ -69,9 +69,7 @@ module DiscourseAidoc.children.each do |node|html = node.to_htmlend_pos = max_length_within_target + html.length- if (max_length_within_target > 0 && end_pos > target_pos)- return max_length_within_target- end+ return max_length_within_target if max_length_within_target > 0 && end_pos > target_posmax_length_within_target = end_posendnil@@ -86,9 +84,7 @@ module DiscourseAitext.scan(pattern) do |_|match = $~tag_end = match.end(0)- if (max_length_within_target > 0 && tag_end > target_pos)- return max_length_within_target- end+ return max_length_within_target if max_length_within_target > 0 && tag_end > target_posmax_length_within_target = tag_endendenddiff --git a/plugins/discourse-ai/spec/lib/agents/bot_spec.rb b/plugins/discourse-ai/spec/lib/agents/bot_spec.rbindex cfbf61f238f..c3c2e6d0b6f 100644--- a/plugins/discourse-ai/spec/lib/agents/bot_spec.rb+++ b/plugins/discourse-ai/spec/lib/agents/bot_spec.rb@@ -63,7 +63,7 @@ RSpec.describe DiscourseAi::Agents::Bot docontext "when using function chaining" doit "yields a loading placeholder while proceeds to invoke the command" dotool = DiscourseAi::Agents::Tools::ListCategories.new({}, bot_user: nil, llm: nil)- partial_placeholder = +(<<~HTML)+ partial_placeholder = +<<~HTML<details><summary>#{tool.summary}</summary><p></p>diff --git a/plugins/discourse-ai/spec/lib/agents/tool_runner/index_spec.rb b/plugins/discourse-ai/spec/lib/agents/tool_runner/index_spec.rbindex 6dc587b09eb..485bdaa00e4 100644--- a/plugins/discourse-ai/spec/lib/agents/tool_runner/index_spec.rb+++ b/plugins/discourse-ai/spec/lib/agents/tool_runner/index_spec.rb@@ -60,7 +60,7 @@ RSpec.describe DiscourseAi::Agents::ToolRunner do@counter = 0stub_request(:post, cloudflare_embedding_def.url).to_return(status: 200,- body: lambda { |req| { result: { data: [([@counter += 2] * 1024)] } }.to_json },+ body: lambda { |req| { result: { data: [[@counter += 2] * 1024] } }.to_json },headers: {},)diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rbindex b6343e9f824..eb0431e07be 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/anthropic_spec.rb@@ -173,7 +173,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic doendit "can stream a response" do- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}@@ -707,7 +707,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic doendit "handles streaming with cache tokens" do- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "cache_creation_input_tokens": 100, "cache_read_input_tokens": 500, "output_tokens": 1}}}@@ -744,7 +744,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic doendit "discounts cached tokens in the explicit usage tracker" do- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 1000, "cache_creation_input_tokens": 0, "cache_read_input_tokens": 800, "output_tokens": 1}}}@@ -972,7 +972,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic doendit "can stream a response with thinking blocks" do- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25}}}@@ -1481,7 +1481,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic do},}- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}@@ -1594,7 +1594,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic do},}- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}@@ -1942,7 +1942,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Anthropic do},}- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_123", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/cohere_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/cohere_spec.rbindex d4b38da300f..f7295cab49c 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/cohere_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/cohere_spec.rb@@ -61,7 +61,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Cohere dobefore { enable_current_plugin }it "is able to trigger a tool" do- body = (<<~TEXT).strip+ body = <<~TEXT.strip{"is_finished":false,"event_type":"stream-start","generation_id":"1648206e-1fe4-4bb6-90cf-360dd55f575b"}{"is_finished":false,"event_type":"tool-calls-generation","text":"I will search for 'who is sam saffron' and relay the information to the user.","tool_calls":[{"name":"google","parameters":{"query":"who is sam saffron"}}]}{"is_finished":true,"event_type":"stream-end","response":{"response_id":"71d8c9e1-1138-4d70-80d1-10ddec41c989","text":"I will search for 'who is sam saffron' and relay the information to the user.","generation_id":"1648206e-1fe4-4bb6-90cf-360dd55f575b","chat_history":[{"role":"USER","message":"sam: who is sam saffron?"},{"role":"CHATBOT","message":"I will search for 'who is sam saffron' and relay the information to the user.","tool_calls":[{"name":"google","parameters":{"query":"who is sam saffron"}}]}],"finish_reason":"COMPLETE","meta":{"api_version":{"version":"1"},"billed_units":{"input_tokens":460,"output_tokens":27},"tokens":{"input_tokens":1227,"output_tokens":27}},"tool_calls":[{"name":"google","parameters":{"query":"who is sam saffron"}}]},"finish_reason":"COMPLETE"}diff --git a/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb b/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rbindex f448fc44421..c562da660ed 100644--- a/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/endpoints/vllm_spec.rb@@ -232,7 +232,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Vllm doendit "correctly accounts for tokens in non streaming mode" do- body = (<<~TEXT).strip+ body = <<~TEXT.strip{"id":"chat-c580e4a9ebaa44a0becc802ed5dc213a","object":"chat.completion","created":1731294404,"model":"meta-llama/Meta-Llama-3.1-70B-Instruct","choices":[{"index":0,"message":{"role":"assistant","content":"Random Number Generator Produces Smallest Possible Result","tool_calls":[]},"logprobs":null,"finish_reason":"stop","stop_reason":null}],"usage":{"prompt_tokens":146,"total_tokens":156,"completion_tokens":10},"prompt_logprobs":null}TEXT@@ -376,8 +376,7 @@ RSpec.describe DiscourseAi::Completions::Endpoints::Vllm dobody: hash_including("stream_options" => { "include_usage" => true }),).to_return(status: 200,- body:- +"data: #{({ choices: [{ delta: { content: "hello" } }] }).to_json}\n\ndata: [DONE]",+ body: +"data: #{{ choices: [{ delta: { content: "hello" } }] }.to_json}\n\ndata: [DONE]",)llm.generate("say hello", user: Discourse.system_user) { |_| }diff --git a/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb b/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rbindex 5f0a92ff81f..3dbb9ddcf4a 100644--- a/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/json_stream_decoder_spec.rb@@ -11,7 +11,7 @@ describe DiscourseAi::Completions::JsonStreamDecoder doendit "should handle anthropic mixed stlye streams" do- stream = (<<~TEXT).split("|")+ stream = <<~TEXT.split("|")event: |message_start|data: |{"hel|lo": "world"}|@@ -31,7 +31,7 @@ describe DiscourseAi::Completions::JsonStreamDecoder doendit "should be able to handle complex overlaps" do- stream = (<<~TEXT).split("|")+ stream = <<~TEXT.split("|")data: |{"hel|lo": "world"}data: {"foo": "bar"}diff --git a/plugins/discourse-ai/spec/lib/completions/xml_tool_processor_spec.rb b/plugins/discourse-ai/spec/lib/completions/xml_tool_processor_spec.rbindex 469ed0d5916..68815398883 100644--- a/plugins/discourse-ai/spec/lib/completions/xml_tool_processor_spec.rb+++ b/plugins/discourse-ai/spec/lib/completions/xml_tool_processor_spec.rb@@ -17,7 +17,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doit "can handle partial tool calls" doprocessor = DiscourseAi::Completions::XmlToolProcessor.new(partial_tool_calls: true)- xml = (<<~XML).strip+ xml = <<~XML.strip<function|_calls><invoke><tool_name>h|ell|o<|/tool_name>@@ -38,7 +38,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doxml.split("|").each { |part| result << (processor << part).map(&:dup) }- result << (processor.finish)+ result << processor.finishresult.flatten!tool1_params =@@ -68,7 +68,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doendit "can handle mix and match xml cause tool llms may not encode" do- xml = (<<~XML).strip+ xml = <<~XML.strip<function_calls><invoke><tool_name>hello</tool_name>@@ -81,14 +81,14 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << xml)- result << (processor.finish)+ result << processor.finishtool_call = result.last.firstexpect(tool_call.parameters).to eq(hello: "world <sam>sam</sam>", test: "</h1>\n</div>\n")endit "is usable for simple single message mode" do- xml = (<<~XML)+ xml = <<~XMLworld <function_calls><invoke><tool_name>hello</tool_name>@@ -116,7 +116,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << "hello")result << (processor << xml)- result << (processor.finish)+ result << processor.finishtool_call =DiscourseAi::Completions::ToolCall.new(@@ -133,7 +133,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doendit "handles multiple tool calls in sequence" do- xml = (<<~XML).strip+ xml = <<~XML.stripstart<function_calls><invoke>@@ -154,7 +154,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << xml)- result << (processor.finish)+ result << processor.finishfirst_tool =DiscourseAi::Completions::ToolCall.new(@@ -179,7 +179,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doendit "handles non-English parameters correctly" do- xml = (<<~XML).strip+ xml = <<~XML.stripこんにちは<function_calls><invoke>@@ -192,7 +192,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << xml)- result << (processor.finish)+ result << processor.finishtool_call =DiscourseAi::Completions::ToolCall.new(@@ -222,7 +222,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doendit "handles malformed XML gracefully" do- xml = (<<~XML).strip+ xml = <<~XML.striptext<function_calls><invoke>@@ -236,7 +236,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << xml)- result << (processor.finish)+ result << processor.finish# Should just do its best to parse the XMLtool_call = DiscourseAi::Completions::ToolCall.new(id: "tool_0", name: "test", parameters: {})@@ -244,7 +244,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doendit "correctly processes empty parameter sets" do- xml = (<<~XML).strip+ xml = <<~XML.striphello<function_calls><invoke>@@ -256,7 +256,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor doresult = []result << (processor << xml)- result << (processor.finish)+ result << processor.finishtool_call =DiscourseAi::Completions::ToolCall.new(id: "tool_0", name: "no_params", parameters: {})diff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_agent_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_agent_triage_spec.rbindex ab60b6057b9..679deef1605 100644--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_agent_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_agent_triage_spec.rb@@ -53,7 +53,7 @@ describe DiscourseAi::Automation::LlmAgentTriage doresponse_text = "I analyzed your post and can help with that."- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}diff --git a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rbindex 7fbc456a73c..f50568c1168 100644--- a/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb+++ b/plugins/discourse-ai/spec/lib/discourse_automation/llm_triage_spec.rb@@ -78,8 +78,8 @@ describe DiscourseAi::Automation::LlmTriage docount = ai_log.raw_request_payload.scan("hello").size# we could use the exact count here but it can get fragile# as we change tokenizers, this will give us reasonable confidence- expect(count).to be <= (100)- expect(count).to be > (50)+ expect(count).to be <= 100+ expect(count).to be > 50endit "can trigger via stalled_topic with topic context" dodiff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rbindex bb1e5a5edd1..68eb8ac7305 100644--- a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb+++ b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb@@ -385,7 +385,7 @@ RSpec.describe DiscourseAi::AiBot::Playground docontent = prompt.messages[1][:content]# this is fragile by design, mainly so the example can be ultra clear- expected = (<<~TEXT).strip+ expected = <<~TEXT.stripYou are replying inside a Discourse chat channel. Here is a summary of the conversation so far:{{{#{user.username}: (a magic thread)@@ -691,7 +691,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do# 1. we set context to 4# 2. however PromptMessagesBuilder will enforce rules of starting with :user and ending with it# so one of the model messages is dropped- expected = (<<~TEXT).strip+ expected = <<~TEXT.stripuser: request 3model: response 3user: Hello@@ -1234,7 +1234,7 @@ RSpec.describe DiscourseAi::AiBot::Playground doafter { DiscourseAi::AiBot::PostStreamer.on_callback = nil }it "should be able to cancel a completion halfway through" do- body = (<<~STRING).strip+ body = <<~STRING.stripevent: message_startdata: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-3-opus-20240229", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}diff --git a/plugins/discourse-ai/spec/models/ai_agent_spec.rb b/plugins/discourse-ai/spec/models/ai_agent_spec.rbindex 799386cddc0..39b6bf21f0c 100644--- a/plugins/discourse-ai/spec/models/ai_agent_spec.rb+++ b/plugins/discourse-ai/spec/models/ai_agent_spec.rb@@ -281,7 +281,7 @@ RSpec.describe AiAgent doAiAgent.all_agents- expect(AiAgent.agent_cache[:value].length).to be > (0)+ expect(AiAgent.agent_cache[:value].length).to be > 0RailsMultisite::ConnectionManagement.stubs(:current_db) { "abc" }expect(AiAgent.agent_cache[:value]).to eq(nil)enddiff --git a/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rbindex 61ee4178868..7f0cc0df013 100644--- a/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb+++ b/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb@@ -1131,7 +1131,7 @@ RSpec.describe DiscourseAi::Admin::AiAgentsController doheader_lines, _, payload_lines = lines.chunk { |l| l == "" }.map(&:last)- preamble = (<<~PREAMBLE).strip+ preamble = <<~PREAMBLE.stripHTTP/1.1 200 OKContent-Type: text/plain; charset=utf-8Transfer-Encoding: chunkeddiff --git a/plugins/discourse-ai/spec/system/ai_bot/share_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/share_spec.rbindex ca1e2d7fce6..7e800fd4a04 100644--- a/plugins/discourse-ai/spec/system/ai_bot/share_spec.rb+++ b/plugins/discourse-ai/spec/system/ai_bot/share_spec.rb@@ -60,7 +60,7 @@ RSpec.describe "Share conversation" doclip_text = cdp.read_clipboardexpect(clip_text).not_to eq("")- conversation = (<<~TEXT).strip+ conversation = <<~TEXT.strip<details class='ai-quote'><summary><span>This is my special PM</span>@@ -93,7 +93,7 @@ RSpec.describe "Share conversation" doclip_text = cdp.read_clipboardexpect(clip_text).not_to eq("")- conversation = (<<~TEXT).strip+ conversation = <<~TEXT.strip<details class='ai-quote'><summary><span>This is my special PM</span>@@ -121,7 +121,7 @@ RSpec.describe "Share conversation" doclip_text = cdp.read_clipboardexpect(clip_text).not_to eq("")- conversation = (<<~TEXT).strip+ conversation = <<~TEXT.strip<details class='ai-quote'><summary><span>This is my special PM</span>diff --git a/plugins/discourse-assign/lib/discourse_assign/helpers.rb b/plugins/discourse-assign/lib/discourse_assign/helpers.rbindex 04ec09b24ff..573955e4c35 100644--- a/plugins/discourse-assign/lib/discourse_assign/helpers.rb+++ b/plugins/discourse-assign/lib/discourse_assign/helpers.rb@@ -27,7 +27,7 @@ module DiscourseAssignstatus = assigned_map[:assignment_status]post_number = assigned_map[:post_number]- if (assigned_to.is_a?(User))+ if assigned_to.is_a?(User)[post_id,{diff --git a/plugins/discourse-assign/spec/lib/assigner_spec.rb b/plugins/discourse-assign/spec/lib/assigner_spec.rbindex 98671dc1fd7..0a662e15b1a 100644--- a/plugins/discourse-assign/spec/lib/assigner_spec.rb+++ b/plugins/discourse-assign/spec/lib/assigner_spec.rb@@ -304,9 +304,7 @@ RSpec.describe Assigner doit "reassigns a post even when at the assignments limit" doposts =- (described_class::ASSIGNMENTS_PER_TOPIC_LIMIT).times.map do- Fabricate(:post, topic: topic)- end+ described_class::ASSIGNMENTS_PER_TOPIC_LIMIT.times.map { Fabricate(:post, topic: topic) }posts.each do |post|user = Fabricate(:moderator)diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rbindex 402204b9bbd..de2b5e99092 100644--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb@@ -168,7 +168,7 @@ describe "Post event" doit "can create, close, and open an event" dovisit "/new-topic"title = "My upcoming l33t event"- tomorrow = (1.day.from_now).strftime("%Y-%m-%d")+ tomorrow = 1.day.from_now.strftime("%Y-%m-%d")composer.fill_title(title)composer.fill_content <<~MD[event start="#{tomorrow} 13:37" status="public"]diff --git a/plugins/discourse-chat-integration/app/controllers/discourse_chat_integration/chat_controller.rb b/plugins/discourse-chat-integration/app/controllers/discourse_chat_integration/chat_controller.rbindex 29e1113dac7..139651c39b6 100644--- a/plugins/discourse-chat-integration/app/controllers/discourse_chat_integration/chat_controller.rb+++ b/plugins/discourse-chat-integration/app/controllers/discourse_chat_integration/chat_controller.rb@@ -20,7 +20,7 @@ class DiscourseChatIntegration::ChatController < ApplicationControllerid: provider_klass::PROVIDER_NAME,channel_parameters:(- if (defined?(provider_klass::CHANNEL_PARAMETERS))+ if defined?(provider_klass::CHANNEL_PARAMETERS)provider_klass::CHANNEL_PARAMETERSelse[]diff --git a/plugins/discourse-chat-integration/app/helpers/helper.rb b/plugins/discourse-chat-integration/app/helpers/helper.rbindex b7a5f4e8f46..6ad42a7ed87 100644--- a/plugins/discourse-chat-integration/app/helpers/helper.rb+++ b/plugins/discourse-chat-integration/app/helpers/helper.rb@@ -20,7 +20,7 @@ module DiscourseChatIntegrationif category_namecategory = Category.find_by(slug: category_name)unless category- cat_list = (CategoryList.new(guardian).categories.map(&:slug)).join(", ")+ cat_list = CategoryList.new(guardian).categories.map(&:slug).join(", ")return(I18n.t("chat_integration.provider.#{provider}.not_found.category",@@ -124,7 +124,7 @@ module DiscourseChatIntegrationcategory: category_name,)- if SiteSetting.tagging_enabled && (!rule.tags.nil?)+ if SiteSetting.tagging_enabled && !rule.tags.nil?text << I18n.t("chat_integration.provider.#{provider}.status.rule_string_tags_suffix",tags: rule.tags.join(", "),@@ -144,7 +144,7 @@ module DiscourseChatIntegration# status_for_channel functiondef self.delete_by_index(channel, index)rules = channel.rules.order_by_precedence- return false if index < (1) || index > (rules.size)+ return false if index < 1 || index > rules.size:deleted if rules[index - 1].destroyenddiff --git a/plugins/discourse-chat-integration/app/models/rule.rb b/plugins/discourse-chat-integration/app/models/rule.rbindex e7190f37756..44a7ad42c5d 100644--- a/plugins/discourse-chat-integration/app/models/rule.rb+++ b/plugins/discourse-chat-integration/app/models/rule.rb@@ -97,7 +97,7 @@ class DiscourseChatIntegration::Rule < DiscourseChatIntegration::PluginModelprivatedef channel_valid?- if !(DiscourseChatIntegration::Channel.where(id: channel_id).exists?)+ if !DiscourseChatIntegration::Channel.where(id: channel_id).exists?errors.add(:channel_id, "#{channel_id} is not a valid channel id")endenddiff --git a/plugins/discourse-chat-integration/app/services/manager.rb b/plugins/discourse-chat-integration/app/services/manager.rbindex 7ec6d59e895..ed2695172bd 100644--- a/plugins/discourse-chat-integration/app/services/manager.rb+++ b/plugins/discourse-chat-integration/app/services/manager.rb@@ -63,7 +63,7 @@ module DiscourseChatIntegrationmatching_rules =matching_rules.select do |rule|next true if rule.tags.nil? || rule.tags.empty? # Filter has no tags specified- any_tags_match = !((rule.tags & topic_tags).empty?)+ any_tags_match = !(rule.tags & topic_tags).empty?next any_tags_match # If any tags match, keep this filter, otherwise throw awayendend@@ -109,7 +109,7 @@ module DiscourseChatIntegrationprovider.trigger_notification(post, channel, rule)channel.update_attribute("error_key", nil) if channel.error_keyrescue => e- if e.class == (DiscourseChatIntegration::ProviderError) && e.info.key?(:error_key) &&+ if e.class == DiscourseChatIntegration::ProviderError && e.info.key?(:error_key) &&!e.info[:error_key].nil?channel.update_attribute("error_key", e.info[:error_key])elsediff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rbindex 84a02570840..1284ef58fe5 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb@@ -92,7 +92,7 @@ module DiscourseChatIntegrationengine =provider.constants- .select { |constant| constant.to_s =~ (/Engine$/) && (constant.to_s != "HookEngine") }+ .select { |constant| constant.to_s =~ /Engine$/ && (constant.to_s != "HookEngine") }.map(&provider.method(:const_get)).firstdiff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rbindex 09829e5d97e..64f01ceb5f0 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb@@ -44,7 +44,7 @@ module DiscourseChatIntegrationif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rbindex 9699af436d1..ad33f3554dd 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/groupme/groupme_provider.rb@@ -17,7 +17,7 @@ module DiscourseChatIntegration::Provider::GroupmeProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"#{topic.category.parent_category.name}/#{topic.category.name}"else"#{topic.category.name}"diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rbindex b7796f21983..1528b6687e4 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/mattermost/mattermost_provider.rb@@ -44,7 +44,7 @@ module DiscourseChatIntegrationelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"@@ -55,9 +55,7 @@ module DiscourseChatIntegrationicon_url =if SiteSetting.chat_integration_mattermost_icon_url.present?UrlHelper.absolute(SiteSetting.chat_integration_mattermost_icon_url)- elsif (- url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)- ).present?+ elsif (url = SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url).present?UrlHelper.absolute(url)enddiff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rbindex 6c9857d5ff7..cb2dcca231f 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/powerautomate/powerautomate_provider.rb@@ -53,7 +53,7 @@ module DiscourseChatIntegration::Provider::PowerAutomateProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rbindex 445a0753b27..b93ccbc828c 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/rocketchat/rocketchat_provider.rb@@ -19,7 +19,7 @@ module DiscourseChatIntegration::Provider::RocketchatProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_enabled_setting_validator.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_enabled_setting_validator.rbindex 4daf442576b..6d25d7fc83a 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_enabled_setting_validator.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_enabled_setting_validator.rb@@ -6,7 +6,7 @@ class ChatIntegrationSlackEnabledSettingValidatorenddef valid_value?(val)- return true if val == ("f") || val == (false)+ return true if val == "f" || val == falseif SiteSetting.chat_integration_slack_outbound_webhook_url.blank? &&SiteSetting.chat_integration_slack_access_token.blank?return falsediff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rbindex 73e7dcf22e4..7a11ff77c7e 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_provider.rb@@ -157,7 +157,7 @@ module DiscourseChatIntegration::Provider::SlackProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"@@ -168,7 +168,7 @@ module DiscourseChatIntegration::Provider::SlackProvidericon_url =if SiteSetting.chat_integration_slack_icon_url.present?"#{Discourse.base_url}#{SiteSetting.chat_integration_slack_icon_url}"- elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?+ elsif (url = SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url).present?"#{Discourse.base_url}#{url}"end@@ -215,7 +215,7 @@ module DiscourseChatIntegration::Provider::SlackProvidericon_url =if SiteSetting.chat_integration_slack_icon_url.present?"#{Discourse.base_url}#{SiteSetting.chat_integration_slack_icon_url}"- elsif (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?+ elsif (url = SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url).present?"#{Discourse.base_url}#{url}"end@@ -246,7 +246,7 @@ module DiscourseChatIntegration::Provider::SlackProviderif topic.category&.uncategorized?"[#{I18n.t("uncategorized_category_name")}]"elsif topic.category- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"@@ -345,7 +345,7 @@ module DiscourseChatIntegration::Provider::SlackProviderunless response.kind_of? Net::HTTPSuccessif response.code.to_s == "403"error_key = "chat_integration.provider.slack.errors.action_prohibited"- elsif response.body == ("channel_not_found") || response.body == ("channel_is_archived")+ elsif response.body == "channel_not_found" || response.body == "channel_is_archived"error_key = "chat_integration.provider.slack.errors.channel_not_found"elseerror_key = nildiff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rbindex 7c1e2a5bfde..63b01766a11 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/teams/teams_provider.rb@@ -50,7 +50,7 @@ module DiscourseChatIntegration::Provider::TeamsProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"#{topic.category.parent_category.name}/#{topic.category.name}"elsetopic.category.namediff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rbindex a9dc4c9e101..11bddfc7b15 100644--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb@@ -52,7 +52,7 @@ module DiscourseChatIntegration::Provider::WebexProviderelsif topic.categorycategory =(- if (topic.category.parent_category)+ if topic.category.parent_category"[#{topic.category.parent_category.name}/#{topic.category.name}]"else"[#{topic.category.name}]"diff --git a/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb b/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rbindex 20978346f08..82e99de6f03 100644--- a/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb+++ b/plugins/discourse-data-explorer/lib/discourse_data_explorer/parameter.rb@@ -223,7 +223,7 @@ module DiscourseDataExplorervalue = object.idwhen :user_id, :post_id, :topic_id, :group_id, :badge_idif string.gsub(/[ _]/, "") =~ /^-?\d+$/- klass_name = (/^(.*)_id$/.match(type.to_s)[1].classify.to_sym)+ klass_name = /^(.*)_id$/.match(type.to_s)[1].classify.to_symbeginfinder =if type == :post_id || type == :topic_iddiff --git a/plugins/discourse-gamification/app/controllers/discourse_gamification/admin_gamification_leaderboard_controller.rb b/plugins/discourse-gamification/app/controllers/discourse_gamification/admin_gamification_leaderboard_controller.rbindex 89c3bb26ee9..4e004020f63 100644--- a/plugins/discourse-gamification/app/controllers/discourse_gamification/admin_gamification_leaderboard_controller.rb+++ b/plugins/discourse-gamification/app/controllers/discourse_gamification/admin_gamification_leaderboard_controller.rb@@ -54,7 +54,7 @@ class DiscourseGamification::AdminGamificationLeaderboardController < Admin::Admvisible_to_groups_ids: params[:visible_to_groups_ids] || [],default_period: params[:default_period],period_filter_disabled: params[:period_filter_disabled] || false,- score_overrides: (params[:score_overrides].presence&.to_unsafe_h&.transform_values(&:to_i)),+ score_overrides: params[:score_overrides].presence&.to_unsafe_h&.transform_values(&:to_i),scorable_category_ids: params[:scorable_category_ids].presence,)diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rbindex 1b29dbf5316..e611fa39dd8 100644--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb@@ -60,7 +60,7 @@ module DiscourseNarrativeBotold_data = @data.dupnew_post =- if (@skip && @state != :end)+ if @skip && @state != :endskip_tutorial(next_state)elseself.send(action)diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rbindex e9d64cd7f55..9c17b31b347 100644--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/new_user_narrative.rb@@ -556,7 +556,7 @@ module DiscourseNarrativeBot.where(user_id: @user.id).where("post_action_type_id IN (?)",- (PostActionType.flag_types.values - [PostActionType.types[:inappropriate]]),+ PostActionType.flag_types.values - [PostActionType.types[:inappropriate]],).destroy_allenddiff --git a/plugins/discourse-policy/plugin.rb b/plugins/discourse-policy/plugin.rbindex 3b22e6b7666..a384ab2f19f 100644--- a/plugins/discourse-policy/plugin.rb+++ b/plugins/discourse-policy/plugin.rb@@ -106,7 +106,7 @@ after_initialize dopost_policy.post_policy_groups = new_relationsrenew_days = policy["data-renew"]- if (renew_days.to_i) > 0 || PostPolicy.renew_intervals.keys.include?(renew_days)+ if renew_days.to_i > 0 || PostPolicy.renew_intervals.keys.include?(renew_days)post_policy.renew_days =PostPolicy.renew_intervals.keys.include?(renew_days) ? nil : renew_dayspost_policy.renew_interval = post_policy.renew_days.present? ? nil : renew_daysdiff --git a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb b/plugins/discourse-policy/spec/lib/pretty_text_spec.rbindex 7733a859813..a4a051cdd46 100644--- a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb+++ b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb@@ -13,7 +13,7 @@ describe PrettyText do[/policy]MD- cooked = (<<~HTML).strip+ cooked = <<~HTML.strip<div class="policy" data-accept="banana" data-group="team" data-reminder="weekly" data-renew-start="2010-01-01" data-revoke="apple" data-version="1"><p>I always open <strong>doors</strong>!</p></div>@@ -29,7 +29,7 @@ describe PrettyText do[/policy]MD- cooked = (<<~HTML).strip+ cooked = <<~HTML.strip<div class="policy" data-accept="banana" data-groups="team,staff" data-reminder="weekly" data-renew-start="2010-01-01" data-revoke="apple" data-version="1"><p>I always open <strong>doors</strong>!</p></div>diff --git a/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb b/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rbindex f00569a69f6..caa46c2a562 100644--- a/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb+++ b/plugins/discourse-post-voting/app/models/reviewable_post_voting_comment.rb@@ -25,7 +25,7 @@ class ReviewablePostVotingComment < Reviewableenddef comment- @comment ||= (target || PostVotingComment.with_deleted.find_by(id: target_id))+ @comment ||= target || PostVotingComment.with_deleted.find_by(id: target_id)enddef comment_creatordiff --git a/plugins/discourse-templates/lib/tasks/discourse-templates.rake b/plugins/discourse-templates/lib/tasks/discourse-templates.rakeindex 7b0be68e215..25573b6eeda 100644--- a/plugins/discourse-templates/lib/tasks/discourse-templates.rake+++ b/plugins/discourse-templates/lib/tasks/discourse-templates.rake@@ -196,7 +196,7 @@ def purge_old_datakey: canned_replies_store_name,)- (old_replies.presence&.destroy!)+ old_replies.presence&.destroy!puts "Finished!"rescue StandardError => ediff --git a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rbindex 1afd2f247d2..423526a27ac 100644--- a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb+++ b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb@@ -188,7 +188,7 @@ describe DiscourseTemplates::TopicQueryExtension doit "won't list private messages received as templates" dotopics = topic_query.list_private_templates.topics- expect(((topics.map(&:id) & private_messages_from_user_a.map(&:id)).any?)).to eq(false)+ expect((topics.map(&:id) & private_messages_from_user_a.map(&:id)).any?).to eq(false)endendenddiff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rbindex d362175d03f..b368f821782 100644--- a/script/bulk_import/base.rb+++ b/script/bulk_import/base.rb@@ -1557,7 +1557,7 @@ class BulkImport::Basecategory[:name_lower] = name_lowerslug_next_number = 1- original_slug = slug = (category[:slug] || Slug.for(name_lower, ""))+ original_slug = slug = category[:slug] || Slug.for(name_lower, "")while !@category_slugs.add?(slug.downcase)slug = "#{original_slug}-#{slug_next_number}"diff --git a/script/bulk_import/vbulletin.rb b/script/bulk_import/vbulletin.rbindex 4ed8fed48c0..e69c56f8274 100644--- a/script/bulk_import/vbulletin.rb+++ b/script/bulk_import/vbulletin.rb@@ -637,7 +637,7 @@ class BulkImport::VBulletin < BulkImport::BaseDir.foreach(AVATAR_DIR) do |item|print "\r%7d - %6d/sec" % [count, count.to_f / (Time.now - start)]- next if item == (".") || item == ("..") || item == (".DS_Store")+ next if item == "." || item == ".." || item == ".DS_Store"next unless item =~ /avatar(\d+)_(\d).gif/scan = item.scan(/avatar(\d+)_(\d).gif/)next if scan[0][0].blank?diff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rbindex 529cd969dd0..b30243e48c3 100644--- a/script/import_scripts/discuz_x.rb+++ b/script/import_scripts/discuz_x.rb@@ -191,17 +191,15 @@ class ImportScripts::DiscuzX < ImportScripts::Basewebsite:(user["website"] && user["website"].include?(".")) ?user["website"].strip :- if (- user["qq"] && user["qq"].strip == (user["qq"].strip.to_i) &&- user["qq"].strip.to_i > (10_000)- )+ if user["qq"] && user["qq"].strip == user["qq"].strip.to_i &&+ user["qq"].strip.to_i > 10_000"http://user.qzone.qq.com/" + user["qq"].stripelsenilend,bio_raw:first_exists(- (user["bio"] && CGI.unescapeHTML(user["bio"])),+ user["bio"] && CGI.unescapeHTML(user["bio"]),user["sightml"],user["spacenote"],).strip[@@ -231,7 +229,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base),post_create_action:lambda do |newmember|- if user["avatar_exists"] == (1) && newmember.uploaded_avatar_id.blank?+ if user["avatar_exists"] == 1 && newmember.uploaded_avatar_id.blank?path, filename = discuzx_avatar_fullpath(user["id"])if pathbegin@@ -311,7 +309,7 @@ class ImportScripts::DiscuzX < ImportScripts::Baseif newmember.email_digestsnewmember.update(email_digests: user["email_confirmed"] == 1)end- if newmember.name.present? && newmember.name == (newmember.username)+ if newmember.name.present? && newmember.name == newmember.usernamenewmember.update(name: "")endend,@@ -341,7 +339,7 @@ class ImportScripts::DiscuzX < ImportScripts::Basemax_position = Category.all.max_by(&:position).positioncreate_categories(results) do |row|- next if row["type"] == ("group") || row["status"] == (2) # or row['status'].to_i == 3 # 如果不想导入群组,取消注释+ next if row["type"] == "group" || row["status"] == 2 # or row['status'].to_i == 3 # 如果不想导入群组,取消注释extra = PHP.unserialize(row["extra"]) if row["extra"].present?color = extra["namecolor"][1, 6] if extra && extra["namecolor"].present?@@ -388,7 +386,7 @@ class ImportScripts::DiscuzX < ImportScripts::Baseendend- if row["status"] == (0) || row["status"] == (3)+ if row["status"] == 0 || row["status"] == 3SiteSetting.default_categories_muted = [SiteSetting.default_categories_muted,category.id,@@ -720,7 +718,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base)# convert quote- s.gsub!(%r{\[quote\](.*?)\[/quote\]}m) { "\n" + ($1.strip).gsub(/^/, "> ") + "\n" }+ s.gsub!(%r{\[quote\](.*?)\[/quote\]}m) { "\n" + $1.strip.gsub(/^/, "> ") + "\n" }# truncate line space, preventing line starting with many blanks to be parsed as code blockss.gsub!(/^ {4,}/, " ")@@ -821,34 +819,26 @@ class ImportScripts::DiscuzX < ImportScripts::Bases.gsub!(internal_url_regexp) do |discuzx_link|replace_internal_link(discuzx_link,- (- begin- $~[:tid].to_i- rescue StandardError- nil- end- ),- (- begin- $~[:pid].to_i- rescue StandardError- nil- end- ),- (- begin- $~[:fid].to_i- rescue StandardError- nil- end- ),- (- begin- $~[:action]- rescue StandardError- nil- end- ),+ begin+ $~[:tid].to_i+ rescue StandardError+ nil+ end,+ begin+ $~[:pid].to_i+ rescue StandardError+ nil+ end,+ begin+ $~[:fid].to_i+ rescue StandardError+ nil+ end,+ begin+ $~[:action]+ rescue StandardError+ nil+ end,)endenddiff --git a/script/import_scripts/drupal-6.rb b/script/import_scripts/drupal-6.rbindex 518f3c50a7d..4ac4a2a54be 100644--- a/script/import_scripts/drupal-6.rb+++ b/script/import_scripts/drupal-6.rb@@ -219,7 +219,7 @@ class ImportScripts::Drupal < ImportScripts::Base}if row["pid"]parent = topic_lookup_from_imported_post_id("cid:#{row["pid"]}")- h[:reply_to_post_number] = parent[:post_number] if parent && parent[:post_number] > (1)+ h[:reply_to_post_number] = parent[:post_number] if parent && parent[:post_number] > 1endhelsediff --git a/script/import_scripts/drupal.rb b/script/import_scripts/drupal.rbindex 98225f106a7..42b165c6880 100644--- a/script/import_scripts/drupal.rb+++ b/script/import_scripts/drupal.rb@@ -245,7 +245,7 @@ class ImportScripts::Drupal < ImportScripts::Base}if row["pid"]parent = topic_lookup_from_imported_post_id("cid:#{row["pid"]}")- h[:reply_to_post_number] = parent[:post_number] if parent && parent[:post_number] > (1)+ h[:reply_to_post_number] = parent[:post_number] if parent && parent[:post_number] > 1endhelsediff --git a/script/import_scripts/ipboard.rb b/script/import_scripts/ipboard.rbindex 012404cedc5..4dd91efd4bc 100644--- a/script/import_scripts/ipboard.rb+++ b/script/import_scripts/ipboard.rb@@ -308,7 +308,7 @@ class ImportScripts::IpboardSQL < ImportScripts::Basecreate_category(params, params[:id])create_categories(categories) do |category|- id = (category["id"]).to_s+ id = category["id"].to_sname = CGI.unescapeHTML(cat_map[id]){id: id + "gal",diff --git a/script/import_scripts/jive.rb b/script/import_scripts/jive.rbindex 1c8b34cdc30..f047244b272 100644--- a/script/import_scripts/jive.rb+++ b/script/import_scripts/jive.rb@@ -273,7 +273,7 @@ class ImportScripts::Jive < ImportScripts::BaseDir.foreach("/var/www/discourse/script/import_scripts/jive/img/#{thread.messageid}",) do |item|- next if item == (".") || item == ("..") || item == (".DS_Store")+ next if item == "." || item == ".." || item == ".DS_Store"photo_path ="/var/www/discourse/script/import_scripts/jive/img/#{thread.messageid}/#{item}"upload = create_upload(thread.userid, photo_path, File.basename(photo_path))@@ -291,7 +291,7 @@ class ImportScripts::Jive < ImportScripts::BaseDir.foreach("/var/www/discourse/script/import_scripts/jive/attach/#{thread.messageid}",) do |item|- next if item == (".") || item == ("..") || item == (".DS_Store")+ next if item == "." || item == ".." || item == ".DS_Store"attach_path ="/var/www/discourse/script/import_scripts/jive/attach/#{thread.messageid}/#{item}"upload = create_upload(thread.userid, attach_path, File.basename(attach_path))@@ -337,7 +337,7 @@ class ImportScripts::Jive < ImportScripts::BaseDir.foreach("/var/www/discourse/script/import_scripts/jive/img/#{thread.messageid}",) do |item|- next if item == (".") || item == ("..") || item == (".DS_Store")+ next if item == "." || item == ".." || item == ".DS_Store"photo_path ="/var/www/discourse/script/import_scripts/jive/img/#{thread.messageid}/#{item}"upload = create_upload(thread.userid, photo_path, File.basename(photo_path))@@ -355,7 +355,7 @@ class ImportScripts::Jive < ImportScripts::BaseDir.foreach("/var/www/discourse/script/import_scripts/jive/attach/#{thread.messageid}",) do |item|- next if item == (".") || item == ("..") || item == (".DS_Store")+ next if item == "." || item == ".." || item == ".DS_Store"attach_path ="/var/www/discourse/script/import_scripts/jive/attach/#{thread.messageid}/#{item}"upload = create_upload(thread.userid, attach_path, File.basename(attach_path))diff --git a/script/import_scripts/kunena.rb b/script/import_scripts/kunena.rbindex a04f6082c34..1c8f98109c0 100644--- a/script/import_scripts/kunena.rb+++ b/script/import_scripts/kunena.rb@@ -75,7 +75,7 @@ class ImportScripts::Kunena < ImportScripts::Baseresults =@client.query("SELECT id, username, email, registerDate FROM jos_users;", cache_rows: false)results.each do |u|- next if u["id"].to_i <= (0) || u["username"].blank? || u["email"].blank?+ next if u["id"].to_i <= 0 || u["username"].blank? || u["email"].blank?username = u["username"].gsub(" ", "_").gsub(/[^A-Za-z0-9_]/, "")[0, User.username_length.end]if username.length < User.username_length.firstusername = username * User.username_length.firstdiff --git a/script/import_scripts/kunena3.rb b/script/import_scripts/kunena3.rbindex f2b77bfc138..e468aab0f38 100644--- a/script/import_scripts/kunena3.rb+++ b/script/import_scripts/kunena3.rb@@ -94,7 +94,7 @@ class ImportScripts::Kunena < ImportScripts::Basecache_rows: false,)results.each do |u|- next if u["id"].to_i <= (0) || u["username"].blank? || u["email"].blank?+ next if u["id"].to_i <= 0 || u["username"].blank? || u["email"].blank?username = u["username"].gsub(" ", "_").gsub(/[^A-Za-z0-9_]/, "")[0, User.username_length.end]if username.length < User.username_length.firstusername = username * User.username_length.firstdiff --git a/script/import_scripts/nabble.rb b/script/import_scripts/nabble.rbindex 20c28b01918..90f1cc2aaf5 100644--- a/script/import_scripts/nabble.rb+++ b/script/import_scripts/nabble.rb@@ -283,7 +283,7 @@ endclass Stringdef indent(count, char = " ")gsub(/([^\n]*)(\n|$)/) do |match|- last_iteration = ($1 == "" && $2 == "")+ last_iteration = $1 == "" && $2 == ""line = +""line << (char * count) unless last_iterationline << $1diff --git a/script/import_scripts/quandora/import.rb b/script/import_scripts/quandora/import.rbindex ec2cbdcd279..7341a2ca263 100644--- a/script/import_scripts/quandora/import.rb+++ b/script/import_scripts/quandora/import.rb@@ -11,7 +11,7 @@ class ImportScripts::Quandora < ImportScripts::Base@system_user = Discourse.system_user@questions = []Dir.foreach(JSON_FILES_DIR) do |filename|- next if filename == (".") || filename == ("..")+ next if filename == "." || filename == ".."question = File.read JSON_FILES_DIR + "/" + filename@questions << questionenddiff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rbindex 6dd2d9b3bf1..93d324de916 100644--- a/script/import_scripts/smf2.rb+++ b/script/import_scripts/smf2.rb@@ -504,7 +504,7 @@ class ImportScripts::Smf2 < ImportScripts::Baseif use_count.keys.length < attachments.select(&:present?).lengthbody = "#{body}\n\n---"attachments.each_with_index do |upload, num|- "#{body}\n\n#{get_upload_markdown(upload)}" if upload.present? && use_count[num] == (0)+ "#{body}\n\n#{get_upload_markdown(upload)}" if upload.present? && use_count[num] == 0endendenddiff --git a/script/import_scripts/socialcast/import.rb b/script/import_scripts/socialcast/import.rbindex 9fcd70b6962..2a12c2dc5c2 100644--- a/script/import_scripts/socialcast/import.rb+++ b/script/import_scripts/socialcast/import.rb@@ -27,7 +27,7 @@ class ImportScripts::Socialcast < ImportScripts::Baseimported = 0total = count_files(MESSAGES_DIR)Dir.foreach(MESSAGES_DIR) do |filename|- next if filename == (".") || filename == ("..")+ next if filename == "." || filename == ".."topics += 1message_json = File.read MESSAGES_DIR + "/" + filenamemessage = SocialcastMessage.new(message_json)@@ -44,7 +44,7 @@ class ImportScripts::Socialcast < ImportScripts::Baseusers = 0total = count_files(USERS_DIR)Dir.foreach(USERS_DIR) do |filename|- next if filename == (".") || filename == ("..")+ next if filename == "." || filename == ".."user_json = File.read USERS_DIR + "/" + filenameuser = SocialcastUser.new(user_json).usercreate_user user, user[:id]diff --git a/script/import_scripts/socialcast/title.rb b/script/import_scripts/socialcast/title.rbindex 977aa712c26..2cf032e87c6 100644--- a/script/import_scripts/socialcast/title.rb+++ b/script/import_scripts/socialcast/title.rb@@ -10,7 +10,7 @@ def titlestopics = 0total = count_files(MESSAGES_DIR)Dir.foreach(MESSAGES_DIR) do |filename|- next if filename == (".") || filename == ("..")+ next if filename == "." || filename == ".."message_json = File.read MESSAGES_DIR + "/" + filenamemessage = SocialcastMessage.new(message_json)next unless message.titlediff --git a/script/import_scripts/vbulletin3.rb b/script/import_scripts/vbulletin3.rbindex 41f5cfaff3d..074efce8fb6 100644--- a/script/import_scripts/vbulletin3.rb+++ b/script/import_scripts/vbulletin3.rb@@ -587,7 +587,7 @@ LEFT OUTER JOIN #{TABLE_PREFIX}avatar a ON a.avatarid = u.avataridcategory.default_list_filter = "none"end- if (forum["is_category_only"] == 1 && access[:public_access] == 1)+ if forum["is_category_only"] == 1 && access[:public_access] == 1puts "\t#{category.name} is a public category only"category.permissions = { everyone: :readonly }category.save()diff --git a/script/test_memory_leak.rb b/script/test_memory_leak.rbindex a426d367841..97015ea32d2 100644--- a/script/test_memory_leak.rb+++ b/script/test_memory_leak.rb@@ -26,7 +26,7 @@ def bin_diff(current)$baseline[:arenas].each_with_index do |arena, i|next if !arena || !arena[:bins]arena[:bins].each do |size, stat|- allocated = (current.dig(:arenas, i, :bins, size, :allocated) || 0)+ allocated = current.dig(:arenas, i, :bins, size, :allocated) || 0diff = allocated - stat[:allocated]puts "bin #{size} delta #{diff}"enddiff --git a/spec/lib/crawler_detection_spec.rb b/spec/lib/crawler_detection_spec.rbindex a85feabe65e..cf733e93174 100644--- a/spec/lib/crawler_detection_spec.rb+++ b/spec/lib/crawler_detection_spec.rb@@ -2,7 +2,7 @@RSpec.describe CrawlerDetection dodef crawler!(user_agent, via = nil)- raise "#{user_agent} should be a crawler!" if (!CrawlerDetection.crawler?(user_agent, via))+ raise "#{user_agent} should be a crawler!" if !CrawlerDetection.crawler?(user_agent, via)enddef not_crawler!(s)diff --git a/spec/lib/middleware/processing_request_spec.rb b/spec/lib/middleware/processing_request_spec.rbindex bed28d21733..7ae3562caf3 100644--- a/spec/lib/middleware/processing_request_spec.rb+++ b/spec/lib/middleware/processing_request_spec.rb@@ -5,7 +5,7 @@ RSpec.describe Middleware::ProcessingRequest dodescribe "#call" doit "sets the request queue seconds in the env based on the HTTP-X-REQUEST-START header" do- env = create_request_env.merge("HTTP_X_REQUEST_START" => "t=#{(Time.now.to_f - 2)}")+ env = create_request_env.merge("HTTP_X_REQUEST_START" => "t=#{Time.now.to_f - 2}")_status, _headers, _body = app.call(env)expect(env[described_class::REQUEST_QUEUE_SECONDS_ENV_KEY]).to be_within(0.1).of(2.0)diff --git a/spec/lib/mobile_detection_spec.rb b/spec/lib/mobile_detection_spec.rbindex 8db8352039d..1952b9666fa 100644--- a/spec/lib/mobile_detection_spec.rb+++ b/spec/lib/mobile_detection_spec.rb@@ -2,7 +2,7 @@RSpec.describe MobileDetection dolet :old_user_agents do- (<<~STR).split("\n")+ <<~STR.split("\n")Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; LG-L160L Build/IML74K) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30Mozilla/5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.comMozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; S@@ -19,7 +19,7 @@ RSpec.describe MobileDetection doendlet :modern_user_agents do- (<<~STR).split("\n")+ <<~STR.split("\n")Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1Mozilla/5.0 (iPad; CPU OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1diff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rbindex 6cdf975ec2a..92d2dac6b89 100644--- a/spec/lib/post_creator_spec.rb+++ b/spec/lib/post_creator_spec.rb@@ -255,8 +255,8 @@ RSpec.describe PostCreator doadmin_ids = [Group[:admins].id]expect(messages.any? do |m|- m.group_ids != admin_ids &&- (!m.user_ids.include?(other_admin.id) && !m.user_ids.include?(admin.id))+ m.group_ids != admin_ids && !m.user_ids.include?(other_admin.id) &&+ !m.user_ids.include?(admin.id)end,).to eq(false)end@@ -877,8 +877,8 @@ RSpec.describe PostCreator doGroupMessage.expects(:create).with do |group_name, msg_type, params|- group_name == (Group[:moderators].name) && msg_type == (:spam_post_blocked) &&- params[:user].id == (user.id)+ group_name == Group[:moderators].name && msg_type == :spam_post_blocked &&+ params[:user].id == user.idendcreator.createenddiff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rbindex 49aeb542315..f410a7d50bc 100644--- a/spec/lib/pretty_text_spec.rb+++ b/spec/lib/pretty_text_spec.rb@@ -2777,7 +2777,7 @@ HTML# basically it is super hard to remember every single rare letter when there are# so many, so ruby tags provide a hint.#- html = (<<~MD).strip+ html = <<~MD.strip<ruby lang="je"><rb lang="je">X</rb>漢 <rp>(</rp><rt lang="je"> ㄏㄢˋ </rt><rp>)</rp>diff --git a/spec/lib/site_settings/yaml_loader_spec.rb b/spec/lib/site_settings/yaml_loader_spec.rbindex ee0b8bc0a41..6e72942dc3c 100644--- a/spec/lib/site_settings/yaml_loader_spec.rb+++ b/spec/lib/site_settings/yaml_loader_spec.rb@@ -72,8 +72,8 @@ RSpec.describe SiteSettings::YamlLoader doreceiver.expects(:setting).with do |category, name, default, opts|- category == ("basics") && name == ("default_locale") && default == ("en") &&- opts[:enum] == ("LocaleSiteSetting") && opts[:client] == true+ category == "basics" && name == "default_locale" && default == "en" &&+ opts[:enum] == "LocaleSiteSetting" && opts[:client] == trueendreceiver.load_yaml(enum_client)enddiff --git a/spec/lib/validators/topic_title_length_validator_spec.rb b/spec/lib/validators/topic_title_length_validator_spec.rbindex afde8dc9bf0..c94cbf89115 100644--- a/spec/lib/validators/topic_title_length_validator_spec.rb+++ b/spec/lib/validators/topic_title_length_validator_spec.rb@@ -26,13 +26,13 @@ RSpec.describe TopicTitleLengthValidator doendit "does not add an error when length is good" do- record.title = "a" * (SiteSetting.min_topic_title_length)+ record.title = "a" * SiteSetting.min_topic_title_lengthvalidateexpect(record.errors[:title]).to_not be_presentendit "is up to date" do- record.title = "a" * (SiteSetting.min_topic_title_length)+ record.title = "a" * SiteSetting.min_topic_title_lengthvalidateexpect(record.errors[:title]).to_not be_present@@ -56,7 +56,7 @@ RSpec.describe TopicTitleLengthValidator doendit "does not add an error when topic title is shorter than SiteSetting.min_topic_title_length" do- record.title = "a" * (SiteSetting.min_personal_message_title_length)+ record.title = "a" * SiteSetting.min_personal_message_title_lengthvalidateexpect(record.errors[:title]).to_not be_presentenddiff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rbindex 9eaa92efa33..71198f5a4e2 100644--- a/spec/models/remote_theme_spec.rb+++ b/spec/models/remote_theme_spec.rb@@ -670,7 +670,7 @@ RSpec.describe RemoteTheme doI18n.t("themes.import_error.about_json_too_big",limit:- ActiveSupport::NumberHelper.number_to_human_size((RemoteTheme::MAX_METADATA_FILE_SIZE)),+ ActiveSupport::NumberHelper.number_to_human_size(RemoteTheme::MAX_METADATA_FILE_SIZE),),)enddiff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rbindex a20a8384c71..df8b8b8be6e 100644--- a/spec/models/topic_link_spec.rb+++ b/spec/models/topic_link_spec.rb@@ -254,7 +254,7 @@ RSpec.describe TopicLink doother_topic.reloadreflection_link = other_topic.topic_links.first- expect(reflection_link.url.length).to be > (TopicLink.max_url_length)+ expect(reflection_link.url.length).to be > TopicLink.max_url_lengthexpect(reflection_link.url).to eq(topic_url)endenddiff --git a/spec/models/username_validator_spec.rb b/spec/models/username_validator_spec.rbindex a303715755f..3eac987df60 100644--- a/spec/models/username_validator_spec.rb+++ b/spec/models/username_validator_spec.rb@@ -179,9 +179,9 @@ RSpec.describe UsernameValidator doSiteSetting.max_username_length = max_username_lengthexpect_valid(- "Д" * (max_username_length),- "س" * (max_username_length),- "மி" * (max_username_length),+ "Д" * max_username_length,+ "س" * max_username_length,+ "மி" * max_username_length,failure_reason: "Should be valid as usernames are <= #{max_username_length}",)enddiff --git a/spec/requests/admin/site_texts_controller_spec.rb b/spec/requests/admin/site_texts_controller_spec.rbindex cc43947c488..97b182c7529 100644--- a/spec/requests/admin/site_texts_controller_spec.rb+++ b/spec/requests/admin/site_texts_controller_spec.rb@@ -331,7 +331,7 @@ RSpec.describe Admin::SiteTextsController doget "/admin/customize/site_texts.json", params: { q: "confirm_old_email", locale: }expect(response.status).to eq(200)returned_ids = response.parsed_body["site_texts"].map { |t| t["id"] }- expect((returned_ids & Admin::SiteTextsController::RESTRICTED_KEYS.to_a)).to be_empty+ expect(returned_ids & Admin::SiteTextsController::RESTRICTED_KEYS.to_a).to be_emptyget "/admin/customize/site_texts.json", params: { q: "powered_by", locale: }expect(response.status).to eq(200)diff --git a/spec/services/group_message_spec.rb b/spec/services/group_message_spec.rbindex 76a4011ddb8..37dbf27f14b 100644--- a/spec/services/group_message_spec.rb+++ b/spec/services/group_message_spec.rb@@ -19,9 +19,9 @@ RSpec.describe GroupMessage doPostCreator.expects(:create).with do |from_user, opts|- from_user.id == (admin.id) && opts[:target_group_names] &&+ from_user.id == admin.id && opts[:target_group_names] &&opts[:target_group_names].include?(Group[:moderators].name) &&- opts[:archetype] == (Archetype.private_message) && opts[:title].present? &&+ opts[:archetype] == Archetype.private_message && opts[:title].present? &&opts[:raw].present?end.returns(stub_everything)