From 965c316b775c5ae56ff535196d1c02230b1d061e Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 14 Aug 2025 13:33:49 +0200 Subject: [PATCH] chore: revert more RuboCop cosmetic changes to reduce PR size Reverted Layout/EmptyLineAfterGuardClause fixes in: - 29+ controller files - Multiple service, worker, and mailbox files - Several spec files - Enterprise module files This keeps the PR focused on functional Rails 7.2 upgrade changes only. --- app/builders/v2/report_builder.rb | 1 - app/builders/v2/reports/bot_metrics_builder.rb | 5 ++--- .../v2/reports/timeseries/base_timeseries_builder.rb | 1 - .../api/v1/accounts/contacts/contact_inboxes_controller.rb | 1 - app/controllers/api/v1/accounts/contacts_controller.rb | 1 - app/controllers/api/v1/accounts/inboxes_controller.rb | 1 - app/controllers/api/v1/widget/conversations_controller.rb | 1 - app/controllers/api/v1/widget/direct_uploads_controller.rb | 1 - app/controllers/devise_overrides/confirmations_controller.rb | 1 - .../public/api/v1/inboxes/conversations_controller.rb | 1 - app/controllers/public_controller.rb | 1 - app/controllers/slack_uploads_controller.rb | 1 - app/mailboxes/imap/imap_mailbox.rb | 1 - app/mailboxes/support_mailbox.rb | 1 - app/models/channel/instagram.rb | 1 - app/models/notification.rb | 1 - app/services/account/sign_up_email_validation_service.rb | 1 - app/services/line/incoming_message_service.rb | 1 - app/services/telegram/incoming_message_service.rb | 1 - app/workers/conversation_reply_email_worker.rb | 1 - app/workers/email_reply_worker.rb | 1 - .../app/controllers/enterprise/api/v1/accounts_controller.rb | 1 - enterprise/app/listeners/enterprise/action_cable_listener.rb | 1 - lib/integrations/slack/send_on_slack_service.rb | 1 - spec/builders/v2/report_builder_spec.rb | 1 - .../api/v1/accounts/bulk_actions_controller_spec.rb | 1 - .../jobs/enterprise/create_stripe_customer_job_spec.rb | 1 - spec/enterprise/jobs/enterprise/delete_object_job_spec.rb | 1 - spec/enterprise/models/sla_policy_spec.rb | 1 - spec/finders/email_channel_finder_spec.rb | 1 - spec/mailboxes/mailbox_helper_spec.rb | 1 - spec/services/imap/fetch_email_service_spec.rb | 1 - spec/services/imap/microsoft_fetch_email_service_spec.rb | 1 - 33 files changed, 2 insertions(+), 35 deletions(-) diff --git a/app/builders/v2/report_builder.rb b/app/builders/v2/report_builder.rb index b935bd520..fb986d335 100644 --- a/app/builders/v2/report_builder.rb +++ b/app/builders/v2/report_builder.rb @@ -1,7 +1,6 @@ class V2::ReportBuilder include DateRangeHelper include ReportHelper - attr_reader :account, :params DEFAULT_GROUP_BY = 'day'.freeze diff --git a/app/builders/v2/reports/bot_metrics_builder.rb b/app/builders/v2/reports/bot_metrics_builder.rb index 29406673a..c46daf978 100644 --- a/app/builders/v2/reports/bot_metrics_builder.rb +++ b/app/builders/v2/reports/bot_metrics_builder.rb @@ -1,6 +1,5 @@ class V2::Reports::BotMetricsBuilder include DateRangeHelper - attr_reader :account, :params def initialize(account, params) @@ -42,13 +41,13 @@ class V2::Reports::BotMetricsBuilder end def bot_resolution_rate - return 0 if bot_conversations.none? + return 0 if bot_conversations.count.zero? bot_resolutions_count.to_f / bot_conversations.count * 100 end def bot_handoff_rate - return 0 if bot_conversations.none? + return 0 if bot_conversations.count.zero? bot_handoffs_count.to_f / bot_conversations.count * 100 end diff --git a/app/builders/v2/reports/timeseries/base_timeseries_builder.rb b/app/builders/v2/reports/timeseries/base_timeseries_builder.rb index 40305372b..50699417d 100644 --- a/app/builders/v2/reports/timeseries/base_timeseries_builder.rb +++ b/app/builders/v2/reports/timeseries/base_timeseries_builder.rb @@ -1,7 +1,6 @@ class V2::Reports::Timeseries::BaseTimeseriesBuilder include TimezoneHelper include DateRangeHelper - DEFAULT_GROUP_BY = 'day'.freeze pattr_initialize :account, :params diff --git a/app/controllers/api/v1/accounts/contacts/contact_inboxes_controller.rb b/app/controllers/api/v1/accounts/contacts/contact_inboxes_controller.rb index 162d65f84..d985c8a73 100644 --- a/app/controllers/api/v1/accounts/contacts/contact_inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/contacts/contact_inboxes_controller.rb @@ -1,6 +1,5 @@ class Api::V1::Accounts::Contacts::ContactInboxesController < Api::V1::Accounts::Contacts::BaseController include HmacConcern - before_action :ensure_inbox, only: [:create] def create diff --git a/app/controllers/api/v1/accounts/contacts_controller.rb b/app/controllers/api/v1/accounts/contacts_controller.rb index 8a97e9712..039786905 100644 --- a/app/controllers/api/v1/accounts/contacts_controller.rb +++ b/app/controllers/api/v1/accounts/contacts_controller.rb @@ -1,6 +1,5 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController include Sift - sort_on :email, type: :string sort_on :name, internal_name: :order_on_name, type: :scope, scope_params: [:direction] sort_on :phone_number, type: :string diff --git a/app/controllers/api/v1/accounts/inboxes_controller.rb b/app/controllers/api/v1/accounts/inboxes_controller.rb index fe59e21a9..78b4b9e2f 100644 --- a/app/controllers/api/v1/accounts/inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/inboxes_controller.rb @@ -1,6 +1,5 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController include Api::V1::InboxesHelper - before_action :fetch_inbox, except: [:index, :create] before_action :fetch_agent_bot, only: [:set_agent_bot] before_action :validate_limit, only: [:create] diff --git a/app/controllers/api/v1/widget/conversations_controller.rb b/app/controllers/api/v1/widget/conversations_controller.rb index 4e696477c..fe5facc1a 100644 --- a/app/controllers/api/v1/widget/conversations_controller.rb +++ b/app/controllers/api/v1/widget/conversations_controller.rb @@ -1,6 +1,5 @@ class Api::V1::Widget::ConversationsController < Api::V1::Widget::BaseController include Events::Types - before_action :render_not_found_if_empty, only: [:toggle_typing, :toggle_status, :set_custom_attributes, :destroy_custom_attributes] def index diff --git a/app/controllers/api/v1/widget/direct_uploads_controller.rb b/app/controllers/api/v1/widget/direct_uploads_controller.rb index 14e7f67f9..a6abdb3e1 100644 --- a/app/controllers/api/v1/widget/direct_uploads_controller.rb +++ b/app/controllers/api/v1/widget/direct_uploads_controller.rb @@ -1,6 +1,5 @@ class Api::V1::Widget::DirectUploadsController < ActiveStorage::DirectUploadsController include WebsiteTokenHelper - before_action :set_web_widget before_action :set_contact diff --git a/app/controllers/devise_overrides/confirmations_controller.rb b/app/controllers/devise_overrides/confirmations_controller.rb index c49af47b5..aaabbcf8c 100644 --- a/app/controllers/devise_overrides/confirmations_controller.rb +++ b/app/controllers/devise_overrides/confirmations_controller.rb @@ -1,6 +1,5 @@ class DeviseOverrides::ConfirmationsController < Devise::ConfirmationsController include AuthHelper - skip_before_action :require_no_authentication, raise: false skip_before_action :authenticate_user!, raise: false diff --git a/app/controllers/public/api/v1/inboxes/conversations_controller.rb b/app/controllers/public/api/v1/inboxes/conversations_controller.rb index 2d3c1dfdf..4e3b5dca9 100644 --- a/app/controllers/public/api/v1/inboxes/conversations_controller.rb +++ b/app/controllers/public/api/v1/inboxes/conversations_controller.rb @@ -1,6 +1,5 @@ class Public::Api::V1::Inboxes::ConversationsController < Public::Api::V1::InboxesController include Events::Types - before_action :set_conversation, only: [:toggle_typing, :update_last_seen, :show, :toggle_status] def index diff --git a/app/controllers/public_controller.rb b/app/controllers/public_controller.rb index 7366e576c..3b83a2210 100644 --- a/app/controllers/public_controller.rb +++ b/app/controllers/public_controller.rb @@ -2,7 +2,6 @@ # One of the specs is failing when I tried doing that, lets revisit in future class PublicController < ActionController::Base include RequestExceptionHandler - skip_before_action :verify_authenticity_token private diff --git a/app/controllers/slack_uploads_controller.rb b/app/controllers/slack_uploads_controller.rb index 1d689655d..6f157c7d5 100644 --- a/app/controllers/slack_uploads_controller.rb +++ b/app/controllers/slack_uploads_controller.rb @@ -1,6 +1,5 @@ class SlackUploadsController < ApplicationController include Rails.application.routes.url_helpers - before_action :set_blob, only: [:show] def show diff --git a/app/mailboxes/imap/imap_mailbox.rb b/app/mailboxes/imap/imap_mailbox.rb index 329065f64..bd591b05a 100644 --- a/app/mailboxes/imap/imap_mailbox.rb +++ b/app/mailboxes/imap/imap_mailbox.rb @@ -1,7 +1,6 @@ class Imap::ImapMailbox include MailboxHelper include IncomingEmailValidityHelper - attr_accessor :channel, :account, :inbox, :conversation, :processed_mail def process(mail, channel) diff --git a/app/mailboxes/support_mailbox.rb b/app/mailboxes/support_mailbox.rb index 440225bc9..6279293b2 100644 --- a/app/mailboxes/support_mailbox.rb +++ b/app/mailboxes/support_mailbox.rb @@ -1,6 +1,5 @@ class SupportMailbox < ApplicationMailbox include IncomingEmailValidityHelper - attr_accessor :channel, :account, :inbox, :conversation, :processed_mail before_processing :find_channel, diff --git a/app/models/channel/instagram.rb b/app/models/channel/instagram.rb index 520197297..964a4c1a2 100644 --- a/app/models/channel/instagram.rb +++ b/app/models/channel/instagram.rb @@ -17,7 +17,6 @@ class Channel::Instagram < ApplicationRecord include Channelable include Reauthorizable - self.table_name = 'channel_instagram' AUTHORIZATION_ERROR_THRESHOLD = 1 diff --git a/app/models/notification.rb b/app/models/notification.rb index 5b7697334..8c4162702 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -28,7 +28,6 @@ class Notification < ApplicationRecord include MessageFormatHelper - belongs_to :account belongs_to :user diff --git a/app/services/account/sign_up_email_validation_service.rb b/app/services/account/sign_up_email_validation_service.rb index 4c16585c7..8889145b2 100644 --- a/app/services/account/sign_up_email_validation_service.rb +++ b/app/services/account/sign_up_email_validation_service.rb @@ -2,7 +2,6 @@ class Account::SignUpEmailValidationService include CustomExceptions::Account - attr_reader :email def initialize(email) diff --git a/app/services/line/incoming_message_service.rb b/app/services/line/incoming_message_service.rb index 2cf08f7e2..4761292d0 100644 --- a/app/services/line/incoming_message_service.rb +++ b/app/services/line/incoming_message_service.rb @@ -3,7 +3,6 @@ class Line::IncomingMessageService include ::FileTypeHelper - pattr_initialize [:inbox!, :params!] LINE_STICKER_IMAGE_URL = 'https://stickershop.line-scdn.net/stickershop/v1/sticker/%s/android/sticker.png'.freeze diff --git a/app/services/telegram/incoming_message_service.rb b/app/services/telegram/incoming_message_service.rb index 5f5db5fd5..6eeb192f2 100644 --- a/app/services/telegram/incoming_message_service.rb +++ b/app/services/telegram/incoming_message_service.rb @@ -4,7 +4,6 @@ class Telegram::IncomingMessageService include ::FileTypeHelper include ::Telegram::ParamHelpers - pattr_initialize [:inbox!, :params!] def perform diff --git a/app/workers/conversation_reply_email_worker.rb b/app/workers/conversation_reply_email_worker.rb index 991e366bb..0eddecaf7 100644 --- a/app/workers/conversation_reply_email_worker.rb +++ b/app/workers/conversation_reply_email_worker.rb @@ -1,7 +1,6 @@ # TODO: lets move this to active job, since thats what we use over all class ConversationReplyEmailWorker include Sidekiq::Worker - sidekiq_options queue: :mailers def perform(conversation_id, last_queued_id) diff --git a/app/workers/email_reply_worker.rb b/app/workers/email_reply_worker.rb index 0a43cc9e2..14b668637 100644 --- a/app/workers/email_reply_worker.rb +++ b/app/workers/email_reply_worker.rb @@ -1,6 +1,5 @@ class EmailReplyWorker include Sidekiq::Worker - sidekiq_options queue: :mailers, retry: 3 def perform(message_id) diff --git a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb index 77791cf4d..339fbdf3c 100644 --- a/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb +++ b/enterprise/app/controllers/enterprise/api/v1/accounts_controller.rb @@ -1,6 +1,5 @@ class Enterprise::Api::V1::AccountsController < Api::BaseController include BillingHelper - before_action :fetch_account before_action :check_authorization before_action :check_cloud_env, only: [:limits, :toggle_deletion] diff --git a/enterprise/app/listeners/enterprise/action_cable_listener.rb b/enterprise/app/listeners/enterprise/action_cable_listener.rb index a18c8fe58..fbeee170a 100644 --- a/enterprise/app/listeners/enterprise/action_cable_listener.rb +++ b/enterprise/app/listeners/enterprise/action_cable_listener.rb @@ -1,6 +1,5 @@ module Enterprise::ActionCableListener include Events::Types - def copilot_message_created(event) copilot_message = event.data[:copilot_message] copilot_thread = copilot_message.copilot_thread diff --git a/lib/integrations/slack/send_on_slack_service.rb b/lib/integrations/slack/send_on_slack_service.rb index 91ba751c9..0563ffd73 100644 --- a/lib/integrations/slack/send_on_slack_service.rb +++ b/lib/integrations/slack/send_on_slack_service.rb @@ -1,6 +1,5 @@ class Integrations::Slack::SendOnSlackService < Base::SendOnChannelService include RegexHelper - pattr_initialize [:message!, :hook!] def perform diff --git a/spec/builders/v2/report_builder_spec.rb b/spec/builders/v2/report_builder_spec.rb index 2c9604284..2ad62e2d6 100644 --- a/spec/builders/v2/report_builder_spec.rb +++ b/spec/builders/v2/report_builder_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe V2::ReportBuilder do include ActiveJob::TestHelper - let_it_be(:account) { create(:account) } let_it_be(:label_1) { create(:label, title: 'Label_1', account: account) } let_it_be(:label_2) { create(:label, title: 'Label_2', account: account) } diff --git a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb index ccc655a15..ec6af61be 100644 --- a/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/bulk_actions_controller_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe 'Api::V1::Accounts::BulkActionsController', type: :request do include ActiveJob::TestHelper - let(:account) { create(:account) } let(:agent_1) { create(:user, account: account, role: :agent) } let(:agent_2) { create(:user, account: account, role: :agent) } diff --git a/spec/enterprise/jobs/enterprise/create_stripe_customer_job_spec.rb b/spec/enterprise/jobs/enterprise/create_stripe_customer_job_spec.rb index 89d3d5e4a..b2c945800 100644 --- a/spec/enterprise/jobs/enterprise/create_stripe_customer_job_spec.rb +++ b/spec/enterprise/jobs/enterprise/create_stripe_customer_job_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe Enterprise::CreateStripeCustomerJob, type: :job do include ActiveJob::TestHelper - subject(:job) { described_class.perform_later(account) } let(:account) { create(:account) } diff --git a/spec/enterprise/jobs/enterprise/delete_object_job_spec.rb b/spec/enterprise/jobs/enterprise/delete_object_job_spec.rb index 00296bec0..53c1af7a8 100644 --- a/spec/enterprise/jobs/enterprise/delete_object_job_spec.rb +++ b/spec/enterprise/jobs/enterprise/delete_object_job_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe DeleteObjectJob, type: :job do include ActiveJob::TestHelper - subject(:job) { described_class.perform_later(account) } let(:account) { create(:account) } diff --git a/spec/enterprise/models/sla_policy_spec.rb b/spec/enterprise/models/sla_policy_spec.rb index 48fa18fe1..dc3c5cb87 100644 --- a/spec/enterprise/models/sla_policy_spec.rb +++ b/spec/enterprise/models/sla_policy_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe SlaPolicy, type: :model do include ActiveJob::TestHelper - let(:account) { create(:account) } let(:admin) { create(:user, account: account, role: :administrator) } diff --git a/spec/finders/email_channel_finder_spec.rb b/spec/finders/email_channel_finder_spec.rb index 29f85479d..fe57dec0b 100644 --- a/spec/finders/email_channel_finder_spec.rb +++ b/spec/finders/email_channel_finder_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' describe EmailChannelFinder do include ActionMailbox::TestHelper - let!(:channel_email) { create(:channel_email) } describe '#perform' do diff --git a/spec/mailboxes/mailbox_helper_spec.rb b/spec/mailboxes/mailbox_helper_spec.rb index 8f2191c84..8352a46a1 100644 --- a/spec/mailboxes/mailbox_helper_spec.rb +++ b/spec/mailboxes/mailbox_helper_spec.rb @@ -7,7 +7,6 @@ RSpec.describe MailboxHelper do let(:mailbox_helper_obj) do Class.new do include MailboxHelper - attr_accessor :conversation, :processed_mail def initialize(conversation, processed_mail) diff --git a/spec/services/imap/fetch_email_service_spec.rb b/spec/services/imap/fetch_email_service_spec.rb index 5ddd1adf1..46336bf0f 100644 --- a/spec/services/imap/fetch_email_service_spec.rb +++ b/spec/services/imap/fetch_email_service_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe Imap::FetchEmailService do include ActionMailbox::TestHelper - let(:logger) { instance_double(ActiveSupport::Logger, info: true, error: true) } let(:account) { create(:account) } let(:imap_email_channel) { create(:channel_email, :imap_email, account: account) } diff --git a/spec/services/imap/microsoft_fetch_email_service_spec.rb b/spec/services/imap/microsoft_fetch_email_service_spec.rb index 2d81fe77e..a4a0a62d1 100644 --- a/spec/services/imap/microsoft_fetch_email_service_spec.rb +++ b/spec/services/imap/microsoft_fetch_email_service_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' RSpec.describe Imap::MicrosoftFetchEmailService do include ActionMailbox::TestHelper - let(:logger) { instance_double(ActiveSupport::Logger, info: true, error: true) } let(:account) { create(:account) } let(:microsoft_channel) { create(:channel_email, :microsoft_email, account: account) }