Skip to content

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

DEV: Fix `assigned but unused variable` Prism warnings (#39436)

Jarek Radosz683ae3f8b950
diff --git a/app/controllers/composer_messages_controller.rb b/app/controllers/composer_messages_controller.rb
index f3fffc7fd8e..2bb63db0e9a 100644
--- a/app/controllers/composer_messages_controller.rb
+++ b/app/controllers/composer_messages_controller.rb
@@ -23,15 +23,6 @@ class ComposerMessagesController < ApplicationController
users = ComposerMessagesFinder.user_not_seen_in_a_while(usernames)
user_count = users.count
- if user_count > 0
- message_locale =
- if user_count == 1
- "education.user_not_seen_in_a_while.single"
- else
- "education.user_not_seen_in_a_while.multiple"
- end
- end
-
json = {
user_count: user_count,
usernames: users,
diff --git a/app/controllers/edit_directory_columns_controller.rb b/app/controllers/edit_directory_columns_controller.rb
index b373ef4cb9b..e981bc86c9c 100644
--- a/app/controllers/edit_directory_columns_controller.rb
+++ b/app/controllers/edit_directory_columns_controller.rb
@@ -47,12 +47,11 @@ class EditDirectoryColumnsController < ApplicationController
end
end
- details = {}
-
staff_action_logger.log_custom(
"update_directory_columns",
{ previous_value: previous_values, new_value: new_values },
)
+
render json: success_json
end
diff --git a/app/controllers/metadata_controller.rb b/app/controllers/metadata_controller.rb
index 77a71ff8090..6a619f3afe0 100644
--- a/app/controllers/metadata_controller.rb
+++ b/app/controllers/metadata_controller.rb
@@ -51,9 +51,6 @@ class MetadataController < ApplicationController
end
scheme_id = view_context.scheme_id
- primary_color = ColorScheme.hex_for_name("primary", scheme_id)
- icon_url_base =
- UrlHelper.absolute("/svg-sprite/#{Discourse.current_hostname}/icon/#{primary_color}")
manifest = {
name: SiteSetting.title,
diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index c525460c695..203da4187d6 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -1432,7 +1432,6 @@ class TopicsController < ApplicationController
def track_visit_to_topic
topic_id = @topic_view.topic.id
- ip = request.remote_ip
user_id = (current_user.id if current_user)
if !request.format.json?
diff --git a/app/jobs/regular/merge_user.rb b/app/jobs/regular/merge_user.rb
index abfb3d10ab6..4b5eb0468d3 100644
--- a/app/jobs/regular/merge_user.rb
+++ b/app/jobs/regular/merge_user.rb
@@ -3,9 +3,6 @@
module Jobs
class MergeUser < ::Jobs::Base
def execute(args)
- target_user_id = args[:target_user_id]
- current_user_id = args[:current_user_id]
-
user = User.find_by(id: args[:user_id])
target_user = User.find_by(id: args[:target_user_id])
current_user = User.find_by(id: args[:current_user_id])
diff --git a/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb b/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb
index 3626cefbdce..9bf92cf9445 100644
--- a/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb
+++ b/app/jobs/scheduled/clean_up_unused_registered_user_api_key_clients.rb
@@ -8,15 +8,14 @@ module Jobs
if SiteSetting.unused_registered_user_api_key_clients_days > 0
destroy_days_ago = SiteSetting.unused_registered_user_api_key_clients_days.days.ago
- clients =
- UserApiKeyClient
- .where.not(auth_redirect: nil)
- .where(
- "id NOT IN (SELECT user_api_key_client_id FROM user_api_keys WHERE user_api_keys.last_used_at > ?)",
- destroy_days_ago,
- )
- .distinct
- .destroy_all
+ UserApiKeyClient
+ .where.not(auth_redirect: nil)
+ .where(
+ "id NOT IN (SELECT user_api_key_client_id FROM user_api_keys WHERE user_api_keys.last_used_at > ?)",
+ destroy_days_ago,
+ )
+ .distinct
+ .destroy_all
end
end
end
diff --git a/app/models/concerns/has_custom_fields.rb b/app/models/concerns/has_custom_fields.rb
index b3b3121ad53..ed40890c955 100644
--- a/app/models/concerns/has_custom_fields.rb
+++ b/app/models/concerns/has_custom_fields.rb
@@ -300,8 +300,6 @@ module HasCustomFields
if descriptor.array_type? || (field_type != :json && Array === value)
value = Array(value || [])
value.compact!
- sub_type = field_type[0]
-
value.map! { |v| descriptor.serialize(v) }
unless value == fields.map(&:value)
diff --git a/app/models/concerns/reports/time_to_first_response.rb b/app/models/concerns/reports/time_to_first_response.rb
index 3b419e1acbe..89fc9011500 100644
--- a/app/models/concerns/reports/time_to_first_response.rb
+++ b/app/models/concerns/reports/time_to_first_response.rb
@@ -5,7 +5,6 @@ module Reports::TimeToFirstResponse
class_methods do
def report_time_to_first_response(report)
- category_filter = report.filters.dig(:category)
category_id, include_subcategories = report.add_category_filter
report.icon = "reply"
diff --git a/app/models/group_archived_message.rb b/app/models/group_archived_message.rb
index 14de99ba753..b08495446a1 100644
--- a/app/models/group_archived_message.rb
+++ b/app/models/group_archived_message.rb
@@ -6,10 +6,13 @@ class GroupArchivedMessage < ActiveRecord::Base
def self.move_to_inbox!(group_id, topic, opts = {})
topic_id = topic.id
- destroyed = GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
+
+ GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
+
trigger(:move_to_inbox, group_id, topic_id)
MessageBus.publish("/topic/#{topic_id}", { type: "move_to_inbox" }, group_ids: [group_id])
publish_topic_tracking_state(topic, group_id, opts[:acting_user_id])
+
Jobs.enqueue(
:group_pm_update_summary,
group_id: group_id,
@@ -20,11 +23,14 @@ class GroupArchivedMessage < ActiveRecord::Base
def self.archive!(group_id, topic, opts = {})
topic_id = topic.id
- destroyed = GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
+
+ GroupArchivedMessage.where(group_id: group_id, topic_id: topic_id).destroy_all
GroupArchivedMessage.create!(group_id: group_id, topic_id: topic_id)
+
trigger(:archive_message, group_id, topic_id)
MessageBus.publish("/topic/#{topic_id}", { type: "archived" }, group_ids: [group_id])
publish_topic_tracking_state(topic, group_id, opts[:acting_user_id])
+
Jobs.enqueue(
:group_pm_update_summary,
group_id: group_id,
diff --git a/app/models/private_message_topic_tracking_state.rb b/app/models/private_message_topic_tracking_state.rb
index d50069b3182..5b9da537b54 100644
--- a/app/models/private_message_topic_tracking_state.rb
+++ b/app/models/private_message_topic_tracking_state.rb
@@ -71,7 +71,7 @@ class PrivateMessageTopicTrackingState
TopicTrackingState.new_filter_sql
end
- sql = +<<~SQL
+ +<<~SQL
SELECT
DISTINCT topics.id AS topic_id,
u.id AS user_id,
diff --git a/app/models/topic_group.rb b/app/models/topic_group.rb
index 8a05b36a7e8..9ca08b116fd 100644
--- a/app/models/topic_group.rb
+++ b/app/models/topic_group.rb
@@ -31,14 +31,13 @@ class TopicGroup < ActiveRecord::Base
tg.group_id
SQL
- updated_groups =
- DB.query(
- update_query,
- user_id: user.id,
- topic_id: topic_id,
- post_number: post_number,
- now: DateTime.now,
- )
+ DB.query(
+ update_query,
+ user_id: user.id,
+ topic_id: topic_id,
+ post_number: post_number,
+ now: DateTime.now,
+ )
end
def self.create_topic_group(user, topic_id, post_number, updated_group_ids)
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 0c09d16f928..6bb724abcf4 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -421,7 +421,7 @@ class Upload < ActiveRecord::Base
raise "Calculated dominant color but unable to parse output:\n#{data}" if color.nil?
color
- rescue Discourse::Utils::CommandError => e
+ rescue Discourse::Utils::CommandError
# Timeout or unable to parse image
# This can happen due to bad user input - ignore and save
# an empty string to prevent re-evaluation
diff --git a/app/serializers/user_card_serializer.rb b/app/serializers/user_card_serializer.rb
index 6536cfa2c18..208c2aea209 100644
--- a/app/serializers/user_card_serializer.rb
+++ b/app/serializers/user_card_serializer.rb
@@ -200,7 +200,7 @@ class UserCardSerializer < BasicUserSerializer
end
def recent_time_read
- time = object.recent_time_read
+ object.recent_time_read
end
def primary_group_name
diff --git a/app/services/handle_chunk_upload.rb b/app/services/handle_chunk_upload.rb
index cc69c1c5baa..433e8791ff6 100644
--- a/app/services/handle_chunk_upload.rb
+++ b/app/services/handle_chunk_upload.rb
@@ -23,7 +23,7 @@ class HandleChunkUpload
has_chunk_been_uploaded =
File.exist?(@chunk) && File.size(@chunk) == @params[:current_chunk_size]
# 200 = exists, 404 = not uploaded yet
- status = has_chunk_been_uploaded ? 200 : 404
+ has_chunk_been_uploaded ? 200 : 404
end
def upload_chunk
diff --git a/app/services/user_updater.rb b/app/services/user_updater.rb
index 7ec8e4bbd66..f1cc14e1f98 100644
--- a/app/services/user_updater.rb
+++ b/app/services/user_updater.rb
@@ -259,7 +259,7 @@ class UserUpdater
)
end
DiscourseEvent.trigger(:within_user_updater_transaction, user, attributes)
- rescue Addressable::URI::InvalidURIError => e
+ rescue Addressable::URI::InvalidURIError
# Prevent 500 for crazy url input
return saved
end
diff --git a/config/initializers/000-pg_connection_patch.rb b/config/initializers/000-pg_connection_patch.rb
index bde7c786d15..aa97599e6fd 100644
--- a/config/initializers/000-pg_connection_patch.rb
+++ b/config/initializers/000-pg_connection_patch.rb
@@ -2,7 +2,6 @@
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
def self.new_client(conn_params)
- start = Time.now()
PG.connect(**conn_params)
rescue ::PG::Error => error
if conn_params && conn_params[:dbname] == "postgres"
diff --git a/config/initializers/008-rack-cors.rb b/config/initializers/008-rack-cors.rb
index f9d23ec771d..bfd8422da9d 100644
--- a/config/initializers/008-rack-cors.rb
+++ b/config/initializers/008-rack-cors.rb
@@ -32,15 +32,11 @@ class Discourse::Cors
end
def self.apply_headers(cors_origins, env, headers)
- request_method = env["REQUEST_METHOD"]
-
if headers["Access-Control-Allow-Origin"]
# Already configured. Probably by ApplicationController#apply_cdn_headers
elsif cors_origins
- origin = nil
- if origin = env["HTTP_ORIGIN"]
- origin = nil if cors_origins.exclude?(origin)
- end
+ origin = env["HTTP_ORIGIN"]
+ origin = nil if origin && cors_origins.exclude?(origin)
headers["Access-Control-Allow-Origin"] = origin || cors_origins[0]
headers[
diff --git a/lib/backup_restore/restorer.rb b/lib/backup_restore/restorer.rb
index eb6218f60d4..473df6c78c7 100644
--- a/lib/backup_restore/restorer.rb
+++ b/lib/backup_restore/restorer.rb
@@ -187,7 +187,7 @@ module BackupRestore
status = @success ? :restore_succeeded : :restore_failed
logs = Discourse::Utils.logs_markdown(@logger.logs, user: user)
- post = SystemMessage.create_from_system_user(user, status, logs: logs)
+ SystemMessage.create_from_system_user(user, status, logs: logs)
else
log "Could not send notification to '#{@user_info[:username]}' " \
"(#{@user_info[:email]}), because the user does not exist."
diff --git a/lib/discourse_dev/email_log.rb b/lib/discourse_dev/email_log.rb
index b7d94c27090..961d94bd137 100644
--- a/lib/discourse_dev/email_log.rb
+++ b/lib/discourse_dev/email_log.rb
@@ -47,7 +47,6 @@ module DiscourseDev
def incoming_email_data
user = User.random
- subject = Faker::Lorem.sentence
email_content = <<-EMAIL
Return-Path: #{user.email}
From: #{user.email}
diff --git a/lib/discourse_dev/tag.rb b/lib/discourse_dev/tag.rb
index 96c06ad6e1d..17b9a0688dc 100644
--- a/lib/discourse_dev/tag.rb
+++ b/lib/discourse_dev/tag.rb
@@ -12,7 +12,7 @@ module DiscourseDev
def create!
super
- rescue ActiveRecord::RecordInvalid => e
+ rescue ActiveRecord::RecordInvalid
# If the name is taken, try again
retry
end
diff --git a/lib/discourse_webauthn/registration_service.rb b/lib/discourse_webauthn/registration_service.rb
index 3fb339bb831..a0bf30e7be9 100644
--- a/lib/discourse_webauthn/registration_service.rb
+++ b/lib/discourse_webauthn/registration_service.rb
@@ -154,7 +154,7 @@ module DiscourseWebauthn
# see https://w3c.github.io/webauthn/#attested-credential-data for lengths
# of data for extraction
- aa_guid = attested_credential_data[0..15]
+ # aa_guid = attested_credential_data[0..15]
credential_id_length = attested_credential_data[16..17].unpack("n*")[0]
credential_id = attested_credential_data[18..(18 + credential_id_length - 1)]
diff --git a/lib/file_store/s3_store.rb b/lib/file_store/s3_store.rb
index 2c366972344..0cf1e89a3a7 100644
--- a/lib/file_store/s3_store.rb
+++ b/lib/file_store/s3_store.rb
@@ -505,7 +505,7 @@ module FileStore
if acl.present? || remove_existing_acl
begin
- object = object_from_path(key).acl.put(acl:)
+ object_from_path(key).acl.put(acl:)
rescue Aws::S3::Errors::NotImplemented => err
Discourse.warn_exception(
err,
diff --git a/lib/gaps.rb b/lib/gaps.rb
index 517f1e99c92..78a0beb7aba 100644
--- a/lib/gaps.rb
+++ b/lib/gaps.rb
@@ -27,7 +27,6 @@ class Gaps
return if @subset.nil? || @original.nil?
i = j = 0
- gaps = {}
current_gap = []
while e1 = @subset[i]
diff --git a/lib/import_export/base_exporter.rb b/lib/import_export/base_exporter.rb
index 6f08abfa297..a5169b92fcd 100644
--- a/lib/import_export/base_exporter.rb
+++ b/lib/import_export/base_exporter.rb
@@ -122,7 +122,6 @@ module ImportExport
end
def export_category_groups
- groups = []
group_names = []
auto_group_names = Group::AUTO_GROUPS.keys.map(&:to_s)
diff --git a/lib/import_export/importer.rb b/lib/import_export/importer.rb
index 67c1b00d80a..550a9b66f4c 100644
--- a/lib/import_export/importer.rb
+++ b/lib/import_export/importer.rb
@@ -62,8 +62,9 @@ module ImportExport
@groups.each do |group_data|
g = group_data.dup
user_ids = g.delete(:user_ids)
- external_id = g.delete(:id)
+ g.delete(:id) # external_id
new_group = Group.find_by_name(g[:name]) || Group.create!(g)
+
user_ids.each do |external_user_id|
begin
new_group.add(User.find(new_user_id(external_user_id)))
diff --git a/lib/mini_scheduler_long_running_job_logger.rb b/lib/mini_scheduler_long_running_job_logger.rb
index f64d70800f8..0685f4930b2 100644
--- a/lib/mini_scheduler_long_running_job_logger.rb
+++ b/lib/mini_scheduler_long_running_job_logger.rb
@@ -24,8 +24,6 @@ class MiniSchedulerLongRunningJobLogger
def start
@thread ||=
Thread.new do
- hostname = Discourse.os_hostname
-
loop do
break if self.stop_requested?
diff --git a/lib/onebox/status_check.rb b/lib/onebox/status_check.rb
index b774232ff8c..6c98b4e6e79 100644
--- a/lib/onebox/status_check.rb
+++ b/lib/onebox/status_check.rb
@@ -35,7 +35,7 @@ module Onebox
private
def check
- status, headers = FinalDestination.new(@url).small_get({})
+ status, _headers = FinalDestination.new(@url).small_get({})
@status = status
rescue Timeout::Error, Errno::ECONNREFUSED, Net::HTTPError, SocketError
@status = 0
diff --git a/lib/pretty_text/helpers.rb b/lib/pretty_text/helpers.rb
index 2f38fae3905..81cef0386eb 100644
--- a/lib/pretty_text/helpers.rb
+++ b/lib/pretty_text/helpers.rb
@@ -64,9 +64,9 @@ module PrettyText
Upload
.where(sha1: map.values)
- .pluck(:sha1, :url, :extension, :original_filename, :secure)
+ .pluck(:sha1, :url, :extension, :secure)
.each do |row|
- sha1, url, extension, original_filename, secure = row
+ sha1, url, extension, secure = row
if short_urls = reverse_map[sha1]
secure_uploads = SiteSetting.secure_uploads? && secure
diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rb
index b4a146898ac..0929f8f14f4 100644
--- a/lib/site_settings/type_supervisor.rb
+++ b/lib/site_settings/type_supervisor.rb
@@ -215,7 +215,6 @@ class SiteSettings::TypeSupervisor
def type_hash(name)
name = name.to_sym
type = get_type(name)
- list_type = get_list_type(name)
result = { type: type.to_s }
if type == :enum || (type == :list && get_enum_class(name))
diff --git a/lib/tasks/populate.thor b/lib/tasks/populate.thor
index 422de72ba4f..85e66a749a8 100644
--- a/lib/tasks/populate.thor
+++ b/lib/tasks/populate.thor
@@ -98,9 +98,8 @@ class Populate < Thor
puts post_creator.errors.full_messages, ""
raise StandardError.new(post_creator.errors.full_messages)
end
- topic = first_post.topic
- start_post = 2
- topic
+
+ first_post.topic
end
def create_post(users, topic)
diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake
index d1e22d8de08..6011886dcdc 100644
--- a/lib/tasks/themes.rake
+++ b/lib/tasks/themes.rake
@@ -227,22 +227,21 @@ task "themes:clone_all_official" do |task, args|
require "theme_metadata"
FileUtils.rm_rf("tmp/themes")
- official_themes =
- ThemeMetadata::OFFICIAL_THEMES.each do |theme_name|
- repo = "https://github.com/discourse/#{theme_name}"
- path = File.join(Rails.root, "tmp/themes/#{theme_name}")
+ ThemeMetadata::OFFICIAL_THEMES.each do |theme_name|
+ repo = "https://github.com/discourse/#{theme_name}"
+ path = File.join(Rails.root, "tmp/themes/#{theme_name}")
- attempts = 0
+ attempts = 0
- begin
- attempts += 1
- system("git clone #{repo} #{path}", exception: true)
- rescue StandardError
- abort("Failed to clone #{repo}") if attempts >= 3
- STDERR.puts "Failed to clone #{repo}... trying again..."
- retry
- end
+ begin
+ attempts += 1
+ system("git clone #{repo} #{path}", exception: true)
+ rescue StandardError
+ abort("Failed to clone #{repo}") if attempts >= 3
+ STDERR.puts "Failed to clone #{repo}... trying again..."
+ retry
end
+ end
end
desc "pull compatible theme versions for all themes"
diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 2092aca4b6b..83b171f6d1a 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -870,7 +870,6 @@ end
def mark_upload_posts_for_rebake(post_ids_to_rebake)
posts_to_rebake = Post.where(id: post_ids_to_rebake)
- post_rebake_errors = []
puts "",
"Marking #{posts_to_rebake.length} posts with affected uploads for rebake. Every 15 minutes, a batch of these will be enqueued for rebaking.",
""
diff --git a/lib/theme_store/git_importer.rb b/lib/theme_store/git_importer.rb
index 3b734fdbd35..773482b774f 100644
--- a/lib/theme_store/git_importer.rb
+++ b/lib/theme_store/git_importer.rb
@@ -17,7 +17,7 @@ class ThemeStore::GitImporter < ThemeStore::BaseImporter
if version = Discourse.find_compatible_git_resource(temp_folder)
begin
execute "git", "cat-file", "-e", version
- rescue RuntimeError => e
+ rescue RuntimeError
tracking_ref =
execute "git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}"
remote_name = tracking_ref.split("/", 2)[0]
diff --git a/lib/theme_translation_manager.rb b/lib/theme_translation_manager.rb
index e9b354ddd03..31a171982f4 100644
--- a/lib/theme_translation_manager.rb
+++ b/lib/theme_translation_manager.rb
@@ -5,7 +5,6 @@ class ThemeTranslationManager
attr_reader :key, :default, :theme
def self.list_from_hash(locale:, hash:, theme:, parent_keys: [])
- list = []
hash
.map do |key, value|
this_key_array = parent_keys + [key]
@@ -61,12 +60,11 @@ class ThemeTranslationManager
end
def create_record!(value)
- record =
- ThemeTranslationOverride.create!(
- locale: @locale,
- translation_key: @key,
- theme: @theme,
- value: value,
- )
+ ThemeTranslationOverride.create!(
+ locale: @locale,
+ translation_key: @key,
+ theme: @theme,
+ value: value,
+ )
end
end
diff --git a/lib/topic_creator.rb b/lib/topic_creator.rb
index 72d9288457a..cffceb9ecf5 100644
--- a/lib/topic_creator.rb
+++ b/lib/topic_creator.rb
@@ -124,7 +124,7 @@ class TopicCreator
begin
group.set_message_default_notification_levels!(topic)
- rescue Group::GroupPmUserLimitExceededError => e
+ rescue Group::GroupPmUserLimitExceededError
rollback_with!(
topic,
:too_large_group,
diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb
index 9f40978845a..806b64923cb 100644
--- a/lib/turbo_tests/runner.rb
+++ b/lib/turbo_tests/runner.rb
@@ -105,21 +105,11 @@ module TurboTests
protected
def check_for_migrations
- config =
- ActiveRecord::Base
- .configurations
- .find_db_config("test")
- .configuration_hash
- .merge("database" => "discourse_test_1")
-
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = %w[db/migrate db/post_migrate]
-
- begin
- ActiveRecord::Migration.check_all_pending!
- rescue ActiveRecord::PendingMigrationError
- puts "There are pending migrations, run rake parallel:migrate"
- exit 1
- end
+ ActiveRecord::Migration.check_all_pending!
+ rescue ActiveRecord::PendingMigrationError
+ STDERR.puts "There are pending migrations, run rake parallel:migrate"
+ exit 1
end
def setup_tmp_dir
diff --git a/lib/validators/pop3_polling_enabled_setting_validator.rb b/lib/validators/pop3_polling_enabled_setting_validator.rb
index d56f5ae6d82..223c19c0041 100644
--- a/lib/validators/pop3_polling_enabled_setting_validator.rb
+++ b/lib/validators/pop3_polling_enabled_setting_validator.rb
@@ -40,7 +40,7 @@ class POP3PollingEnabledSettingValidator
password: SiteSetting.pop3_polling_password,
openssl_verify: SiteSetting.pop3_polling_openssl_verify,
)
- rescue *EmailSettingsExceptionHandler::EXPECTED_EXCEPTIONS => err
+ rescue *EmailSettingsExceptionHandler::EXPECTED_EXCEPTIONS
false
else
true
diff --git a/lib/validators/string_setting_validator.rb b/lib/validators/string_setting_validator.rb
index 7dcc6abd229..2b218b90d00 100644
--- a/lib/validators/string_setting_validator.rb
+++ b/lib/validators/string_setting_validator.rb
@@ -27,7 +27,7 @@ class StringSettingValidator
# but ideally we should validate against the schema
begin
JSON.parse(json)
- rescue JSON::ParserError => e
+ rescue JSON::ParserError
@json_fail = true
return false
end
diff --git a/lib/version_compatibility.rb b/lib/version_compatibility.rb
index a0710470bda..226bf2e0bef 100644
--- a/lib/version_compatibility.rb
+++ b/lib/version_compatibility.rb
@@ -26,7 +26,7 @@ module Discourse
begin
version_list = YAML.safe_load(version_list)
- rescue Psych::SyntaxError, Psych::DisallowedClass => e
+ rescue Psych::SyntaxError, Psych::DisallowedClass
end
raise InvalidVersionListError unless version_list.is_a?(Hash)
@@ -35,7 +35,7 @@ module Discourse
version_list
.transform_keys do |v|
Gem::Requirement.parse(v)
- rescue Gem::Requirement::BadRequirementError => e
+ rescue Gem::Requirement::BadRequirementError
raise InvalidVersionListError, "Invalid version specifier: #{v}"
end
.sort_by do |parsed_requirement, _|
@@ -129,7 +129,7 @@ module Discourse
)
Discourse.find_compatible_resource(compat_resource)
- rescue InvalidVersionListError => e
+ rescue InvalidVersionListError
$stderr.puts "Invalid version list in #{path}"
rescue Discourse::Utils::CommandError
end
diff --git a/plugins/chat/lib/chat/onebox_handler.rb b/plugins/chat/lib/chat/onebox_handler.rb
index d9a5020b698..9803fecc436 100644
--- a/plugins/chat/lib/chat/onebox_handler.rb
+++ b/plugins/chat/lib/chat/onebox_handler.rb
@@ -37,7 +37,7 @@ module Chat
private
def self.build_args(url, chat_channel)
- args = {
+ {
channel_id: chat_channel.id,
channel_name: chat_channel.name,
is_category: chat_channel.category_channel?,
diff --git a/plugins/discourse-ai/lib/configuration/embedding_defs_validator.rb b/plugins/discourse-ai/lib/configuration/embedding_defs_validator.rb
index 06cd00b777f..84b1c821e84 100644
--- a/plugins/discourse-ai/lib/configuration/embedding_defs_validator.rb
+++ b/plugins/discourse-ai/lib/configuration/embedding_defs_validator.rb
@@ -25,7 +25,7 @@ module DiscourseAi
end
true
- rescue Net::HTTPBadResponse => e
+ rescue Net::HTTPBadResponse
false
end
diff --git a/plugins/discourse-ai/lib/guardian_extensions.rb b/plugins/discourse-ai/lib/guardian_extensions.rb
index e2aaf0303ed..2b857b96858 100644
--- a/plugins/discourse-ai/lib/guardian_extensions.rb
+++ b/plugins/discourse-ai/lib/guardian_extensions.rb
@@ -53,7 +53,6 @@ module DiscourseAi
def can_request_summary?
return false if anonymous?
- user_group_ids = user.group_ids
if (ai_agent = AiAgent.find_by_id_from_cache(SiteSetting.ai_summarization_agent)).blank?
return false
end
diff --git a/plugins/discourse-ai/lib/inferred_concepts/applier.rb b/plugins/discourse-ai/lib/inferred_concepts/applier.rb
index 9c7270ca533..31241d244b5 100644
--- a/plugins/discourse-ai/lib/inferred_concepts/applier.rb
+++ b/plugins/discourse-ai/lib/inferred_concepts/applier.rb
@@ -99,9 +99,6 @@ module DiscourseAi
def match_concepts_to_content(content, concept_list)
return [] if content.blank? || concept_list.blank?
- # Prepare user message with only the content
- user_message = content
-
# Use the ConceptMatcher agent to match concepts
agent =
diff --git a/plugins/discourse-ai/lib/summarization/strategies/topic_summary.rb b/plugins/discourse-ai/lib/summarization/strategies/topic_summary.rb
index fa8c9c10721..afbebdfcb1b 100644
--- a/plugins/discourse-ai/lib/summarization/strategies/topic_summary.rb
+++ b/plugins/discourse-ai/lib/summarization/strategies/topic_summary.rb
@@ -48,7 +48,6 @@ module DiscourseAi
end
def as_llm_messages(contents)
- resource_path = "#{Discourse.base_path}/t/-/#{target.id}"
content_title = target.title
category_name = target.category&.name
# Only include public tags in summaries since summaries are cached and shared across users
diff --git a/plugins/discourse-calendar/lib/time_sniffer.rb b/plugins/discourse-calendar/lib/time_sniffer.rb
index 5be385ed0d4..a61f2e13b35 100644
--- a/plugins/discourse-calendar/lib/time_sniffer.rb
+++ b/plugins/discourse-calendar/lib/time_sniffer.rb
@@ -302,7 +302,7 @@ class TimeSniffer
if match
begin
result = instance_exec(match, &blk)
- rescue Exception => e
+ rescue Exception
raise if @raise_errors
else
return result if result
diff --git a/plugins/discourse-chat-integration/app/jobs/onceoff/migrate_from_slack_official.rb b/plugins/discourse-chat-integration/app/jobs/onceoff/migrate_from_slack_official.rb
index 2a36a68f8c8..c12292a2621 100644
--- a/plugins/discourse-chat-integration/app/jobs/onceoff/migrate_from_slack_official.rb
+++ b/plugins/discourse-chat-integration/app/jobs/onceoff/migrate_from_slack_official.rb
@@ -86,13 +86,12 @@ module Jobs
end
# Create the rule, with clever logic for avoiding duplicates
- success =
- DiscourseChatIntegration::Helper.smart_create_rule(
- channel: channel,
- filter: row[:filter],
- category_id: row[:category_id],
- tags: row[:tags],
- )
+ DiscourseChatIntegration::Helper.smart_create_rule(
+ channel: channel,
+ filter: row[:filter],
+ category_id: row[:category_id],
+ tags: row[:tags],
+ )
end
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
index 59da14a8b74..9eff936b3d0 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/guilded/guilded_provider.rb
@@ -35,23 +35,15 @@ module DiscourseChatIntegration
def self.generate_guilded_message(post)
topic = post.topic
- category = ""
- if topic.category
- category =
- (
- if (topic.category.parent_category)
- "[#{topic.category.parent_category.name}/#{topic.category.name}]"
- else
- "[#{topic.category.name}]"
- end
- )
- end
- display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
-
- icon_url =
- if (url = (SiteSetting.try(:site_logo_small_url) || SiteSetting.logo_small_url)).present?
- "#{Discourse.base_url}#{url}"
+ category =
+ if topic.category&.parent_category
+ "[#{topic.category.parent_category.name}/#{topic.category.name}]"
+ elsif topic.category
+ "[#{topic.category.name}]"
+ else
+ ""
end
+ display_name = DiscourseChatIntegration::Helper.formatted_display_name(post.user)
message = {
embeds: [
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
index e871ae4089e..d8df4a9f84b 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/zulip/zulip_provider.rb
@@ -48,7 +48,7 @@ module DiscourseChatIntegration
),
)
- data = { type: "stream", to: stream, subject: subject, content: message }
+ { type: "stream", to: stream, subject: subject, content: message }
end
def self.trigger_notification(post, channel, rule)
diff --git a/plugins/discourse-lti/lib/discourse_lti/lti_omniauth_strategy.rb b/plugins/discourse-lti/lib/discourse_lti/lti_omniauth_strategy.rb
index 126c025e0de..dd1b74baaf6 100644
--- a/plugins/discourse-lti/lib/discourse_lti/lti_omniauth_strategy.rb
+++ b/plugins/discourse-lti/lib/discourse_lti/lti_omniauth_strategy.rb
@@ -34,7 +34,6 @@ class DiscourseLti::LtiOmniauthStrategy
end
def other_phase
- methods = %i[get post]
if on_initiate_path? && %i[get post].include?(request.request_method.downcase.to_sym)
return initiate_phase
end
@@ -220,7 +219,7 @@ class DiscourseLti::LtiOmniauthStrategy
end
def decode_token(token)
- payload, header =
+ payload, _header =
::JWT.decode(
request.params["id_token"],
public_key,
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 8aceb4f6fb2..1b29dbf5316 100644
--- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
+++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/base.rb
@@ -154,7 +154,6 @@ module DiscourseNarrativeBot
end
def reset_data(user, additional_data = {})
- old_data = get_data(user)
new_data = additional_data
set_data(user, new_data)
new_data
diff --git a/plugins/discourse-post-voting/lib/post_voting/comment_review_queue.rb b/plugins/discourse-post-voting/lib/post_voting/comment_review_queue.rb
index a059c8e479d..265da5630dc 100644
--- a/plugins/discourse-post-voting/lib/post_voting/comment_review_queue.rb
+++ b/plugins/discourse-post-voting/lib/post_voting/comment_review_queue.rb
@@ -43,15 +43,14 @@ module PostVoting
payload: payload,
)
reviewable.update(target_created_by: comment.user)
- score =
- reviewable.add_score(
- guardian.user,
- flag_type_id,
- meta_topic_id: post&.topic_id,
- take_action: opts[:take_action],
- reason: queued_for_review ? "post_voting_comment_queued_by_staff" : nil,
- force_review: queued_for_review,
- )
+ reviewable.add_score(
+ guardian.user,
+ flag_type_id,
+ meta_topic_id: post&.topic_id,
+ take_action: opts[:take_action],
+ reason: queued_for_review ? "post_voting_comment_queued_by_staff" : nil,
+ force_review: queued_for_review,
+ )
if opts[:take_action]
reviewable.perform(guardian.user, :agree_and_delete)
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
index 5132944c4e4..3e16a81b516 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/admin/subscriptions_controller.rb
@@ -100,7 +100,8 @@ module DiscourseSubscriptions
stripe_request_opts,
) if subscription[:latest_invoice]
payment_intent = invoice[:payment_intent] if invoice[:payment_intent]
- refund = ::Stripe::Refund.create({ payment_intent: payment_intent }, stripe_request_opts)
+
+ ::Stripe::Refund.create({ payment_intent: payment_intent }, stripe_request_opts)
end
end
end
diff --git a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
index 57fdecf230f..4799a361161 100644
--- a/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
+++ b/plugins/discourse-subscriptions/app/controllers/discourse_subscriptions/subscribe_controller.rb
@@ -111,16 +111,16 @@ module DiscourseSubscriptions
end
invoice = ::Stripe::Invoice.create(invoice_params, stripe_request_opts)
- invoice_item =
- ::Stripe::InvoiceItem.create(
- {
- customer: customer[:id],
- price: params[:plan],
- discounts: [{ coupon: coupon_id }],
- invoice: invoice[:id],
- },
- stripe_request_opts,
- )
+ ::Stripe::InvoiceItem.create(
+ {
+ customer: customer[:id],
+ price: params[:plan],
+ discounts: [{ coupon: coupon_id }],
+ invoice: invoice[:id],
+ },
+ stripe_request_opts,
+ )
+
transaction = ::Stripe::Invoice.finalize_invoice(invoice[:id], {}, stripe_request_opts)
payment_intent = retrieve_payment_intent(transaction[:id]) if transaction[:status] ==
"open"
diff --git a/plugins/discourse-subscriptions/app/services/discourse_subscriptions/campaign.rb b/plugins/discourse-subscriptions/app/services/discourse_subscriptions/campaign.rb
index 68fd63f723f..0d250c34fbf 100644
--- a/plugins/discourse-subscriptions/app/services/discourse_subscriptions/campaign.rb
+++ b/plugins/discourse-subscriptions/app/services/discourse_subscriptions/campaign.rb
@@ -138,7 +138,7 @@ module DiscourseSubscriptions
},
}
- plan = ::Stripe::Price.create(price_object, stripe_request_opts)
+ ::Stripe::Price.create(price_object, stripe_request_opts)
end
def get_one_time_payments(product_ids)
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 949002cbe6a..5b4ba867e97 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -437,7 +437,7 @@ RSpec.configure do |config|
module IgnoreServerCapturedErrors
def raise_server_error!
super
- rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::ENOTCONN => e
+ rescue EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::ENOTCONN
# Ignore these exceptions - caused by client. Handled by the app server in dev/prod
end
end
@@ -497,7 +497,6 @@ RSpec.configure do |config|
example_file_path = example.metadata[:rerun_file_path]
if example_file_path
- expanded_example_file_path = Pathname.new(example_file_path).expand_path
match =
example_file_path.to_s.match(
%r{^#{Regexp.escape(Rails.root.to_s)}/(plugins|themes|spec)/([^/]+)/},
diff --git a/spec/support/mock_git_importer.rb b/spec/support/mock_git_importer.rb
index 2f7c9bb487f..da6f3280d4c 100644
--- a/spec/support/mock_git_importer.rb
+++ b/spec/support/mock_git_importer.rb
@@ -27,7 +27,7 @@ class MockGitImporter < ThemeStore::GitImporter
end
def reset!
- repos = nil
+ @repos = nil
end
private
diff --git a/spec/system/page_objects/components/pikaday_calendar.rb b/spec/system/page_objects/components/pikaday_calendar.rb
index f6b0afd076f..c8ae86f359e 100644
--- a/spec/system/page_objects/components/pikaday_calendar.rb
+++ b/spec/system/page_objects/components/pikaday_calendar.rb
@@ -75,9 +75,6 @@ module PageObjects
end
def select_year(year)
- # visible: false is here because pikaday sets the controls
- # to opacity: 0 for some reason.
- select_element = visible_pikaday.find(".pika-select-year", visible: false)
page.driver.with_playwright_page do |playwright_page|
playwright_page.eval_on_selector(
".pika-select-year",