DEV: lint against Layout/EmptyLineBetweenDefs ()

This commit is contained in:
Kelv 2023-12-15 23:46:04 +08:00 committed by GitHub
parent 15fc2a289a
commit 2477bcc32e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 124 additions and 0 deletions
app
db/migrate
lib
plugins/chat/lib/chat
script
import_scripts
phpbb3/support/bbcode
smf2.rb
thread_detective.rb
spec

@ -14,8 +14,10 @@ class Admin::DashboardController < Admin::StaffController
def moderation
end
def security
end
def reports
end

@ -123,6 +123,7 @@ class ApplicationController < ActionController::Base
class RenderEmpty < StandardError
end
class PluginDisabled < StandardError
end

@ -112,8 +112,10 @@ module Jobs
class ImageTooLargeError < StandardError
end
class ImageBrokenError < StandardError
end
class UploadCreateError < StandardError
end

@ -206,6 +206,7 @@ module HasCustomFields
class NotPreloadedError < StandardError
end
class PreloadedProxy
def initialize(preloaded, klass_with_custom_fields)
@preloaded = preloaded

@ -3,6 +3,7 @@
class DiscourseConnect < DiscourseConnectBase
class BlankExternalId < StandardError
end
class BannedExternalId < StandardError
end

@ -3,8 +3,10 @@
class Invite < ActiveRecord::Base
class UserExists < StandardError
end
class RedemptionFailed < StandardError
end
class ValidationFailed < StandardError
end

@ -250,6 +250,7 @@ class Tag < ActiveRecord::Base
def sanitize_description
self.description = sanitize_field(self.description) if description_changed?
end
def name_validator
errors.add(:name, :invalid) if name.present? && RESERVED_TAGS.include?(self.name.strip.downcase)
end

@ -3,6 +3,7 @@
class Topic < ActiveRecord::Base
class UserExists < StandardError
end
class NotAllowed < StandardError
end
include RateLimiter::OnCreateRecord

@ -9,6 +9,7 @@ class ApplicationSerializer < ActiveModel::Serializer
def initialize(json)
@json = json
end
def as_json(*_args)
@json
end

@ -9,10 +9,13 @@ class ExternalUploadManager
class ChecksumMismatchError < StandardError
end
class DownloadFailedError < StandardError
end
class CannotPromoteError < StandardError
end
class SizeMismatchError < StandardError
end

@ -7,6 +7,7 @@ class AddUsernameLowerToUsers < ActiveRecord::Migration[4.2]
add_index :users, [:username_lower], unique: true
change_column :users, :username_lower, :string, limit: 20, null: false
end
def down
remove_column :users, :username_lower
end

@ -16,6 +16,7 @@ class CreatePostActions < ActiveRecord::Migration[4.2]
execute "create unique index idx_unique_actions on
post_actions(user_id, post_action_type_id, post_id) where deleted_at is null"
end
def down
drop_table :post_actions
end

@ -4,6 +4,7 @@ class AddTrackingToTopicUsers < ActiveRecord::Migration[4.2]
def up
execute "update topic_users set notification_level = 3 where notification_level = 2"
end
def down
execute "update topic_users set notification_level = 2 where notification_level = 3"
end

@ -4,6 +4,7 @@ class AddIpAddressToUsers < ActiveRecord::Migration[4.2]
def up
execute "alter table users add column ip_address inet"
end
def down
execute "alter table users drop column ip_address"
end

@ -6,6 +6,7 @@ class AddCustomEmailInToCategories < ActiveRecord::Migration[4.2]
add_column :categories, :email_in_allow_strangers, :boolean, default: false
add_index :categories, :email_in, unique: true
end
def down
remove_column :categories, :email_in
remove_column :categories, :email_in_allow_strangers

@ -5,6 +5,7 @@ class PrivateMessagesHaveNoCategoryId < ActiveRecord::Migration[4.2]
execute "UPDATE topics SET category_id = NULL WHERE category_id IS NOT NULL AND archetype = \'private_message\'"
execute "ALTER TABLE topics ADD CONSTRAINT pm_has_no_category CHECK (category_id IS NULL OR archetype <> 'private_message')"
end
def down
raise ActiveRecord::IrreversibleMigration
end

@ -5,6 +5,7 @@ class FlushApplicationRequests < ActiveRecord::Migration[4.2]
# flush as enum changed
execute "TRUNCATE TABLE application_requests"
end
def down
end
end

@ -4,6 +4,7 @@ class EnlargeUsersEmailField < ActiveRecord::Migration[4.2]
def up
change_column :users, :email, :string, limit: 513
end
def down
change_column :users, :email, :string, limit: 128
end

@ -8,6 +8,7 @@ class ShortenTopicCustomFieldsIndex < ActiveRecord::Migration[4.2]
name: "topic_custom_fields_value_key_idx",
where: "value IS NOT NULL AND char_length(value) < 400"
end
def down
remove_index :topic_custom_fields, :value, name: "topic_custom_fields_value_key_idx"
add_index :topic_custom_fields, :value

