Skip to content

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

DEV: Enforce blank lines between definitions (#43246)

Alan Guo Xiang Tancc1783374630
diff --git a/.rubocop.yml b/.rubocop.yml
index ae99f8299d1..7461649db78 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -5,6 +5,9 @@ inherit_mode:
merge:
- Exclude
+Layout/EmptyLineBetweenDefs:
+ Enabled: true
+
# Still work to do in ensuring we don't link old files
Discourse/NoAddReferenceOrAliasesActiveRecordMigration:
Enabled: false
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ead34b7befb..f6110fcd20f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -320,6 +320,7 @@ module ApplicationHelper
def is_crawler_homepage?
request.path == "/" && use_crawler_layout?
end
+
# Creates open graph and twitter card meta data
def crawlable_meta_data(opts = nil)
opts ||= {}
diff --git a/app/serializers/email_log_serializer.rb b/app/serializers/email_log_serializer.rb
index 5ff92f56431..b99c2375d1f 100644
--- a/app/serializers/email_log_serializer.rb
+++ b/app/serializers/email_log_serializer.rb
@@ -16,6 +16,7 @@ class EmailLogSerializer < ApplicationSerializer
return if object.cc_addresses.blank?
object.cc_addresses_split
end
+
def include_reply_key?
reply_keys = @options[:reply_keys]
reply_keys.present? && reply_keys[[object.post_id, object.user_id]]
diff --git a/db/migrate/20251107123438_add_index_to_tag_groups.rb b/db/migrate/20251107123438_add_index_to_tag_groups.rb
index 43ad294063b..836e8e0d344 100644
--- a/db/migrate/20251107123438_add_index_to_tag_groups.rb
+++ b/db/migrate/20251107123438_add_index_to_tag_groups.rb
@@ -10,6 +10,7 @@ class AddIndexToTagGroups < ActiveRecord::Migration[8.0]
add_index :tag_groups, "lower(name)", unique: true
end
+
def down
raise ActiveRecord::IrreversibleMigration
end
diff --git a/lib/schema_settings_object_validator.rb b/lib/schema_settings_object_validator.rb
index ee3a9433d8c..42b3b2b6037 100644
--- a/lib/schema_settings_object_validator.rb
+++ b/lib/schema_settings_object_validator.rb
@@ -128,6 +128,7 @@ class SchemaSettingsObjectValidator
@errors.map(&:error_message)
end
end
+
class SchemaSettingsObjectError
def initialize(error, i18n_opts = {})
@error = error
diff --git a/migrations/core/lib/migrations/settings_parser.rb b/migrations/core/lib/migrations/settings_parser.rb
index 173df438977..868c875a992 100644
--- a/migrations/core/lib/migrations/settings_parser.rb
+++ b/migrations/core/lib/migrations/settings_parser.rb
@@ -4,6 +4,7 @@ module Migrations
class SettingsParser
class InvalidYaml < StandardError
end
+
class ValidationError < StandardError
end
diff --git a/migrations/core/spec/lib/common/reporting/factory_spec.rb b/migrations/core/spec/lib/common/reporting/factory_spec.rb
index d7f7ca71ca1..4f0f2638781 100644
--- a/migrations/core/spec/lib/common/reporting/factory_spec.rb
+++ b/migrations/core/spec/lib/common/reporting/factory_spec.rb
@@ -10,6 +10,7 @@ RSpec.describe Migrations::Reporting::Factory do
def io.tty?
true
end
+
def io.winsize
[24, 80]
end
diff --git a/migrations/core/spec/spec_setup.rb b/migrations/core/spec/spec_setup.rb
index 58c8c3d14be..ae1350ba201 100644
--- a/migrations/core/spec/spec_setup.rb
+++ b/migrations/core/spec/spec_setup.rb
@@ -50,6 +50,7 @@ module MigrationsSpecSetup
# `disco` binary does before loading the Rails environment.
def self.boot_rails(spec_dir)
rails_root = File.expand_path("../../..", spec_dir)
+ RSpec.configuration.files_to_run
Dir.chdir(rails_root) { require File.join(rails_root, "spec", "rails_helper") }
end
diff --git a/migrations/importer/lib/migrations/importer/uploads/site_settings.rb b/migrations/importer/lib/migrations/importer/uploads/site_settings.rb
index f4b22432a33..9f9c3022543 100644
--- a/migrations/importer/lib/migrations/importer/uploads/site_settings.rb
+++ b/migrations/importer/lib/migrations/importer/uploads/site_settings.rb
@@ -37,6 +37,7 @@ module Migrations
def self.current_db_override=(value)
@current_db_override = value
end
+
def self.current_db
@current_db_override
end
diff --git a/migrations/tooling/scripts/benchmarks/ipc_serialization.rb b/migrations/tooling/scripts/benchmarks/ipc_serialization.rb
index 02529d7de73..2545d4d5a84 100755
--- a/migrations/tooling/scripts/benchmarks/ipc_serialization.rb
+++ b/migrations/tooling/scripts/benchmarks/ipc_serialization.rb
@@ -75,6 +75,7 @@ module Codecs
def dump(data)
Oj.dump(data, OJ_OBJECT_SETTINGS)
end
+
def load(string)
Oj.load(string, OJ_OBJECT_SETTINGS)
end
@@ -82,6 +83,7 @@ module Codecs
def write(io, data)
Oj.to_stream(io, data, OJ_OBJECT_SETTINGS)
end
+
def each(io, &)
Oj.load(io, OJ_OBJECT_SETTINGS, &)
end
@@ -95,6 +97,7 @@ module Codecs
def dump(data)
Oj.dump(data, OJ_COMPAT_DUMP_SETTINGS)
end
+
def load(string)
Oj.load(string, OJ_COMPAT_LOAD_SETTINGS)
end
@@ -102,6 +105,7 @@ module Codecs
def write(io, data)
Oj.to_stream(io, data, OJ_COMPAT_DUMP_SETTINGS)
end
+
def each(io, &)
Oj.load(io, OJ_COMPAT_LOAD_SETTINGS, &)
end
@@ -117,6 +121,7 @@ module Codecs
def dump(data)
Oj.dump(data, OJ_STRICT_DUMP_SETTINGS)
end
+
def load(string)
Oj.load(string, OJ_STRICT_LOAD_SETTINGS)
end
@@ -124,6 +129,7 @@ module Codecs
def write(io, data)
Oj.to_stream(io, data, OJ_STRICT_DUMP_SETTINGS)
end
+
def each(io, &)
Oj.load(io, OJ_STRICT_LOAD_SETTINGS, &)
end
@@ -137,6 +143,7 @@ module Codecs
def dump(data)
JSON.generate(data)
end
+
def load(string)
JSON.parse(string, symbolize_names: true)
end
@@ -160,6 +167,7 @@ module Codecs
def dump(data)
::Marshal.dump(data)
end
+
def load(string)
::Marshal.load(string)
end
@@ -184,6 +192,7 @@ module Codecs
def dump(data)
MessagePack.pack(data)
end
+
def load(string)
MessagePack.unpack(string, symbolize_keys: true)
end
diff --git a/plugins/automation/db/migrate/20250307031538_migrate_category_to_categories_post_created.rb b/plugins/automation/db/migrate/20250307031538_migrate_category_to_categories_post_created.rb
index 44f1572ec6b..1a4ea89c115 100644
--- a/plugins/automation/db/migrate/20250307031538_migrate_category_to_categories_post_created.rb
+++ b/plugins/automation/db/migrate/20250307031538_migrate_category_to_categories_post_created.rb
@@ -33,6 +33,7 @@ class MigrateCategoryToCategoriesPostCreated < ActiveRecord::Migration[7.2]
AND a.trigger = 'post_created_edited'
SQL
end
+
def down
raise ActiveRecord::IrreversibleMigration
end
diff --git a/plugins/discourse-ai/lib/agents/artifact_update_strategies/base.rb b/plugins/discourse-ai/lib/agents/artifact_update_strategies/base.rb
index 1deb921624a..ff2fc2a18c9 100644
--- a/plugins/discourse-ai/lib/agents/artifact_update_strategies/base.rb
+++ b/plugins/discourse-ai/lib/agents/artifact_update_strategies/base.rb
@@ -4,6 +4,7 @@ module DiscourseAi
module ArtifactUpdateStrategies
class InvalidFormatError < StandardError
end
+
class Base
attr_reader :post,
:user,
diff --git a/plugins/discourse-ai/lib/utils/diff_utils/simple_diff.rb b/plugins/discourse-ai/lib/utils/diff_utils/simple_diff.rb
index 202ea881cbe..a75b5a1fa22 100644
--- a/plugins/discourse-ai/lib/utils/diff_utils/simple_diff.rb
+++ b/plugins/discourse-ai/lib/utils/diff_utils/simple_diff.rb
@@ -8,6 +8,7 @@ module DiscourseAi
class Error < StandardError
end
+
class NoMatchError < Error
end
diff --git a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
index 8e81d208663..8faa3acbf9d 100644
--- a/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
+++ b/plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/slack/slack_transcript.rb
@@ -75,6 +75,7 @@ module DiscourseChatIntegration::Provider::SlackProvider
def first_message_number
@first_message_index < 0 ? @messages.length + @first_message_index : @first_message_index
end
+
def last_message_number
@last_message_index < 0 ? @messages.length + @last_message_index : @last_message_index
end
diff --git a/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb b/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
index b7939b3a928..1aced515580 100644
--- a/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
+++ b/plugins/discourse-openid-connect/lib/omniauth_open_id_connect.rb
@@ -12,6 +12,7 @@ module OmniAuth
class OpenIDConnect < OmniAuth::Strategies::OAuth2
class NonceVerifyError < StandardError
end
+
class SubVerifyError < StandardError
end
diff --git a/script/bulk_import/uploads_importer.rb b/script/bulk_import/uploads_importer.rb
index 4dca236128a..12052c53b06 100644
--- a/script/bulk_import/uploads_importer.rb
+++ b/script/bulk_import/uploads_importer.rb
@@ -27,6 +27,7 @@ module BulkImport
class UploadsImporter
class DownloadFailedError < StandardError
end
+
class UploadSizeExceededError < DownloadFailedError
end
@@ -777,6 +778,7 @@ module BulkImport
def self.current_db_override=(value)
@current_db_override = value
end
+
def self.current_db
@current_db_override
end
diff --git a/spec/requests/admin/dashboard_controller_spec.rb b/spec/requests/admin/dashboard_controller_spec.rb
index 9b9802a7ab9..715fdf8ea12 100644
--- a/spec/requests/admin/dashboard_controller_spec.rb
+++ b/spec/requests/admin/dashboard_controller_spec.rb
@@ -1255,6 +1255,7 @@ RSpec.describe Admin::DashboardController do
let(:fake_provider) do
Class.new(AdminDashboard::Reports::SourceProvider) do
def self.source_name = "fake_source"
+
def self.fetch_many(identifiers, guardian:, filters: {})
identifiers.each_with_object({}) do |id, h|
h[id.to_s] = { id: id.to_s, filters: filters }
@@ -1266,6 +1267,7 @@ RSpec.describe Admin::DashboardController do
let(:raising_provider) do
Class.new(AdminDashboard::Reports::SourceProvider) do
def self.source_name = "raising_source"
+
def self.fetch_many(identifiers, guardian:, filters: {})
identifiers.each_with_object({}) do |id, h|
raise "boom" if id == "broken"
@@ -2329,6 +2331,7 @@ RSpec.describe Admin::DashboardController do
Class.new(AdminDashboard::Reports::SourceProvider) do
def self.source_name = "fake_source"
def self.label = "Fake"
+
def self.accessible_ids(identifiers, guardian:)
identifiers.map(&:to_s).reject { |id| id == "forbidden" }.to_set
end
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 380ffe57adf..a96fe5e26ad 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -5,6 +5,7 @@ module Helpers
class NotAThemeError < StandardError
end
+
class NotAComponentThemeError < StandardError
end
diff --git a/spec/system/page_objects/components/private_message_map.rb b/spec/system/page_objects/components/private_message_map.rb
index 627d3b953de..11047111b79 100644
--- a/spec/system/page_objects/components/private_message_map.rb
+++ b/spec/system/page_objects/components/private_message_map.rb
@@ -32,6 +32,7 @@ module PageObjects
def has_no_add_participants_button?
controls.has_no_button?(class: "add-participant-btn")
end
+
def click_add_participants_button
controls.click_button(class: "add-participant-btn")
end