Skip to content

A platform for community discussion. Free, open, simple.

DEV: Enable Style/RedundantParentheses rubocop rule (#40095)

Jarek Radosz09d07fc41847
diff --git a/.rubocop.yml b/.rubocop.yml
index ef498f87d2b..a02a3da8b1b 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -62,3 +62,6 @@ Lint/IdentityComparison:
Lint/SymbolConversion:
Enabled: true
+
+Style/RedundantParentheses:
+ Enabled: true
diff --git a/app/controllers/admin/embedding_controller.rb b/app/controllers/admin/embedding_controller.rb
index 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::AdminController
end
def 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.rb
index 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::AdminController
category_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_name
end,
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.rb
index 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::StaffController
args[:current_user] = current_user
report = 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::StaffController
else
report = Report.find(report_type, args)
- Report.cache(report) if (report_params[:cache]) && report
+ Report.cache(report) if report_params[:cache] && report
if report.blank?
report = Report._get(report_type, args)
@@ -55,7 +55,7 @@ class Admin::ReportsController < Admin::StaffController
args[:current_user] = current_user
report = 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::StaffController
raise Discourse::NotFound if report.blank?
- Report.cache(report) if (params[:cache])
+ Report.cache(report) if params[:cache]
render_json_dump(report: report)
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e73059f906b..f35e13efc6b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -304,8 +304,8 @@ class ApplicationController < ActionController::Base
opts ||= {}
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::Base
def 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::Base
def 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::Base
end
def add_noindex_header_to_non_canonical
- canonical = (@canonical_url || @default_canonical)
+ canonical = @canonical_url || @default_canonical
if canonical.present? && canonical != request.url &&
!SiteSetting.allow_indexing_non_canonical_urls
response.headers["X-Robots-Tag"] ||= "noindex"
diff --git a/app/controllers/edit_directory_columns_controller.rb b/app/controllers/edit_directory_columns_controller.rb
index 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 < ApplicationController
directory_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_i
new_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.rb
index 6ba212b7d5d..f20f6de49a4 100644
--- a/app/controllers/export_csv_controller.rb
+++ b/app/controllers/export_csv_controller.rb
@@ -23,7 +23,7 @@ class ExportCsvController < ApplicationController
unless 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 == 0
render_json_error I18n.t("csv_export.rate_limit_error")
return
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index c7d9945718c..8d7ac528dd9 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -687,7 +687,7 @@ class GroupsController < ApplicationController
def search
include_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.rb
index a697f4d7402..362715ab2aa 100644
--- a/app/controllers/session_controller.rb
+++ b/app/controllers/session_controller.rb
@@ -288,7 +288,7 @@ class SessionController < ApplicationController
text = 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")
else
diff --git a/app/controllers/svg_sprite_controller.rb b/app/controllers/svg_sprite_controller.rb
index 1db07800ef0..ddb0db28e08 100644
--- a/app/controllers/svg_sprite_controller.rb
+++ b/app/controllers/svg_sprite_controller.rb
@@ -19,7 +19,7 @@ class SvgSpriteController < ApplicationController
theme_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: true
end
svg_sprite = "window.__svg_sprite = #{SvgSprite.bundle(theme_id).inspect};"
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 9164c890979..748e1dc9736 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -218,7 +218,7 @@ class TagsController < ::ApplicationController
canonical_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.rb
index 4207af192fe..56c3771000d 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -1204,7 +1204,7 @@ class TopicsController < ApplicationController
def reset_new
topic_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 < ApplicationController
helpers.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.summary
store_preloaded("topic_#{@topic_view.topic.id}", MultiJson.dump(topic_view_serializer))
render :show
end
diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb
index 0c1a9f54dd6..1759fa71d95 100644
--- a/app/controllers/uploads_controller.rb
+++ b/app/controllers/uploads_controller.rb
@@ -95,7 +95,7 @@ class UploadsController < ApplicationController
params.permit(short_urls: [])
uploads = []
- if (params[:short_urls] && params[:short_urls].length > 0)
+ if params[:short_urls] && params[:short_urls].length > 0
PrettyText::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.rb
index d0da1a3ff53..338a3f643d0 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -607,7 +607,7 @@ class UsersController < ApplicationController
end
def changing_case_of_own_username(target_user, username)
- target_user && username.downcase == (target_user.username.downcase)
+ target_user && username.downcase == target_user.username.downcase
end
# Used for checking availability of a username and will return suggestions
diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb
index 0b13d9a6d0a..f86349fbaae 100644
--- a/app/controllers/webhooks_controller.rb
+++ b/app/controllers/webhooks_controller.rb
@@ -27,7 +27,7 @@ class WebhooksController < ActionController::Base
events = 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.rb
index 83bcddeb97b..c49e29925b0 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -398,7 +398,7 @@ module ApplicationHelper
end
private 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/markup
if img_url.ends_with?(".svg")
@@ -950,7 +950,7 @@ module ApplicationHelper
cookie = cookies[:forced_color_mode]
return cookie == "light" if cookie.present?
- !!(current_user&.user_option&.light_mode_forced?)
+ !!current_user&.user_option&.light_mode_forced?
end
def forced_dark_mode?
@@ -959,7 +959,7 @@ module ApplicationHelper
cookie = cookies[:forced_color_mode]
return cookie == "dark" if cookie.present?
- !!(current_user&.user_option&.dark_mode_forced?)
+ !!current_user&.user_option&.dark_mode_forced?
end
def light_color_hex_for_name(name)
diff --git a/app/helpers/embed_helper.rb b/app/helpers/embed_helper.rb
index bcd8e8c3587..52ef5887652 100644
--- a/app/helpers/embed_helper.rb
+++ b/app/helpers/embed_helper.rb
@@ -21,7 +21,7 @@ module EmbedHelper
def 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).humanize
raw PrettyText.format_for_email(cooked, post)
end
diff --git a/app/jobs/concerns/skippable.rb b/app/jobs/concerns/skippable.rb
index bb2e0bd2c24..e1ec0ddafd8 100644
--- a/app/jobs/concerns/skippable.rb
+++ b/app/jobs/concerns/skippable.rb
@@ -15,7 +15,7 @@ module Skippable
if 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 exists
diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb
index 3dacea427a9..d97d4f73019 100644
--- a/app/jobs/regular/user_email.rb
+++ b/app/jobs/regular/user_email.rb
@@ -160,7 +160,7 @@ module Jobs
email_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])
end
diff --git a/app/jobs/scheduled/aggregate_web_hooks_events.rb b/app/jobs/scheduled/aggregate_web_hooks_events.rb
index 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 Jobs
every 1.day
def execute(args = {})
- date = (args[:date].presence || Time.zone.now.to_date)
+ date = args[:date].presence || Time.zone.now.to_date
WebHook
.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.rb
index 4c1808ade45..5ca9e7baa10 100644
--- a/app/jobs/scheduled/call_discourse_hub.rb
+++ b/app/jobs/scheduled/call_discourse_hub.rb
@@ -6,7 +6,7 @@ module Jobs
def 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)
begin
prev_missing_versions_count = DiscourseUpdates.missing_versions_count || 0
@@ -18,8 +18,8 @@ module Jobs
DiscourseUpdates.updated_at = Time.zone.now
DiscourseUpdates.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_i
message = VersionMailer.send_notice
Email::Sender.new(message, :new_version).send
end
diff --git a/app/jobs/scheduled/periodical_updates.rb b/app/jobs/scheduled/periodical_updates.rb
index 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_i
last_new_topic = Topic.order("created_at desc").offset(offset).select(:created_at).first
SiteSetting.min_new_topics_time = last_new_topic.created_at.to_i if last_new_topic
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index 43bf6d68730..6afc47a5a1a 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -78,7 +78,7 @@ class UserNotifications < ActionMailer::Base
template: "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::Base
else
reached_limit = SiteSetting.max_emails_per_day_per_user > 0
reached_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_to
diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb
index 50222713526..3abbb44f78a 100644
--- a/app/models/api_key_scope.rb
+++ b/app/models/api_key_scope.rb
@@ -314,10 +314,8 @@ class ApiKeyScope < ActiveRecord::Base
action = "#{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.rb
index fb4445cc39b..0b8eae747b5 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -983,14 +983,14 @@ class Category < ActiveRecord::Base
def 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)
end
def 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).first
end
@@ -1001,7 +1001,7 @@ class Category < ActiveRecord::Base
def 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?
end
def uncategorized?
diff --git a/app/models/concerns/positionable.rb b/app/models/concerns/positionable.rb
index 66b854f97be..da31d48838d 100644
--- a/app/models/concerns/positionable.rb
+++ b/app/models/concerns/positionable.rb
@@ -8,7 +8,7 @@ module Positionable
def 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.position
DB.exec "
UPDATE #{self.class.table_name}
SET position = position - 1
diff --git a/app/models/emoji.rb b/app/models/emoji.rb
index 807e08a8337..5ae30220ac4 100644
--- a/app/models/emoji.rb
+++ b/app/models/emoji.rb
@@ -373,7 +373,7 @@ class Emoji
codepoints = code.codepoints
codepoints.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_code
end
end
diff --git a/app/models/group.rb b/app/models/group.rb
index 7d3357854be..1146e1659ca 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1065,7 +1065,7 @@ class Group < ActiveRecord::Base
domains =
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)
end
max_domains = SiteSetting.max_automatic_membership_email_domains
diff --git a/app/models/incoming_link.rb b/app/models/incoming_link.rb
index 0212cd79b4f..feb47e2e906 100644
--- a/app/models/incoming_link.rb
+++ b/app/models/incoming_link.rb
@@ -39,7 +39,7 @@ class IncomingLink < ActiveRecord::Base
post_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 : nil
ip_address = nil if cid
unless cid && cid == user_id
diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rb
index 4cc7de68d5e..28a3b017b1e 100644
--- a/app/models/optimized_image.rb
+++ b/app/models/optimized_image.rb
@@ -37,7 +37,7 @@ class OptimizedImage < ActiveRecord::Base
return 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.extension
if !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_path
extension = File.extname(path)[1..-1]
else
extension = File.extname(opts[:filename] || ext_path || path)[1..-1]
diff --git a/app/models/post.rb b/app/models/post.rb
index 5a039627dd6..22cf285253d 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -282,7 +282,7 @@ class Post < ActiveRecord::Base
def 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 != id
end
def raw_hash
diff --git a/app/models/report.rb b/app/models/report.rb
index 4f38f290e04..3b1a65095a6 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -411,7 +411,7 @@ class Report
report.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,
)
end
diff --git a/app/models/reviewable_flagged_post.rb b/app/models/reviewable_flagged_post.rb
index a24adfc9faf..a1ce92e0eff 100644
--- a/app/models/reviewable_flagged_post.rb
+++ b/app/models/reviewable_flagged_post.rb
@@ -41,7 +41,7 @@ class ReviewableFlaggedPost < Reviewable
end
def post
- @post ||= (target || Post.with_deleted.find_by(id: target_id))
+ @post ||= target || Post.with_deleted.find_by(id: target_id)
end
def build_actions(actions, guardian, args)
diff --git a/app/models/reviewable_post.rb b/app/models/reviewable_post.rb
index 8e46077b02f..2ed8b525893 100644
--- a/app/models/reviewable_post.rb
+++ b/app/models/reviewable_post.rb
@@ -127,7 +127,7 @@ class ReviewablePost < Reviewable
private
def post
- @post ||= (target || Post.with_deleted.find_by(id: target_id))
+ @post ||= target || Post.with_deleted.find_by(id: target_id)
end
end
diff --git a/app/models/screened_email.rb b/app/models/screened_email.rb
index 9a09bd8ee07..b1c8ad7f42e 100644
--- a/app/models/screened_email.rb
+++ b/app/models/screened_email.rb
@@ -53,7 +53,7 @@ class ScreenedEmail < ActiveRecord::Base
def 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.rb
index 6776a00bec8..5b625ce27b5 100644
--- a/app/models/sidebar_section_link.rb
+++ b/app/models/sidebar_section_link.rb
@@ -28,7 +28,7 @@ class SidebarSectionLink < ActiveRecord::Base
end
def 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.rb
index bf26083820f..bf6b2c2ef62 100644
--- a/app/models/theme.rb
+++ b/app/models/theme.rb
@@ -454,7 +454,7 @@ class Theme < ActiveRecord::Base
return "" 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_nonce
resolved.html_safe
end
diff --git a/app/models/topic.rb b/app/models/topic.rb
index f232268f45e..d5b143e08b0 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -196,7 +196,7 @@ class Topic < ActiveRecord::Base
max_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::Base
post = self.ordered_posts.first
html = post.cooked
- if (guardian && ContentLocalization.show_translated_post?(post, guardian))
+ if guardian && ContentLocalization.show_translated_post?(post, guardian)
html = post.get_localization&.cooked.presence || html
end
@@ -1716,7 +1716,7 @@ class Topic < ActiveRecord::Base
elsif topic_timer.status_type == TopicTimer.types[:delete_replies]
if duration_minutes > 0
first_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_now
topic_timer.duration_minutes = duration_minutes
topic_timer.execute_at = first_reply_created_at + duration_minutes.minutes
topic_timer.created_at = first_reply_created_at
diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb
index 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 form
node[url_param] = URI.join(url, UrlHelper.normalized_encode(src)).to_s
diff --git a/app/models/topic_list.rb b/app/models/topic_list.rb
index bbb9d58d88c..cc810d51b85 100644
--- a/app/models/topic_list.rb
+++ b/app/models/topic_list.rb
@@ -106,7 +106,7 @@ class TopicList
group_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 || []
end
user_ids = TopicList.preload_user_ids(@topics, user_ids, self)
diff --git a/app/models/topic_timer.rb b/app/models/topic_timer.rb
index 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?
end
diff --git a/app/models/topic_tracking_state.rb b/app/models/topic_tracking_state.rb
index b224b74f063..b2f5f6664bf 100644
--- a/app/models/topic_tracking_state.rb
+++ b/app/models/topic_tracking_state.rb
@@ -581,8 +581,8 @@ class TopicTrackingState
groups.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 && !member
next if non_member_reading || member_writing
groups_to_update << group
diff --git a/app/models/trust_level3_requirements.rb b/app/models/trust_level3_requirements.rb
index 54370441a0e..1e2ab4e7927 100644
--- a/app/models/trust_level3_requirements.rb
+++ b/app/models/trust_level3_requirements.rb
@@ -33,7 +33,7 @@ class TrustLevel3Requirements
def 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.rb
index 2100367cc4f..60c5c2ebd44 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -155,7 +155,7 @@ class Upload < ActiveRecord::Base
def get_optimized_image(width, height, opts = nil)
opts ||= {}
- fix_image_extension if (!extension || extension.length == 0)
+ fix_image_extension if !extension || extension.length == 0
opts = opts.merge(raise_on_error: true)
begin
diff --git a/app/models/user.rb b/app/models/user.rb
index 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 true
end
@@ -873,7 +870,7 @@ class User < ActiveRecord::Base
notification = notifications.visible.order("notifications.created_at desc").first
json = NotificationSerializer.new(notification).as_json if notification
- sql = (<<~SQL)
+ sql = <<~SQL
SELECT * FROM (
SELECT n.id, n.read FROM notifications n
LEFT JOIN topics t ON n.topic_id = t.id
diff --git a/app/models/user_archived_message.rb b/app/models/user_archived_message.rb
index ae909608257..f47bccf4432 100644
--- a/app/models/user_archived_message.rb
+++ b/app/models/user_archived_message.rb
@@ -7,13 +7,11 @@ class UserArchivedMessage < ActiveRecord::Base
def 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?
return
end
diff --git a/app/models/user_auth_token.rb b/app/models/user_auth_token.rb
index 3c5285a8a01..d77e400224d 100644
--- a/app/models/user_auth_token.rb
+++ b/app/models/user_auth_token.rb
@@ -240,8 +240,8 @@ class UserAuthToken < ActiveRecord::Base
end
def 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_ip
token = SecureRandom.hex(16)
diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb
index 8ee06a3e3d1..69081db6fde 100644
--- a/app/models/user_profile.rb
+++ b/app/models/user_profile.rb
@@ -133,7 +133,7 @@ class UserProfile < ActiveRecord::Base
type: type,
).create_for(user.id)
- if (is_card_background)
+ if is_card_background
user.user_profile.upload_card_background(upload)
else
user.user_profile.upload_profile_background(upload)
@@ -194,7 +194,7 @@ class UserProfile < ActiveRecord::Base
def website_domain_validator
allowed_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::Base
end
if 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(", "),
)
end
end
diff --git a/app/serializers/category_badge_serializer.rb b/app/serializers/category_badge_serializer.rb
index 69fa095653f..84168d42883 100644
--- a/app/serializers/category_badge_serializer.rb
+++ b/app/serializers/category_badge_serializer.rb
@@ -20,7 +20,7 @@ class CategoryBadgeSerializer < ApplicationSerializer
return 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&.name
else
object.name
diff --git a/app/serializers/category_detailed_serializer.rb b/app/serializers/category_detailed_serializer.rb
index 39197008e2b..1674e9ff302 100644
--- a/app/serializers/category_detailed_serializer.rb
+++ b/app/serializers/category_detailed_serializer.rb
@@ -57,7 +57,7 @@ class CategoryDetailedSerializer < BasicCategorySerializer
def 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 }
count
end
diff --git a/app/serializers/detailed_user_badge_serializer.rb b/app/serializers/detailed_user_badge_serializer.rb
index 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 < BasicUserBadgeSerializer
end
def 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)
end
end
diff --git a/app/serializers/listable_topic_serializer.rb b/app/serializers/listable_topic_serializer.rb
index 9e1db59ea51..7b67b4ecaa3 100644
--- a/app/serializers/listable_topic_serializer.rb
+++ b/app/serializers/listable_topic_serializer.rb
@@ -113,7 +113,7 @@ class ListableTopicSerializer < BasicTopicSerializer
def excerpt
e = object.excerpt
- if (ContentLocalization.show_translated_topic?(object, scope))
+ if ContentLocalization.show_translated_topic?(object, scope)
object.get_localization&.excerpt.presence || e
else
e
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index d24bde7a61a..011f54523ea 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -160,15 +160,15 @@ class PostSerializer < BasicPostSerializer
end
def moderator?
- !!(object&.user&.moderator?)
+ !!object&.user&.moderator?
end
def admin?
- !!(object&.user&.admin?)
+ !!object&.user&.admin?
end
def staff?
- !!(object&.user&.staff?)
+ !!object&.user&.staff?
end
def group_moderator
@@ -741,7 +741,7 @@ class PostSerializer < BasicPostSerializer
end
def user_custom_fields_object
- (@topic_view&.user_custom_fields || @options[:user_custom_fields] || {})
+ @topic_view&.user_custom_fields || @options[:user_custom_fields] || {}
end
def topic
diff --git a/app/serializers/site_category_serializer.rb b/app/serializers/site_category_serializer.rb
index beb9c0cb386..b9ed6e093b2 100644
--- a/app/serializers/site_category_serializer.rb
+++ b/app/serializers/site_category_serializer.rb
@@ -41,7 +41,7 @@ class SiteCategorySerializer < BasicCategorySerializer
return 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&.name
else
object.name
diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb
index 7b3c35b182f..b99384c0d27 100644
--- a/app/services/inline_uploads.rb
+++ b/app/services/inline_uploads.rb
@@ -23,8 +23,8 @@ class InlineUploads
if node.name == "img"
# Do nothing
elsif !(
- 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 InlineUploads
end
if 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], +"![](#{PLACEHOLDER})", $~.offset(0)[0])
end
end
diff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rb
index c1dad02d62f..6e7c8b39aa7 100644
--- a/app/services/push_notification_pusher.rb
+++ b/app/services/push_notification_pusher.rb
@@ -143,7 +143,7 @@ class PushNotificationPusher
p256dh = 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!
return
end
diff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rb
index 3ce8c50b8e9..b721b784919 100644
--- a/app/services/themes_install_task.rb
+++ b/app/services/themes_install_task.rb
@@ -80,7 +80,7 @@ class ThemesInstallTask
end
def 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.rb
index 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_all
end
diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb
index 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)) != 0
StaffActionLogger.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.rb
index 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_f
raise RateLimiter::LimitExceeded, 30 + (rand * 120).to_i
end
end
diff --git a/config/initializers/008-rack-cors.rb b/config/initializers/008-rack-cors.rb
index bfd8422da9d..857a82d56c6 100644
--- a/config/initializers/008-rack-cors.rb
+++ b/config/initializers/008-rack-cors.rb
@@ -17,7 +17,7 @@ class Discourse::Cors
cors_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, {}), []
end
diff --git a/config/initializers/100-logster.rb b/config/initializers/100-logster.rb
index c7360abe673..8147a281753 100644
--- a/config/initializers/100-logster.rb
+++ b/config/initializers/100-logster.rb
@@ -7,7 +7,7 @@ if GlobalSetting.skip_redis?
return
end
-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)
return
end
diff --git a/config/initializers/100-session_store.rb b/config/initializers/100-session_store.rb
index 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?
"/"
else
Rails.application.config.relative_url_root
diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rb
index 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_header
end
- 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] * 1000
output[:db_calls] = sql[:calls]
diff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rb
index 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.rb
index 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))
- )
:many
else
: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)
)
- )
:few
else
: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)
)
- )
:one
else
: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)
)
- )
:one
else
: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)
- )
:few
else
: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)
- )
:many
else
: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)
)
- )
:one
else
: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)
- )
:many
else
: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))
:few
else
: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
:many
else
: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)
)
- )
:few
else
: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)
- )
:few
else
: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
- )
:one
else
: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)
- )
:many
else
: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
)
- )
:one
else
: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
)
- )
:one
else
: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)
)
- )
:many
else
: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)
- )
:many
else
: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)
- )
:many
else
: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))
- )
:few
else
: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)
)
- )
:many
else
: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)
- )
:one
else
: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
- )
:few
else
: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)
)
- )
:few
else
: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))
- )
:one
else
: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)
)
- )
:many
else
:other
diff --git a/config/pitchfork.conf.rb b/config/pitchfork.conf.rb
index 675a0c6eb52..26d953a1182 100644
--- a/config/pitchfork.conf.rb
+++ b/config/pitchfork.conf.rb
@@ -29,7 +29,7 @@ end
worker_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: true
if ENV["RAILS_ENV"] == "production"
# nuke workers after 30 seconds instead of 20 seconds (the default)
diff --git a/config/routes.rb b/config/routes.rb
index 1310d3e8ec8..94bf9621dcc 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -14,10 +14,7 @@ Discourse::Application.routes.draw do
scope path: nil, constraints: { format: %r{(json|html|\*/\*)} } do
relative_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_root
Rails.configuration.relative_url_root + "/"
else
"/"
diff --git a/db/migrate/20121204183855_fix_link_post_id.rb b/db/migrate/20121204183855_fix_link_post_id.rb
index 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?
end
rescue ActionController::RoutingError
diff --git a/db/migrate/20130625170842_remove_access_password.rb b/db/migrate/20130625170842_remove_access_password.rb
index 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 > 0
execute "DELETE FROM site_settings where name='access_password'"
SiteSetting.login_required = true
SiteSetting.must_approve_users = true
diff --git a/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb b/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb
index 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 > 0
execute "UPDATE categories SET show_subcategory_list = true WHERE parent_category_id IS NULL"
end
end
diff --git a/lib/auth/default_current_user_provider.rb b/lib/auth/default_current_user_provider.rb
index 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 detected
def is_api?
current_user
- !!(@env[API_KEY_ENV])
+ !!@env[API_KEY_ENV]
end
def is_user_api?
current_user
- !!(@env[USER_API_KEY_ENV])
+ !!@env[USER_API_KEY_ENV]
end
def has_auth_cookie?
diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb
index e9e1481eafa..435939f83fb 100644
--- a/lib/composer_messages_finder.rb
+++ b/lib/composer_messages_finder.rb
@@ -191,7 +191,7 @@ class ComposerMessagesFinder
private
def 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])
end
diff --git a/lib/cooked_processor_mixin.rb b/lib/cooked_processor_mixin.rb
index 8db836d9520..646887a95a7 100644
--- a/lib/cooked_processor_mixin.rb
+++ b/lib/cooked_processor_mixin.rb
@@ -429,7 +429,7 @@ module CookedProcessorMixin
original_width, original_height = nil
- if (upload.present?)
+ if upload.present?
original_width = upload.width || 0
original_height = upload.height || 0
else
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 908cf05554c..e5c35535256 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -944,7 +944,7 @@ module Discourse
User.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).first
end
SYSTEM_USER_ID = -1
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb
index eef09a8179b..6dc9c004e1b 100644
--- a/lib/email/receiver.rb
+++ b/lib/email/receiver.rb
@@ -963,7 +963,7 @@ module Email
end
target_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_enabled
if target_post.blank? || too_old_for_group_smtp
create_topic(
diff --git a/lib/email/styles.rb b/lib/email/styles.rb
index 89f34680ac3..b8dab999fb9 100644
--- a/lib/email/styles.rb
+++ b/lib/email/styles.rb
@@ -77,7 +77,7 @@ module Email
img["width"] = img["height"] = 20
else
# 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 > 480
img["width"] = img["height"] = "auto"
end
end
@@ -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 == 0
bg_color = SiteSetting.email_accent_bg_color
inner[
"style"
diff --git a/lib/freedom_patches/request_server_session.rb b/lib/freedom_patches/request_server_session.rb
index 6a850279027..c153f4e2b15 100644
--- a/lib/freedom_patches/request_server_session.rb
+++ b/lib/freedom_patches/request_server_session.rb
@@ -2,7 +2,7 @@
module RequestServerSession
def server_session
- session[:server_session_id] ||= (session.delete(:secure_session_id) || SecureRandom.hex)
+ session[:server_session_id] ||= session.delete(:secure_session_id) || SecureRandom.hex
ServerSession.new(session[:server_session_id])
end
end
diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb
index 46341122fa3..329970c9932 100644
--- a/lib/guardian/post_guardian.rb
+++ b/lib/guardian/post_guardian.rb
@@ -35,7 +35,7 @@ module PostGuardian
taken = opts[:taken_actions].try(:keys).to_a
post_action_type_view = opts[:post_action_type_view] || PostActionTypeView.new
is_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]
else
post_action_type_view.notify_flag_types[action_key] ||
@@ -63,7 +63,7 @@ module PostGuardian
return 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 PostGuardian
return 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 true
end
@@ -236,10 +234,7 @@ module PostGuardian
# You can delete your own posts
if 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 < 1
return false
end
return true if !post.user_deleted?
@@ -264,14 +259,11 @@ module PostGuardian
return 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_id
return true if can_moderate_topic?(topic) && !!post.deleted_at
if 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 < 1
return false
end
return true if post.user_deleted && !post.deleted_at
diff --git a/lib/guardian/topic_guardian.rb b/lib/guardian/topic_guardian.rb
index cbc186a792d..c761a5a3ad0 100644
--- a/lib/guardian/topic_guardian.rb
+++ b/lib/guardian/topic_guardian.rb
@@ -4,7 +4,7 @@
module TopicGuardian
def 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))
end
def 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_id
return 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 true
end
- 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 true
end
- 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 true
end
diff --git a/lib/new_post_manager.rb b/lib/new_post_manager.rb
index bf66211908f..2093bdf3e67 100644
--- a/lib/new_post_manager.rb
+++ b/lib/new_post_manager.rb
@@ -88,10 +88,8 @@ class NewPostManager
return :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_count
return :post_count
end
@@ -99,10 +97,8 @@ class NewPostManager
return :group
end
- 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_groups
end
@@ -118,10 +114,8 @@ class NewPostManager
return :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_media
end
@@ -209,13 +203,9 @@ class NewPostManager
def 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 > 1
end
diff --git a/lib/onebox/engine/allowlisted_generic_onebox.rb b/lib/onebox/engine/allowlisted_generic_onebox.rb
index b2cdc04783c..622ac8d74ea 100644
--- a/lib/onebox/engine/allowlisted_generic_onebox.rb
+++ b/lib/onebox/engine/allowlisted_generic_onebox.rb
@@ -73,9 +73,9 @@ module Onebox
end
def 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_html
end
@@ -184,13 +184,13 @@ module Onebox
end
def 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?
end
def is_card?
diff --git a/lib/onebox/engine/amazon_onebox.rb b/lib/onebox/engine/amazon_onebox.rb
index 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&.strip
end
)
rating =
diff --git a/lib/onebox/engine/pubmed_onebox.rb b/lib/onebox/engine/pubmed_onebox.rb
index 79139d194db..d9d001a5f2a 100644
--- a/lib/onebox/engine/pubmed_onebox.rb
+++ b/lib/onebox/engine/pubmed_onebox.rb
@@ -24,7 +24,7 @@ module Onebox
def authors
initials = 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 > 1
author_list[-2] = author_list[-2] + " and " + author_list[-1]
author_list.pop
diff --git a/lib/onebox/engine/standard_embed.rb b/lib/onebox/engine/standard_embed.rb
index ea6516cebb8..55ef89c26e7 100644
--- a/lib/onebox/engine/standard_embed.rb
+++ b/lib/onebox/engine/standard_embed.rb
@@ -86,7 +86,7 @@ module Onebox
if (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"
end
end
diff --git a/lib/onebox/engine/wikipedia_onebox.rb b/lib/onebox/engine/wikipedia_onebox.rb
index 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 tag
cur_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 showing
first_p_found = true
paras.push(cur_element)
end
diff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rb
index 453f94fe7ab..de7b77e9d11 100644
--- a/lib/onebox/helpers.rb
+++ b/lib/onebox/helpers.rb
@@ -169,7 +169,7 @@ module Onebox
scale = 1024
ndx = 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.rb
index 044b2ecf3ba..aa6c0ed879d 100644
--- a/lib/post_creator.rb
+++ b/lib/post_creator.rb
@@ -69,10 +69,8 @@ class PostCreator
opts[: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 PostCreator
end
if !opts[:import_mode] && !opts[:reviewed_queued_post]
- handle_spam if (@spam || @post)
+ handle_spam if @spam || @post
ReviewablePost.queue_for_review_if_possible(@post, @user) if !@spam && @post && errors.blank?
end
diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb
index 5bb5aea7a8c..d3d980d0b96 100644
--- a/lib/post_revisor.rb
+++ b/lib/post_revisor.rb
@@ -346,23 +346,19 @@ class PostRevisor
return 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).lock
end
# We log staff/group moderator edits to posts
if (
- (
- @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)
end
diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb
index d9ce78619b1..54fe655f738 100644
--- a/lib/pretty_text.rb
+++ b/lib/pretty_text.rb
@@ -259,7 +259,7 @@ module PrettyText
buffer << "__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] == false
opts = context.eval(buffer)
diff --git a/lib/pretty_text/helpers.rb b/lib/pretty_text/helpers.rb
index 64c31ec1d71..d5ecfd10a35 100644
--- a/lib/pretty_text/helpers.rb
+++ b/lib/pretty_text/helpers.rb
@@ -44,7 +44,7 @@ module PrettyText
urls.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 thumbnail
thumbnail = Upload.where("original_filename LIKE ?", "#{sha1}.%").last if sha1
# Fallback for old posts that don't contain data-video-base62-sha1
thumbnail = Upload.where("original_filename LIKE ?", "#{url}.%").last if thumbnail.nil? &&
diff --git a/lib/scheduler/defer.rb b/lib/scheduler/defer.rb
index 6d088241bf4..8cf296cace8 100644
--- a/lib/scheduler/defer.rb
+++ b/lib/scheduler/defer.rb
@@ -113,7 +113,7 @@ module Scheduler
@thread =
Thread.new do
Thread.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?
end
end
diff --git a/lib/search.rb b/lib/search.rb
index 1e20e4ff7af..e1fc09406e3 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -206,7 +206,7 @@ class Search
return 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 - idx
delta += 12 if delta < 0
Time.zone.now.beginning_of_month.months_ago(delta)
@@ -677,7 +677,7 @@ class Search
# try a possible tag match
tag_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_id
posts.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.rb
index 69a08f5ac1c..03830d37712 100644
--- a/lib/search/grouped_search_results.rb
+++ b/lib/search/grouped_search_results.rb
@@ -114,7 +114,7 @@ class Search
elsif @is_header_search && public_send(type).length == Search.per_facet
instance_variable_set(:"@more_#{type}", true)
else
- (self.public_send(type)) << object
+ self.public_send(type) << object
end
if can_lazy_load_categories
diff --git a/lib/site_settings/defaults_provider.rb b/lib/site_settings/defaults_provider.rb
index c10d5615938..484e1b00f88 100644
--- a/lib/site_settings/defaults_provider.rb
+++ b/lib/site_settings/defaults_provider.rb
@@ -18,7 +18,7 @@ class SiteSettings::DefaultsProvider
name = name_arg.to_sym
@defaults[DEFAULT_LOCALE.to_sym][name] = value
- if (locale_defaults)
+ if locale_defaults
locale_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.rb
index 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::TypeSupervisor
def 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 type
when self.class.types[:float]
value.to_f
diff --git a/lib/stylesheet/importer.rb b/lib/stylesheet/importer.rb
index a1c6fd3b761..249674595db 100644
--- a/lib/stylesheet/importer.rb
+++ b/lib/stylesheet/importer.rb
@@ -164,7 +164,7 @@ module Stylesheet
rescue StandardError
ColorScheme.base_colors
end
- elsif (@theme_id && !theme.component)
+ elsif @theme_id && !theme.component
colors = theme&.color_scheme&.resolved_colors || ColorScheme.base_colors
else
# this is a slightly ugly backwards compatibility fix,
diff --git a/lib/tasks/admin.rake b/lib/tasks/admin.rake
index a5fa3266af6..874a1473d27 100644
--- a/lib/tasks/admin.rake
+++ b/lib/tasks/admin.rake
@@ -51,7 +51,7 @@ task "admin:create" => :environment do
ask(
"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"
begin
password = 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 privileges
grant_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 < 1
admin.email_tokens.update_all confirmed: true
diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake
index 3d0d7c9d6ed..80121b37dd0 100644
--- a/lib/tasks/db.rake
+++ b/lib/tasks/db.rake
@@ -5,7 +5,7 @@ task "set_locale" do
begin
I18n.locale =
begin
- (SiteSetting.default_locale || :en)
+ SiteSetting.default_locale || :en
rescue StandardError
:en
end
@@ -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 = false
RailsMultisite::ConnectionManagement.each_connection do |db_name|
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index 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"].invoke
else
puts "You can run `bin/rails dev:reset` to repopulate anytime."
diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake
index 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 |_, a
ask(
"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"
end
puts "Remapping"
@@ -318,7 +318,7 @@ task "posts:delete_word", %i[find type ignore_case] => [:environment] do |_, arg
else
confirm_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"
end
puts "Processing"
diff --git a/lib/tasks/site_settings.rake b/lib/tasks/site_settings.rake
index f3547948bee..78c8901d375 100644
--- a/lib/tasks/site_settings.rake
+++ b/lib/tasks/site_settings.rake
@@ -10,7 +10,7 @@ end
desc "Imports site settings"
task "site_settings:import" => :environment do
- yml = (STDIN.tty?) ? "" : STDIN.read
+ yml = STDIN.tty? ? "" : STDIN.read
if yml == ""
puts
puts "Please specify a settings yml file"
diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake
index 3aca548f30d..4adbd81cee9 100644
--- a/lib/tasks/themes.rake
+++ b/lib/tasks/themes.rake
@@ -249,7 +249,7 @@ end
desc "Install themes & theme components"
task "themes:install" => :environment do |task, args|
- theme_args = (STDIN.tty?) ? "" : STDIN.read
+ theme_args = STDIN.tty? ? "" : STDIN.read
use_json = theme_args == ""
theme_args =
diff --git a/lib/tasks/typepad.thor b/lib/tasks/typepad.thor
index 87312d47c57..fba9ae1d8bb 100644
--- a/lib/tasks/typepad.thor
+++ b/lib/tasks/typepad.thor
@@ -216,7 +216,7 @@ class Typepad < Thor
comment[: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_upper
segments << current
current = ""
end
diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 83b171f6d1a..275790a6218 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -227,8 +227,8 @@ def clean_up_uploads
sha1 = 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 "#"
else
diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake
index 6d6a991185c..0b438d19b9a 100644
--- a/lib/tasks/users.rake
+++ b/lib/tasks/users.rake
@@ -174,7 +174,7 @@ task "users:anonymize_all" => :environment do
anonymized = 0
confirm_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_user
non_staff_users.each do |user|
diff --git a/lib/theme_settings_manager/bool.rb b/lib/theme_settings_manager/bool.rb
index b2b8c4c87ad..66a79265b65 100644
--- a/lib/theme_settings_manager/bool.rb
+++ b/lib/theme_settings_manager/bool.rb
@@ -10,7 +10,7 @@ class ThemeSettingsManager::Bool < ThemeSettingsManager
end
def value=(new_value)
- new_value = (self.class.cast(new_value)).to_s
+ new_value = self.class.cast(new_value).to_s
super(new_value)
end
end
diff --git a/lib/topic_creator.rb b/lib/topic_creator.rb
index 0a1b99040d0..18e01df7af2 100644
--- a/lib/topic_creator.rb
+++ b/lib/topic_creator.rb
@@ -172,7 +172,7 @@ class TopicCreator
topic_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)
end
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 7e9980a9207..9a2e32a23a6 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -846,7 +846,7 @@ class TopicQuery
result = result.references(:categories)
if !@options[:order]
- filter = (options[:filter] || options[:f])
+ filter = options[:filter] || options[:f]
# category default sort order
sort_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]) && @user
action = (PostActionType.types[:like] if filter == "liked")
if action
result =
@@ -1195,8 +1195,8 @@ class TopicQuery
end
def 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.rb
index a156e70b39a..5e7945e3a58 100644
--- a/lib/topic_retriever.rb
+++ b/lib/topic_retriever.rb
@@ -7,7 +7,7 @@ class TopicRetriever
end
def retrieve
- perform_retrieve unless (invalid_url? || retrieved_recently?)
+ perform_retrieve unless invalid_url? || retrieved_recently?
end
private
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rb
index 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_thumbnail
unique_hash
else
sha1
diff --git a/lib/upload_recovery.rb b/lib/upload_recovery.rb
index 34f9ffe6682..7f2c52d6e60 100644
--- a/lib/upload_recovery.rb
+++ b/lib/upload_recovery.rb
@@ -28,7 +28,7 @@ class UploadRecovery
else
recover_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 data
diff --git a/lib/user_comm_screener.rb b/lib/user_comm_screener.rb
index 4a4a59dcfde..e906e81d297 100644
--- a/lib/user_comm_screener.rb
+++ b/lib/user_comm_screener.rb
@@ -263,7 +263,7 @@ class UserCommScreener
end
disallowed_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
[]
end
diff --git a/lib/user_name_suggester.rb b/lib/user_name_suggester.rb
index d7fcd2c7071..1b341bfdbbf 100644
--- a/lib/user_name_suggester.rb
+++ b/lib/user_name_suggester.rb
@@ -40,7 +40,7 @@ module UserNameSuggester
original_allowed_username = current_username
current_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 > 100
if 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.rb
index 364538c62d0..b516b9ed563 100644
--- a/lib/validators/integer_setting_validator.rb
+++ b/lib/validators/integer_setting_validator.rb
@@ -12,8 +12,8 @@ class IntegerSettingValidator
def 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_i
true
end
diff --git a/lib/validators/string_setting_validator.rb b/lib/validators/string_setting_validator.rb
index 2b218b90d00..d4b78e80269 100644
--- a/lib/validators/string_setting_validator.rb
+++ b/lib/validators/string_setting_validator.rb
@@ -11,13 +11,13 @@ class StringSettingValidator
def 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 = true
return false
end
- return valid_json?(val) if (@opts[:json_schema])
+ return valid_json?(val) if @opts[:json_schema]
regex_match?(val)
end
diff --git a/lib/validators/upload_validator.rb b/lib/validators/upload_validator.rb
index 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::Validator
def 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_pm
return true if upload.user&.staff?
end
diff --git a/plugins/automation/app/models/discourse_automation/field.rb b/plugins/automation/app/models/discourse_automation/field.rb
index 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 DiscourseAutomation
validate :metadata_schema
def 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.rb
index 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 DiscourseAutomation
attributes :id, :name, :metadata
def metadata
- ((options[:trigger_metadata] || {}).stringify_keys).merge(object.metadata || {})
+ (options[:trigger_metadata] || {}).stringify_keys.merge(object.metadata || {})
end
end
end
diff --git a/plugins/automation/lib/discourse_automation/scriptable.rb b/plugins/automation/lib/discourse_automation/scriptable.rb
index 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 = false
diff --git a/plugins/chat/app/models/chat/reviewable_message.rb b/plugins/chat/app/models/chat/reviewable_message.rb
index 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 Chat
end
def 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)
end
def chat_message_creator
diff --git a/plugins/chat/app/serializers/chat/message_user_serializer.rb b/plugins/chat/app/serializers/chat/message_user_serializer.rb
index 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 Chat
attributes :moderator?, :admin?, :staff?, :moderator?, :new_user?, :primary_group_name
def moderator?
- !!(object&.moderator?)
+ !!object&.moderator?
end
def admin?
- !!(object&.admin?)
+ !!object&.admin?
end
def staff?
- !!(object&.staff?)
+ !!object&.staff?
end
def new_user?
diff --git a/plugins/chat/lib/chat/notification_consolidation_extension.rb b/plugins/chat/lib/chat/notification_consolidation_extension.rb
index 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 Chat
data.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,
)
end
end,
diff --git a/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rb b/plugins/discourse-ai/app/models/reviewable_ai_chat_message.rb
index 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 < Reviewable
end
def 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)
end
def chat_message_creator
diff --git a/plugins/discourse-ai/app/models/reviewable_ai_post.rb b/plugins/discourse-ai/app/models/reviewable_ai_post.rb
index 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 < Reviewable
private
def post
- @post ||= (target || Post.with_deleted.find_by(id: target_id))
+ @post ||= target || Post.with_deleted.find_by(id: target_id)
end
def destroyer(performed_by)
diff --git a/plugins/discourse-ai/app/serializers/ai_spam_serializer.rb b/plugins/discourse-ai/app/serializers/ai_spam_serializer.rb
index 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 < ApplicationSerializer
def spam_scanning_user
user = 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])
end
end
diff --git a/plugins/discourse-ai/app/serializers/llm_model_serializer.rb b/plugins/discourse-ai/app/serializers/llm_model_serializer.rb
index 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 < ApplicationSerializer
def used_by
llm_usage =
(
- if (scope && scope[:llm_usage])
+ if scope && scope[:llm_usage]
scope[:llm_usage]
else
DiscourseAi::Configuration::LlmEnumerator.global_usage
diff --git a/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rb b/plugins/discourse-ai/app/services/discourse_ai/summarization/regenerate_summaries.rb
index 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 DiscourseAi
topics.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)
else
summarizer = 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.rb
index 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 < ProblemCheck
return no_problem if failed_calls < MIN_FAILED_CALLS
return 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)
end
diff --git a/plugins/discourse-ai/lib/agents/agent.rb b/plugins/discourse-ai/lib/agents/agent.rb
index ee45a06392c..950858e8d82 100644
--- a/plugins/discourse-ai/lib/agents/agent.rb
+++ b/plugins/discourse-ai/lib/agents/agent.rb
@@ -70,10 +70,8 @@ module DiscourseAi
if agent.system
instance = agent.new
- (
- instance.required_tools == [] ||
- (instance.required_tools - all_available_tools).empty?
- )
+ instance.required_tools == [] ||
+ (instance.required_tools - all_available_tools).empty?
else
true
end
diff --git a/plugins/discourse-ai/lib/agents/sql_helper.rb b/plugins/discourse-ai/lib/agents/sql_helper.rb
index 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 DiscourseAi
order by table_name
SQL
- 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.rb
index 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 DiscourseAi
end
def 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.rb
index 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 DiscourseAi
self.class.categories
end
- 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.rb
index 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 DiscourseAi
if total_count <= 0
1
else
- [((total_count.to_f / PER_PAGE).ceil), MAX_ALLOWED_PAGE].min
+ [(total_count.to_f / PER_PAGE).ceil, MAX_ALLOWED_PAGE].min
end
result = { search_results: trimmed }
diff --git a/plugins/discourse-ai/lib/agents/tools/researcher.rb b/plugins/discourse-ai/lib/agents/tools/researcher.rb
index 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 DiscourseAi
end
def assign_tip
- if SiteSetting.respond_to?(:assign_enabled) && SiteSetting.assign_enabled
- (<<~TEXT).strip
+ <<~TEXT.strip if SiteSetting.respond_to?(:assign_enabled) && SiteSetting.assign_enabled
assigned_to:username or assigned_to:username1,username2 - topics assigned to a specific user
assigned_to:* - topics assigned to any user
assigned_to:nobody - topics not assigned to any user
TEXT
- end
end
def name
diff --git a/plugins/discourse-ai/lib/agents/tools/update_artifact.rb b/plugins/discourse-ai/lib/agents/tools/update_artifact.rb
index 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 DiscourseAi
end
def 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.rb
index 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 DiscourseAi
post_type =
(
- if (whisper || post.post_type == Post.types[:whisper])
+ if whisper || post.post_type == Post.types[:whisper]
Post.types[:whisper]
else
Post.types[:regular]
diff --git a/plugins/discourse-ai/lib/completions/dialects/xml_tools.rb b/plugins/discourse-ai/lib/completions/dialects/xml_tools.rb
index 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 DiscourseAi
begin
has_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 DiscourseAi
parameters << "</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.rb
index 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 DiscourseAi
ProblemCheck::AiLlmStatus.fast_track_problem!(
llm_model,
failures_count,
- (FAIL_TTL / 1.hour),
+ FAIL_TTL / 1.hour,
)
end
diff --git a/plugins/discourse-ai/lib/completions/endpoints/gemini.rb b/plugins/discourse-ai/lib/completions/endpoints/gemini.rb
index 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
.compact
if keep_last
- @buffer = +(keep_last)
+ @buffer = +keep_last
else
@buffer = +""
end
diff --git a/plugins/discourse-ai/lib/completions/json_stream_decoder.rb b/plugins/discourse-ai/lib/completions/json_stream_decoder.rb
index 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 DiscourseAi
split = @buffer.scan(/.*\n?/)
split.pop if split.last.blank?
- @buffer = +(split.pop.to_s)
+ @buffer = +split.pop.to_s
split.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.rb
index 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 DiscourseAi
doc.children.each do |node|
html = node.to_html
end_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_pos
max_length_within_target = end_pos
end
nil
@@ -86,9 +84,7 @@ module DiscourseAi
text.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_pos
max_length_within_target = tag_end
end
end
diff --git a/plugins/discourse-ai/spec/lib/agents/bot_spec.rb b/plugins/discourse-ai/spec/lib/agents/bot_spec.rb
index 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 do
context "when using function chaining" do
it "yields a loading placeholder while proceeds to invoke the command" do
tool = 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.rb
index 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 = 0
stub_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.rb
index 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 do
end
it "can stream a response" do
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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 do
end
it "handles streaming with cache tokens" do
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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 do
end
it "discounts cached tokens in the explicit usage tracker" do
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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 do
end
it "can stream a response with thinking blocks" do
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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.strip
event: message_start
data: {"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.strip
event: message_start
data: {"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.strip
event: message_start
data: {"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.rb
index 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 do
before { 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.rb
index 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 do
end
it "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 do
body: 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.rb
index 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 do
end
it "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 do
end
it "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.rb
index 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 do
it "can handle partial tool calls" do
processor = 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 do
xml.split("|").each { |part| result << (processor << part).map(&:dup) }
- result << (processor.finish)
+ result << processor.finish
result.flatten!
tool1_params =
@@ -68,7 +68,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
end
it "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 do
result = []
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
tool_call = result.last.first
expect(tool_call.parameters).to eq(hello: "world <sam>sam</sam>", test: "</h1>\n</div>\n")
end
it "is usable for simple single message mode" do
- xml = (<<~XML)
+ xml = <<~XML
world <function_calls>
<invoke>
<tool_name>hello</tool_name>
@@ -116,7 +116,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
result = []
result << (processor << "hello")
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
tool_call =
DiscourseAi::Completions::ToolCall.new(
@@ -133,7 +133,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
end
it "handles multiple tool calls in sequence" do
- xml = (<<~XML).strip
+ xml = <<~XML.strip
start
<function_calls>
<invoke>
@@ -154,7 +154,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
result = []
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
first_tool =
DiscourseAi::Completions::ToolCall.new(
@@ -179,7 +179,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
end
it "handles non-English parameters correctly" do
- xml = (<<~XML).strip
+ xml = <<~XML.strip
こんにちは
<function_calls>
<invoke>
@@ -192,7 +192,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
result = []
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
tool_call =
DiscourseAi::Completions::ToolCall.new(
@@ -222,7 +222,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
end
it "handles malformed XML gracefully" do
- xml = (<<~XML).strip
+ xml = <<~XML.strip
text
<function_calls>
<invoke>
@@ -236,7 +236,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
result = []
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
# Should just do its best to parse the XML
tool_call = DiscourseAi::Completions::ToolCall.new(id: "tool_0", name: "test", parameters: {})
@@ -244,7 +244,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
end
it "correctly processes empty parameter sets" do
- xml = (<<~XML).strip
+ xml = <<~XML.strip
hello
<function_calls>
<invoke>
@@ -256,7 +256,7 @@ RSpec.describe DiscourseAi::Completions::XmlToolProcessor do
result = []
result << (processor << xml)
- result << (processor.finish)
+ result << processor.finish
tool_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.rb
index 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 do
response_text = "I analyzed your post and can help with that."
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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.rb
index 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 do
count = 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 > 50
end
it "can trigger via stalled_topic with topic context" do
diff --git a/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb b/plugins/discourse-ai/spec/lib/modules/ai_bot/playground_spec.rb
index 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 do
content = prompt.messages[1][:content]
# this is fragile by design, mainly so the example can be ultra clear
- expected = (<<~TEXT).strip
+ expected = <<~TEXT.strip
You 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.strip
user: request 3
model: response 3
user: Hello
@@ -1234,7 +1234,7 @@ RSpec.describe DiscourseAi::AiBot::Playground do
after { DiscourseAi::AiBot::PostStreamer.on_callback = nil }
it "should be able to cancel a completion halfway through" do
- body = (<<~STRING).strip
+ body = <<~STRING.strip
event: message_start
data: {"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.rb
index 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 do
AiAgent.all_agents
- expect(AiAgent.agent_cache[:value].length).to be > (0)
+ expect(AiAgent.agent_cache[:value].length).to be > 0
RailsMultisite::ConnectionManagement.stubs(:current_db) { "abc" }
expect(AiAgent.agent_cache[:value]).to eq(nil)
end
diff --git a/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb b/plugins/discourse-ai/spec/requests/admin/ai_agents_controller_spec.rb
index 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 do
header_lines, _, payload_lines = lines.chunk { |l| l == "" }.map(&:last)
- preamble = (<<~PREAMBLE).strip
+ preamble = <<~PREAMBLE.strip
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
diff --git a/plugins/discourse-ai/spec/system/ai_bot/share_spec.rb b/plugins/discourse-ai/spec/system/ai_bot/share_spec.rb
index 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" do
clip_text = cdp.read_clipboard
expect(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" do
clip_text = cdp.read_clipboard
expect(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" do
clip_text = cdp.read_clipboard
expect(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.rb
index 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 DiscourseAssign
status = 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.rb
index 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 do
it "reassigns a post even when at the assignments limit" do
posts =
- (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.rb
index 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" do
it "can create, close, and open an event" do
visit "/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.rb
index 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 < ApplicationController
id: provider_klass::PROVIDER_NAME,
channel_parameters:
(
- if (defined?(provider_klass::CHANNEL_PARAMETERS))
+ if defined?(provider_klass::CHANNEL_PARAMETERS)
provider_klass::CHANNEL_PARAMETERS
else
[]
diff --git a/plugins/discourse-chat-integration/app/helpers/helper.rb b/plugins/discourse-chat-integration/app/helpers/helper.rb
index 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 DiscourseChatIntegration
if category_name
category = 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 DiscourseChatIntegration
category: 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 function
def 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].destroy
end
diff --git a/plugins/discourse-chat-integration/app/models/rule.rb b/plugins/discourse-chat-integration/app/models/rule.rb
index 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::PluginModel
private
def 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")
end
end
diff --git a/plugins/discourse-chat-integration/app/services/manager.rb b/plugins/discourse-chat-integration/app/services/manager.rb
index 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 DiscourseChatIntegration
matching_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 away
end
end
@@ -109,7 +109,7 @@ module DiscourseChatIntegration
provider.trigger_notification(post, channel, rule)
channel.update_attribute("error_key", nil) if channel.error_key
rescue => 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])
else
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider.rb
index 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 DiscourseChatIntegration
engine =
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))
.first
diff --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.rb
index 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 DiscourseChatIntegration
if topic.category
category =
(
- 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.rb
index 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::GroupmeProvider
elsif topic.category
category =
(
- 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.rb
index 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 DiscourseChatIntegration
elsif topic.category
category =
(
- 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 DiscourseChatIntegration
icon_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)
end
diff --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.rb
index 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::PowerAutomateProvider
elsif topic.category
category =
(
- 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.rb
index 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::RocketchatProvider
elsif topic.category
category =
(
- 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.rb
index 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 ChatIntegrationSlackEnabledSettingValidator
end
def valid_value?(val)
- return true if val == ("f") || val == (false)
+ return true if val == "f" || val == false
if SiteSetting.chat_integration_slack_outbound_webhook_url.blank? &&
SiteSetting.chat_integration_slack_access_token.blank?
return false
diff --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.rb
index 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::SlackProvider
elsif topic.category
category =
(
- 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::SlackProvider
icon_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::SlackProvider
icon_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::SlackProvider
if 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::SlackProvider
unless response.kind_of? Net::HTTPSuccess
if 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"
else
error_key = nil
diff --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.rb
index 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::TeamsProvider
elsif topic.category
category =
(
- 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/webex/webex_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/webex/webex_provider.rb
index 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::WebexProvider
elsif topic.category
category =
(
- 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.rb
index 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 DiscourseDataExplorer
value = object.id
when :user_id, :post_id, :topic_id, :group_id, :badge_id
if string.gsub(/[ _]/, "") =~ /^-?\d+$/
- klass_name = (/^(.*)_id$/.match(type.to_s)[1].classify.to_sym)
+ klass_name = /^(.*)_id$/.match(type.to_s)[1].classify.to_sym
begin
finder =
if type == :post_id || type == :topic_id
diff --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.rb
index 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::Adm
visible_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.rb
index 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 DiscourseNarrativeBot
old_data = @data.dup
new_post =
- if (@skip && @state != :end)
+ if @skip && @state != :end
skip_tutorial(next_state)
else
self.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.rb
index 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_all
end
diff --git a/plugins/discourse-policy/plugin.rb b/plugins/discourse-policy/plugin.rb
index 3b22e6b7666..a384ab2f19f 100644
--- a/plugins/discourse-policy/plugin.rb
+++ b/plugins/discourse-policy/plugin.rb
@@ -106,7 +106,7 @@ after_initialize do
post_policy.post_policy_groups = new_relations
renew_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_days
post_policy.renew_interval = post_policy.renew_days.present? ? nil : renew_days
diff --git a/plugins/discourse-policy/spec/lib/pretty_text_spec.rb b/plugins/discourse-policy/spec/lib/pretty_text_spec.rb
index 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.rb
index 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 < Reviewable
end
def comment
- @comment ||= (target || PostVotingComment.with_deleted.find_by(id: target_id))
+ @comment ||= target || PostVotingComment.with_deleted.find_by(id: target_id)
end
def comment_creator
diff --git a/plugins/discourse-templates/lib/tasks/discourse-templates.rake b/plugins/discourse-templates/lib/tasks/discourse-templates.rake
index 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_data
key: canned_replies_store_name,
)
- (old_replies.presence&.destroy!)
+ old_replies.presence&.destroy!
puts "Finished!"
rescue StandardError => e
diff --git a/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb b/plugins/discourse-templates/spec/lib/topic_query_extension_spec.rb
index 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 do
it "won't list private messages received as templates" do
topics = 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)
end
end
end
diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb
index d362175d03f..b368f821782 100644
--- a/script/bulk_import/base.rb
+++ b/script/bulk_import/base.rb
@@ -1557,7 +1557,7 @@ class BulkImport::Base
category[:name_lower] = name_lower
slug_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.rb
index 4ed8fed48c0..e69c56f8274 100644
--- a/script/bulk_import/vbulletin.rb
+++ b/script/bulk_import/vbulletin.rb
@@ -637,7 +637,7 @@ class BulkImport::VBulletin < BulkImport::Base
Dir.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.rb
index 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::Base
website:
(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"].strip
else
nil
end,
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 path
begin
@@ -311,7 +309,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
if newmember.email_digests
newmember.update(email_digests: user["email_confirmed"] == 1)
end
- if newmember.name.present? && newmember.name == (newmember.username)
+ if newmember.name.present? && newmember.name == newmember.username
newmember.update(name: "")
end
end,
@@ -341,7 +339,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
max_position = Category.all.max_by(&:position).position
create_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::Base
end
end
- if row["status"] == (0) || row["status"] == (3)
+ if row["status"] == 0 || row["status"] == 3
SiteSetting.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 blocks
s.gsub!(/^ {4,}/, " ")
@@ -821,34 +819,26 @@ class ImportScripts::DiscuzX < ImportScripts::Base
s.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,
)
end
end
diff --git a/script/import_scripts/drupal-6.rb b/script/import_scripts/drupal-6.rb
index 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] > 1
end
h
else
diff --git a/script/import_scripts/drupal.rb b/script/import_scripts/drupal.rb
index 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] > 1
end
h
else
diff --git a/script/import_scripts/ipboard.rb b/script/import_scripts/ipboard.rb
index 012404cedc5..4dd91efd4bc 100644
--- a/script/import_scripts/ipboard.rb
+++ b/script/import_scripts/ipboard.rb
@@ -308,7 +308,7 @@ class ImportScripts::IpboardSQL < ImportScripts::Base
create_category(params, params[:id])
create_categories(categories) do |category|
- id = (category["id"]).to_s
+ id = category["id"].to_s
name = CGI.unescapeHTML(cat_map[id])
{
id: id + "gal",
diff --git a/script/import_scripts/jive.rb b/script/import_scripts/jive.rb
index 1c8b34cdc30..f047244b272 100644
--- a/script/import_scripts/jive.rb
+++ b/script/import_scripts/jive.rb
@@ -273,7 +273,7 @@ class ImportScripts::Jive < ImportScripts::Base
Dir.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::Base
Dir.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::Base
Dir.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::Base
Dir.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.rb
index a04f6082c34..1c8f98109c0 100644
--- a/script/import_scripts/kunena.rb
+++ b/script/import_scripts/kunena.rb
@@ -75,7 +75,7 @@ class ImportScripts::Kunena < ImportScripts::Base
results =
@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.first
username = username * User.username_length.first
diff --git a/script/import_scripts/kunena3.rb b/script/import_scripts/kunena3.rb
index f2b77bfc138..e468aab0f38 100644
--- a/script/import_scripts/kunena3.rb
+++ b/script/import_scripts/kunena3.rb
@@ -94,7 +94,7 @@ class ImportScripts::Kunena < ImportScripts::Base
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.first
username = username * User.username_length.first
diff --git a/script/import_scripts/nabble.rb b/script/import_scripts/nabble.rb
index 20c28b01918..90f1cc2aaf5 100644
--- a/script/import_scripts/nabble.rb
+++ b/script/import_scripts/nabble.rb
@@ -283,7 +283,7 @@ end
class String
def indent(count, char = " ")
gsub(/([^\n]*)(\n|$)/) do |match|
- last_iteration = ($1 == "" && $2 == "")
+ last_iteration = $1 == "" && $2 == ""
line = +""
line << (char * count) unless last_iteration
line << $1
diff --git a/script/import_scripts/quandora/import.rb b/script/import_scripts/quandora/import.rb
index 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 << question
end
diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rb
index 6dd2d9b3bf1..93d324de916 100644
--- a/script/import_scripts/smf2.rb
+++ b/script/import_scripts/smf2.rb
@@ -504,7 +504,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
if use_count.keys.length < attachments.select(&:present?).length
body = "#{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] == 0
end
end
end
diff --git a/script/import_scripts/socialcast/import.rb b/script/import_scripts/socialcast/import.rb
index 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::Base
imported = 0
total = count_files(MESSAGES_DIR)
Dir.foreach(MESSAGES_DIR) do |filename|
- next if filename == (".") || filename == ("..")
+ next if filename == "." || filename == ".."
topics += 1
message_json = File.read MESSAGES_DIR + "/" + filename
message = SocialcastMessage.new(message_json)
@@ -44,7 +44,7 @@ class ImportScripts::Socialcast < ImportScripts::Base
users = 0
total = count_files(USERS_DIR)
Dir.foreach(USERS_DIR) do |filename|
- next if filename == (".") || filename == ("..")
+ next if filename == "." || filename == ".."
user_json = File.read USERS_DIR + "/" + filename
user = SocialcastUser.new(user_json).user
create_user user, user[:id]
diff --git a/script/import_scripts/socialcast/title.rb b/script/import_scripts/socialcast/title.rb
index 977aa712c26..2cf032e87c6 100644
--- a/script/import_scripts/socialcast/title.rb
+++ b/script/import_scripts/socialcast/title.rb
@@ -10,7 +10,7 @@ def titles
topics = 0
total = count_files(MESSAGES_DIR)
Dir.foreach(MESSAGES_DIR) do |filename|
- next if filename == (".") || filename == ("..")
+ next if filename == "." || filename == ".."
message_json = File.read MESSAGES_DIR + "/" + filename
message = SocialcastMessage.new(message_json)
next unless message.title
diff --git a/script/import_scripts/vbulletin3.rb b/script/import_scripts/vbulletin3.rb
index 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.avatarid
category.default_list_filter = "none"
end
- if (forum["is_category_only"] == 1 && access[:public_access] == 1)
+ if forum["is_category_only"] == 1 && access[:public_access] == 1
puts "\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.rb
index 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) || 0
diff = allocated - stat[:allocated]
puts "bin #{size} delta #{diff}"
end
diff --git a/spec/lib/crawler_detection_spec.rb b/spec/lib/crawler_detection_spec.rb
index a85feabe65e..cf733e93174 100644
--- a/spec/lib/crawler_detection_spec.rb
+++ b/spec/lib/crawler_detection_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe CrawlerDetection do
def 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)
end
def not_crawler!(s)
diff --git a/spec/lib/middleware/processing_request_spec.rb b/spec/lib/middleware/processing_request_spec.rb
index 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 do
describe "#call" do
it "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.rb
index 8db8352039d..1952b9666fa 100644
--- a/spec/lib/mobile_detection_spec.rb
+++ b/spec/lib/mobile_detection_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe MobileDetection do
let :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.30
Mozilla/5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.com
Mozilla/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 do
end
let :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.1
Mozilla/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.1
Mozilla/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.1
diff --git a/spec/lib/post_creator_spec.rb b/spec/lib/post_creator_spec.rb
index 6cdf975ec2a..92d2dac6b89 100644
--- a/spec/lib/post_creator_spec.rb
+++ b/spec/lib/post_creator_spec.rb
@@ -255,8 +255,8 @@ RSpec.describe PostCreator do
admin_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 do
GroupMessage
.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.id
end
creator.create
end
diff --git a/spec/lib/pretty_text_spec.rb b/spec/lib/pretty_text_spec.rb
index 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.rb
index 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 do
receiver
.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] == true
end
receiver.load_yaml(enum_client)
end
diff --git a/spec/lib/validators/topic_title_length_validator_spec.rb b/spec/lib/validators/topic_title_length_validator_spec.rb
index 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 do
end
it "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_length
validate
expect(record.errors[:title]).to_not be_present
end
it "is up to date" do
- record.title = "a" * (SiteSetting.min_topic_title_length)
+ record.title = "a" * SiteSetting.min_topic_title_length
validate
expect(record.errors[:title]).to_not be_present
@@ -56,7 +56,7 @@ RSpec.describe TopicTitleLengthValidator do
end
it "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_length
validate
expect(record.errors[:title]).to_not be_present
end
diff --git a/spec/models/remote_theme_spec.rb b/spec/models/remote_theme_spec.rb
index 9eaa92efa33..71198f5a4e2 100644
--- a/spec/models/remote_theme_spec.rb
+++ b/spec/models/remote_theme_spec.rb
@@ -670,7 +670,7 @@ RSpec.describe RemoteTheme do
I18n.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),
),
)
end
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index a20a8384c71..df8b8b8be6e 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -254,7 +254,7 @@ RSpec.describe TopicLink do
other_topic.reload
reflection_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_length
expect(reflection_link.url).to eq(topic_url)
end
end
diff --git a/spec/models/username_validator_spec.rb b/spec/models/username_validator_spec.rb
index a303715755f..3eac987df60 100644
--- a/spec/models/username_validator_spec.rb
+++ b/spec/models/username_validator_spec.rb
@@ -179,9 +179,9 @@ RSpec.describe UsernameValidator do
SiteSetting.max_username_length = max_username_length
expect_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}",
)
end
diff --git a/spec/requests/admin/site_texts_controller_spec.rb b/spec/requests/admin/site_texts_controller_spec.rb
index 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 do
get "/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_empty
get "/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.rb
index 76a4011ddb8..37dbf27f14b 100644
--- a/spec/services/group_message_spec.rb
+++ b/spec/services/group_message_spec.rb
@@ -19,9 +19,9 @@ RSpec.describe GroupMessage do
PostCreator
.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)