From 9d0e2bc258085efe4743f5e8282d63fd1937d1e0 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 14 Aug 2025 13:30:39 +0200 Subject: [PATCH] chore: disable RuboCop rules to keep Rails upgrade PR focused - Disable Layout/EmptyLineAfterGuardClause - Disable Performance/Count - Fix Naming/PredicateMethod -> Naming/PredicateName - Revert cosmetic RuboCop fixes to reduce PR size --- .rubocop.yml | 9 ++++++++- app/actions/contact_merge_action.rb | 1 - app/builders/account_builder.rb | 1 - app/builders/messages/message_builder.rb | 1 - app/builders/notification_subscription_builder.rb | 6 +----- app/controllers/api/base_controller.rb | 1 - app/controllers/api/v1/accounts/base_controller.rb | 1 - app/models/application_record.rb | 1 - app/models/campaign.rb | 1 - app/models/concerns/access_tokenable.rb | 1 - app/models/concerns/channelable.rb | 1 - app/models/concerns/featurable.rb | 1 - app/models/concerns/sort_handler.rb | 2 +- app/models/contact_inbox.rb | 1 - app/models/inbox.rb | 2 +- app/models/integrations/app.rb | 1 - app/models/integrations/hook.rb | 2 +- 17 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 56460c4b8..5ef2d6ad7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -161,7 +161,7 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'app/models/message.rb' -Naming/PredicateMethod: +Naming/PredicateName: Exclude: - 'app/builders/messages/instagram/base_message_builder.rb' - 'app/controllers/public/api/v1/csat_survey_controller.rb' @@ -356,3 +356,10 @@ FactoryBot/RedundantFactoryOption: FactoryBot/FactoryAssociationWithStrategy: Enabled: false + +# Rules disabled to keep Rails upgrade PR focused on functional changes only +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Performance/Count: + Enabled: false diff --git a/app/actions/contact_merge_action.rb b/app/actions/contact_merge_action.rb index d7a8599e2..2633c907d 100644 --- a/app/actions/contact_merge_action.rb +++ b/app/actions/contact_merge_action.rb @@ -1,6 +1,5 @@ class ContactMergeAction include Events::Types - pattr_initialize [:account!, :base_contact!, :mergee_contact!] def perform diff --git a/app/builders/account_builder.rb b/app/builders/account_builder.rb index 1a75ae6e3..532487a1b 100644 --- a/app/builders/account_builder.rb +++ b/app/builders/account_builder.rb @@ -2,7 +2,6 @@ class AccountBuilder include CustomExceptions::Account - pattr_initialize [:account_name, :email!, :confirmed, :user, :user_full_name, :user_password, :super_admin, :locale] def perform diff --git a/app/builders/messages/message_builder.rb b/app/builders/messages/message_builder.rb index 8bab28685..e1087b19f 100644 --- a/app/builders/messages/message_builder.rb +++ b/app/builders/messages/message_builder.rb @@ -1,6 +1,5 @@ class Messages::MessageBuilder include ::FileTypeHelper - attr_reader :message def initialize(user, conversation, params) diff --git a/app/builders/notification_subscription_builder.rb b/app/builders/notification_subscription_builder.rb index 284bdbe32..0dede970f 100644 --- a/app/builders/notification_subscription_builder.rb +++ b/app/builders/notification_subscription_builder.rb @@ -17,11 +17,7 @@ class NotificationSubscriptionBuilder end def identifier_subscription - if instance_variable_defined?(:@identifier_subscription) - @identifier_subscription - else - @identifier_subscription = NotificationSubscription.find_by(identifier: identifier) - end + @identifier_subscription ||= NotificationSubscription.find_by(identifier: identifier) end def move_subscription_to_user diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 2708ecc8d..937cd5502 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -1,6 +1,5 @@ class Api::BaseController < ApplicationController include AccessTokenAuthHelper - respond_to :json before_action :authenticate_access_token!, if: :authenticate_by_access_token? before_action :validate_bot_access_token!, if: :authenticate_by_access_token? diff --git a/app/controllers/api/v1/accounts/base_controller.rb b/app/controllers/api/v1/accounts/base_controller.rb index 54c58a701..e30effc59 100644 --- a/app/controllers/api/v1/accounts/base_controller.rb +++ b/app/controllers/api/v1/accounts/base_controller.rb @@ -1,7 +1,6 @@ class Api::V1::Accounts::BaseController < Api::BaseController include SwitchLocale include EnsureCurrentAccountHelper - before_action :current_account around_action :switch_locale_using_account_locale end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index cdb7d9a5f..c6877c883 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,6 +1,5 @@ class ApplicationRecord < ActiveRecord::Base include Events::Types - self.abstract_class = true before_validation :validates_column_content_length diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 5600dae67..2927181c6 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -31,7 +31,6 @@ # class Campaign < ApplicationRecord include UrlHelper - validates :account_id, presence: true validates :inbox_id, presence: true validates :title, presence: true diff --git a/app/models/concerns/access_tokenable.rb b/app/models/concerns/access_tokenable.rb index 76a0811bf..0bb8daa4f 100644 --- a/app/models/concerns/access_tokenable.rb +++ b/app/models/concerns/access_tokenable.rb @@ -1,6 +1,5 @@ module AccessTokenable extend ActiveSupport::Concern - included do has_one :access_token, as: :owner, dependent: :destroy_async after_create :create_access_token diff --git a/app/models/concerns/channelable.rb b/app/models/concerns/channelable.rb index afdd218cd..e3e9eba94 100644 --- a/app/models/concerns/channelable.rb +++ b/app/models/concerns/channelable.rb @@ -1,6 +1,5 @@ module Channelable extend ActiveSupport::Concern - included do validates :account_id, presence: true belongs_to :account diff --git a/app/models/concerns/featurable.rb b/app/models/concerns/featurable.rb index 23b83006b..daa0b4bf6 100644 --- a/app/models/concerns/featurable.rb +++ b/app/models/concerns/featurable.rb @@ -14,7 +14,6 @@ module Featurable included do include FlagShihTzu - has_flags FEATURES.merge(column: 'feature_flags').merge(QUERY_MODE) before_create :enable_default_features diff --git a/app/models/concerns/sort_handler.rb b/app/models/concerns/sort_handler.rb index 29724f441..00eb73717 100644 --- a/app/models/concerns/sort_handler.rb +++ b/app/models/concerns/sort_handler.rb @@ -21,7 +21,7 @@ module SortHandler def last_messaged_conversations Message.except(:order).select( 'DISTINCT ON (conversation_id) conversation_id, id, created_at, message_type' - ).order(:conversation_id, created_at: :desc) + ).order('conversation_id, created_at DESC') end def sort_on_last_user_message_at diff --git a/app/models/contact_inbox.rb b/app/models/contact_inbox.rb index 1eb6f8793..6d034880e 100644 --- a/app/models/contact_inbox.rb +++ b/app/models/contact_inbox.rb @@ -23,7 +23,6 @@ class ContactInbox < ApplicationRecord include Pubsubable include RegexHelper - validates :inbox_id, presence: true validates :contact_id, presence: true validates :source_id, presence: true diff --git a/app/models/inbox.rb b/app/models/inbox.rb index 947b0682f..1c898ba7f 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -153,7 +153,7 @@ class Inbox < ApplicationRecord def active_bot? agent_bot_inbox&.active? || hooks.where(app_id: %w[dialogflow], - status: 'enabled').any? + status: 'enabled').count.positive? end def inbox_type diff --git a/app/models/integrations/app.rb b/app/models/integrations/app.rb index 1ede8637d..6a1378f1e 100644 --- a/app/models/integrations/app.rb +++ b/app/models/integrations/app.rb @@ -1,6 +1,5 @@ class Integrations::App include Linear::IntegrationHelper - attr_accessor :params def initialize(params) diff --git a/app/models/integrations/hook.rb b/app/models/integrations/hook.rb index cf71d021c..ca77fa13d 100644 --- a/app/models/integrations/hook.rb +++ b/app/models/integrations/hook.rb @@ -86,7 +86,7 @@ class Integrations::Hook < ApplicationRecord end def ensure_hook_type - self.hook_type ||= app.params[:hook_type] if app.present? + self.hook_type = app.params[:hook_type] if app.present? end def validate_settings_json_schema