@ -4,6 +4,7 @@ class AddSkippedCreatedAtUserIdIndexOnEmailLogs < ActiveRecord::Migration[5.1]
def up
execute "CREATE INDEX idx_email_logs_user_created_filtered ON email_logs(user_id, created_at) WHERE skipped = 'f'"
end
def down
execute "DROP INDEX idx_email_logs_user_created_filtered"
end

@ -7,6 +7,7 @@ class AddSuppressFromLatestToCategories < ActiveRecord::Migration[5.1]
UPDATE categories SET suppress_from_latest = suppress_from_homepage
SQL
end
def down
raise "can not be removed"
end

@ -13,6 +13,7 @@ class AddIndexToTags < ActiveRecord::Migration[5.2]
add_index :tags, "lower(name)", unique: true
end
def down
raise ActiveRecord::IrreversibleMigration
end

@ -14,6 +14,7 @@ class AddThemeIdToJavascriptCache < ActiveRecord::Migration[5.2]
make_changes
execute "ALTER TABLE javascript_caches ADD CONSTRAINT enforce_theme_or_theme_field CHECK ((theme_id IS NOT NULL AND theme_field_id IS NULL) OR (theme_id IS NULL AND theme_field_id IS NOT NULL))"
end
def down
execute "ALTER TABLE javascript_caches DROP CONSTRAINT enforce_theme_or_theme_field"
revert { make_changes }

@ -7,6 +7,7 @@ class RemoveCanonicalEmailFromUserEmails < ActiveRecord::Migration[6.0]
DROP COLUMN IF EXISTS canonical_email
SQL
end
def down
# nothing to do, we already nuke the migrations
end

@ -2,6 +2,7 @@
module Auth
end
class Auth::CurrentUserProvider
# do all current user initialization here
def initialize(env)

@ -6,6 +6,7 @@ module Autospec
def self.watch(pattern, &blk)
WATCHERS[pattern] = blk
end
def watchers
WATCHERS
end
@ -41,6 +42,7 @@ module Autospec
def self.reload(pattern)
RELOADERS << pattern
end
def reloaders
RELOADERS
end

@ -5,10 +5,13 @@ require "rbconfig"
class ChromeInstalledChecker
class ChromeError < StandardError
end
class ChromeVersionError < ChromeError
end
class ChromeNotInstalled < ChromeError
end
class ChromeVersionTooLow < ChromeError
end

@ -3,8 +3,10 @@
class DiscourseConnectProvider < DiscourseConnectBase
class BlankSecret < RuntimeError
end
class BlankReturnUrl < RuntimeError
end
class InvalidParameterValueError < RuntimeError
attr_reader :param
def initialize(param)

@ -14,32 +14,46 @@ module DiscourseWebauthn
class InvalidOriginError < SecurityKeyError
end
class InvalidRelyingPartyIdError < SecurityKeyError
end
class UserVerificationError < SecurityKeyError
end
class UserPresenceError < SecurityKeyError
end
class ChallengeMismatchError < SecurityKeyError
end
class InvalidTypeError < SecurityKeyError
end
class UnsupportedPublicKeyAlgorithmError < SecurityKeyError
end
class UnsupportedAttestationFormatError < SecurityKeyError
end
class CredentialIdInUseError < SecurityKeyError
end
class MalformedAttestationError < SecurityKeyError
end
class KeyNotFoundError < SecurityKeyError
end
class MalformedPublicKeyCredentialError < SecurityKeyError
end
class OwnershipError < SecurityKeyError
end
class PublicKeyError < SecurityKeyError
end
class UnknownCOSEAlgorithmError < SecurityKeyError
end

@ -9,52 +9,76 @@ module Email
# * add text to server.en.yml (parent key: "emails.incoming.errors")
class ProcessingError < StandardError
end
class EmptyEmailError < ProcessingError
end
class ScreenedEmailError < ProcessingError
end
class UserNotFoundError < ProcessingError
end
class AutoGeneratedEmailError < ProcessingError
end
class BouncedEmailError < ProcessingError
end
class NoBodyDetectedError < ProcessingError
end
class NoSenderDetectedError < ProcessingError
end
class FromReplyByAddressError < ProcessingError
end
class InactiveUserError < ProcessingError
end
class SilencedUserError < ProcessingError
end
class BadDestinationAddress < ProcessingError
end
class StrangersNotAllowedError < ProcessingError
end
class ReplyNotAllowedError < ProcessingError
end
class InsufficientTrustLevelError < ProcessingError
end
class ReplyUserNotMatchingError < ProcessingError
end
class TopicNotFoundError < ProcessingError
end
class TopicClosedError < ProcessingError
end
class InvalidPost < ProcessingError
end
class TooShortPost < ProcessingError
end
class InvalidPostAction < ProcessingError
end
class UnsubscribeNotAllowed < ProcessingError
end
class EmailNotAllowed < ProcessingError
end
class OldDestinationError < ProcessingError
end
class ReplyToDigestError < ProcessingError
end

@ -10,6 +10,7 @@ require "url_helper"
class FinalDestination
class SSRFError < SocketError
end
class UrlEncodingError < ArgumentError
end

@ -4,6 +4,7 @@ class FinalDestination
module SSRFDetector
class DisallowedIpError < SSRFError
end
class LookupFailedError < SSRFError
end

@ -28,51 +28,67 @@ class Guardian
def blank?
true
end
def admin?
false
end
def staff?
false
end
def moderator?
false
end
def anonymous?
true
end
def approved?
false
end
def staged?
false
end
def silenced?
false
end
def is_system_user?
false
end
def bot?
false
end
def secure_category_ids
[]
end
def groups
[]
end
def has_trust_level?(level)
false
end
def has_trust_level_or_staff?(level)
false
end
def email
nil
end
def whisperer?
false
end
def in_any_groups?(group_ids)
false
end

@ -6,6 +6,7 @@
require "htmlentities"
module Import
end
module Import::Normalize
def self.normalize_code_blocks(code, lang = nil)
coder = HTMLEntities.new

@ -56,6 +56,7 @@ class Migration::SafeMigrate
def e.cause
nil
end
def e.backtrace
super.reject do |frame|
frame =~ /safe_migrate\.rb/ || frame =~ /schema_migration_details\.rb/

@ -39,8 +39,10 @@ class MiniSqlMultisiteConnection < MiniSql::ActiveRecordPostgres::Connection
def before_committed!(*)
end
def rolledback!(*)
end
def trigger_transactional_callbacks?
true
end

@ -5,10 +5,13 @@
class PresenceChannel
class NotFound < StandardError
end
class InvalidAccess < StandardError
end
class ConfigNotLoaded < StandardError
end
class InvalidConfig < StandardError
end

@ -32,6 +32,7 @@ module Chat
class MessageMover
class NoMessagesFound < StandardError
end
class InvalidChannel < StandardError
end

@ -2,6 +2,7 @@
module ImportScripts
end
module ImportScripts::PhpBB3
end

@ -585,6 +585,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
class Options
class Error < StandardError
end
class SettingsError < Error
end

@ -8,6 +8,7 @@ class ThreadDetective
def self.test_thread
Thread.new { sleep 1 }
end
def self.start(max_threads)
@thread ||= Thread.new { self.new.monitor(max_threads) }

@ -123,6 +123,7 @@ RSpec.describe Auth::ManagedAuthenticator do
def name
"myauth"
end
def can_connect_existing_user?
false
end
@ -164,6 +165,7 @@ RSpec.describe Auth::ManagedAuthenticator do
def name
"myauth"
end
def match_by_email
false
end
@ -328,9 +330,11 @@ RSpec.describe Auth::ManagedAuthenticator do
def name
"myauth"
end
def match_by_email
false
end
def match_by_username
true
end
@ -395,6 +399,7 @@ RSpec.describe Auth::ManagedAuthenticator do
def name
"myauth"
end
def match_by_username
false
end

@ -68,6 +68,7 @@ RSpec.describe Plugin::Instance do
"a trout"
end
end
class TroutJuniorSerializer < TroutSerializer
attribute :i_am_child

@ -390,6 +390,7 @@ RSpec.describe SiteSettingExtension do
def self.valid_value?(v)
true
end
def self.values
[1, 2, 3]
end
@ -409,9 +410,11 @@ RSpec.describe SiteSettingExtension do
def self.valid_value?(v)
self.values.include?(v)
end
def self.values
["en"]
end
def self.translate_names?
false
end

@ -136,9 +136,11 @@ RSpec.describe SiteSettings::TypeSupervisor do
def self.valid_value?(v)
self.values.include?(v)
end
def self.values
["en"]
end
def self.translate_names?
false
end
@ -147,9 +149,11 @@ RSpec.describe SiteSettings::TypeSupervisor do
class TestSmallThanTenValidator
def initialize(opts)
end
def valid_value?(v)
v < 10
end
def error_message
""
end
@ -408,9 +412,11 @@ RSpec.describe SiteSettings::TypeSupervisor do
def self.valid_value?(v)
self.values.include?(v)
end
def self.values
%w[a b]
end
def self.translate_names?
false
end

@ -3,8 +3,10 @@
class MockedImapProvider < Imap::Providers::Gmail
def connect!
end
def disconnect!
end
def open_mailbox(mailbox_name, write: false)
end

@ -11,6 +11,7 @@ module PageObjects
def user_badges_table
page.find(:table, id: "user-badges", visible: true)
end
def find_badge_row_by_granter(granter)
user_badges_table.find(:table_row, { "Granted By" => "#{granter.username}" })
end

@ -8,6 +8,7 @@ module PageObjects
def modal
find(".grant-badge-modal")
end
def select_badge(badge_name)
within(modal) do
grantable_badges_dropdown.expand

@ -8,6 +8,7 @@ module PageObjects
def modal
find(".change-ownership-modal")
end
def select_new_owner(user)
within(modal) do
users_dropdown.expand