From 5294a11d46a29072883a2253a52f38126cdcc174 Mon Sep 17 00:00:00 2001 From: aminedhobb Date: Tue, 28 Jan 2025 17:06:03 +0100 Subject: [PATCH] adapt code to new rubocop rules --- .rubocop.yml | 3 +++ app/controllers/api/v1/users_controller.rb | 2 +- app/controllers/archives_controller.rb | 4 ++-- app/controllers/brevo/mail_webhooks_controller.rb | 2 +- app/controllers/brevo/sms_webhooks_controller.rb | 3 ++- app/controllers/carnet_de_bord/carnets_controller.rb | 2 +- .../category_configurations_controller.rb | 2 +- .../csv_export_authorizations_controller.rb | 2 +- app/controllers/concerns/before_action_override.rb | 4 ++-- app/controllers/concerns/users/filterable.rb | 6 +++--- app/controllers/file_configurations_controller.rb | 2 +- app/controllers/follow_ups_controller.rb | 12 ++---------- app/controllers/invitations_controller.rb | 4 ++-- .../messages_configurations_controller.rb | 8 ++++---- app/controllers/notifications_controller.rb | 2 +- app/controllers/organisations_controller.rb | 4 ++-- app/controllers/participations_controller.rb | 2 +- .../super_admins/webhook_endpoints_controller.rb | 2 +- app/controllers/tags_controller.rb | 2 +- app/controllers/users/orientations_controller.rb | 4 ++-- .../users/parcours_documents_controller.rb | 8 ++++---- .../users/referent_assignations_controller.rb | 2 +- app/controllers/users/searches_controller.rb | 4 ++-- app/controllers/users/tag_assignations_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/controllers/users_organisations_controller.rb | 2 +- app/dashboards/unavailable_creneau_log_dashboard.rb | 4 ++-- app/jobs/concerns/locked_jobs.rb | 4 ++-- app/jobs/destroy_old_ressources_job.rb | 6 +++--- ...ve_organisation_users_for_expired_archives_job.rb | 2 +- app/lib/redis_connection.rb | 4 ++-- .../logger/formatters/custom_log_formatter.rb | 2 +- app/models/flash_message.rb | 2 +- app/models/invitation.rb | 2 +- app/models/rdv_solidarites/rdv.rb | 2 +- app/models/user.rb | 2 +- .../compute_follow_up_seen_rate_within_delays.rb | 2 +- config/application.rb | 4 ++-- config/initializers/sidekiq.rb | 2 +- .../rdv_solidarites/process_agent_role_job_spec.rb | 1 - spec/rails_helper.rb | 2 +- spec/support/assets_build.rb | 4 ++-- 42 files changed, 66 insertions(+), 71 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 90bf4ebb7..39882aa7c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -47,6 +47,9 @@ Style/StringConcatenation: Style/SymbolArray: Enabled: false +Style/SafeNavigationChainLength: + Max: 3 + Rails/SkipsModelValidations: Enabled: false diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index a6bed88a3..dde3fdd57 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -99,7 +99,7 @@ def motif_category_attributes end def user_params - params.require(:user).permit(*PERMITTED_USER_PARAMS).to_h.deep_symbolize_keys + params.expect(user: [*PERMITTED_USER_PARAMS]).to_h.deep_symbolize_keys end def set_organisation diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index be0a07c17..748197189 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -49,11 +49,11 @@ def destroy # rubocop:disable Metrics/AbcSize private def archive_params - params.require(:archive).permit(:archiving_reason, :user_id, :organisation_id).to_h.deep_symbolize_keys + params.expect(archive: [:archiving_reason, :user_id, :organisation_id]).to_h.deep_symbolize_keys end def create_many_params - params.require(:archives).permit(:user_id, :archiving_reason, organisation_ids: []).to_h.deep_symbolize_keys + params.expect(archives: [:user_id, :archiving_reason, { organisation_ids: [] }]).to_h.deep_symbolize_keys end def set_user diff --git a/app/controllers/brevo/mail_webhooks_controller.rb b/app/controllers/brevo/mail_webhooks_controller.rb index 2f447dfed..6208ea483 100644 --- a/app/controllers/brevo/mail_webhooks_controller.rb +++ b/app/controllers/brevo/mail_webhooks_controller.rb @@ -22,7 +22,7 @@ def record_identifier end def brevo_webhook_params - params.permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(*PERMITTED_PARAMS).to_h.deep_symbolize_keys end end end diff --git a/app/controllers/brevo/sms_webhooks_controller.rb b/app/controllers/brevo/sms_webhooks_controller.rb index 927c7ca2b..c6edf2cb0 100644 --- a/app/controllers/brevo/sms_webhooks_controller.rb +++ b/app/controllers/brevo/sms_webhooks_controller.rb @@ -20,7 +20,8 @@ def record_identifier end def brevo_webhook_params - params.permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(*PERMITTED_PARAMS).to_h.deep_symbolize_keys end end end + diff --git a/app/controllers/carnet_de_bord/carnets_controller.rb b/app/controllers/carnet_de_bord/carnets_controller.rb index b5764efb8..70aba729c 100644 --- a/app/controllers/carnet_de_bord/carnets_controller.rb +++ b/app/controllers/carnet_de_bord/carnets_controller.rb @@ -22,7 +22,7 @@ def create private def carnet_params - params.require(:carnet).permit(:user_id, :department_id) + params.expect(carnet: [:user_id, :department_id]) end def set_user diff --git a/app/controllers/category_configurations_controller.rb b/app/controllers/category_configurations_controller.rb index 107395f69..d760d1819 100644 --- a/app/controllers/category_configurations_controller.rb +++ b/app/controllers/category_configurations_controller.rb @@ -63,7 +63,7 @@ def destroy private def category_configuration_params - params.require(:category_configuration).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(category_configuration: PERMITTED_PARAMS).to_h.deep_symbolize_keys end def formatted_configuration_params diff --git a/app/controllers/concerns/agent_roles/csv_export_authorizations_controller.rb b/app/controllers/concerns/agent_roles/csv_export_authorizations_controller.rb index 5024361f8..451dcce5c 100644 --- a/app/controllers/concerns/agent_roles/csv_export_authorizations_controller.rb +++ b/app/controllers/concerns/agent_roles/csv_export_authorizations_controller.rb @@ -41,7 +41,7 @@ def set_authorized_agent_role_ids end def csv_export_authorizations_params - params.require(:csv_export_authorizations).permit(:organisation_id, agent_role_ids: []) + params.expect(csv_export_authorizations: [:organisation_id, { agent_role_ids: [] }]) end def set_organisation diff --git a/app/controllers/concerns/before_action_override.rb b/app/controllers/concerns/before_action_override.rb index e58c2caec..3440d466b 100644 --- a/app/controllers/concerns/before_action_override.rb +++ b/app/controllers/concerns/before_action_override.rb @@ -32,7 +32,7 @@ def before_action(*names, &block) end end - def method_missing(method_name, *args) + def method_missing(method_name, *) return super unless method_name.to_s.end_with?("for_#{action_name}") splitted_method_name = method_name.to_s.split("_") @@ -42,7 +42,7 @@ def method_missing(method_name, *args) if respond_to?(matching_method, true) send(matching_method) else - super(matching_method, *args) + super(matching_method, *) end end diff --git a/app/controllers/concerns/users/filterable.rb b/app/controllers/concerns/users/filterable.rb index db61d4c75..a9c9823f3 100644 --- a/app/controllers/concerns/users/filterable.rb +++ b/app/controllers/concerns/users/filterable.rb @@ -46,7 +46,7 @@ def filter_users_by_orientation_type .joins(orientations: :orientation_type) .where(orientation_types: { name: params[:orientation_type] }) .where(orientations: { organisations: { department_id: current_department_id } }) - .where("orientations.starts_at <= ?", Time.zone.now) + .where(orientations: { starts_at: ..Time.zone.now }) .where("orientations.ends_at IS NULL OR orientations.ends_at >= ?", Time.zone.now) end @@ -85,7 +85,7 @@ def filter_users_by_creation_date_after def filter_users_by_creation_date_before return if params[:creation_date_before].blank? - @users = @users.where("users.created_at < ?", params[:creation_date_before].to_date.end_of_day) + @users = @users.where(users: { created_at: ...params[:creation_date_before].to_date.end_of_day }) end def filter_users_by_convocation_date_before @@ -93,7 +93,7 @@ def filter_users_by_convocation_date_before @users = @users.joins(participations: :notifications) .where(participations: { convocable: true, follow_up: @follow_ups }) - .where("notifications.created_at < ?", params[:convocation_date_before].to_date.end_of_day) + .where(notifications: { created_at: ...params[:convocation_date_before].to_date.end_of_day }) end def filter_users_by_convocation_date_after diff --git a/app/controllers/file_configurations_controller.rb b/app/controllers/file_configurations_controller.rb index b8862432c..c167743cc 100644 --- a/app/controllers/file_configurations_controller.rb +++ b/app/controllers/file_configurations_controller.rb @@ -53,7 +53,7 @@ def update private def file_configuration_params - params.require(:file_configuration).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(file_configuration: PERMITTED_PARAMS) end def formatted_params diff --git a/app/controllers/follow_ups_controller.rb b/app/controllers/follow_ups_controller.rb index af63be39b..9ccb8f846 100644 --- a/app/controllers/follow_ups_controller.rb +++ b/app/controllers/follow_ups_controller.rb @@ -1,10 +1,6 @@ class FollowUpsController < ApplicationController - PERMITTED_PARAMS = [:user_id, :motif_category_id].freeze - - before_action :set_user, only: [:create] - def create - @follow_up = FollowUp.new(**follow_up_params) + @follow_up = FollowUp.new(follow_up_params) authorize @follow_up if save_follow_up.success? redirect_to request.referer @@ -16,11 +12,7 @@ def create private def follow_up_params - params.require(:follow_up).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys - end - - def set_user - @user = policy_scope(User).preload(:archives).find(follow_up_params[:user_id]) + params.expect(follow_up: [:user_id, :motif_category_id]) end def save_follow_up diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 138443b5b..585e0e828 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -50,8 +50,8 @@ def redirect private def invitation_params - params.require(:invitation).permit( - :format, :rdv_solidarites_lieu_id, { motif_category: [:id] } + params.expect( + invitation: [:format, :rdv_solidarites_lieu_id, { motif_category: [:id] }] ).to_h.deep_symbolize_keys end diff --git a/app/controllers/messages_configurations_controller.rb b/app/controllers/messages_configurations_controller.rb index 5d8769b52..48583f4b8 100644 --- a/app/controllers/messages_configurations_controller.rb +++ b/app/controllers/messages_configurations_controller.rb @@ -17,7 +17,7 @@ def edit; end def create @messages_configuration = MessagesConfiguration.new(organisation: @organisation) - @messages_configuration.assign_attributes(**formatted_params) + @messages_configuration.assign_attributes(formatted_params) if @messages_configuration.save flash.now[:success] = "Les réglages ont été modifiés avec succès" redirect_to organisation_category_configurations_path(@organisation) @@ -28,7 +28,7 @@ def create end def update - @messages_configuration.assign_attributes(**formatted_params) + @messages_configuration.assign_attributes(formatted_params) if @messages_configuration.save flash.now[:success] = "Les réglages ont été modifiés avec succès" render :show @@ -41,13 +41,13 @@ def update private def messages_configuration_params - params.require(:messages_configuration).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(messages_configuration: PERMITTED_PARAMS) end def formatted_params # we nullify some blank params messages_configuration_params.to_h do |k, v| - [k, k.in?([:sms_sender_name, :letter_sender_name, :sender_city]) ? v.presence : v] + [k, k.to_sym.in?([:sms_sender_name, :letter_sender_name, :sender_city]) ? v.presence : v] end end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 23328b664..2bb005d01 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -24,7 +24,7 @@ def set_participation end def notification_params - params.require(:notification).permit(:format, :event) + params.expect(notification: [:format, :event]) end def notify_participation diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 0dae0b9ac..8c7a86790 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -20,7 +20,7 @@ def show; end def edit; end def update - @organisation.assign_attributes(**organisation_params) + @organisation.assign_attributes(organisation_params) authorize @organisation if update_organisation.success? render :show @@ -62,7 +62,7 @@ def search private def organisation_params - params.require(:organisation).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(organisation: PERMITTED_PARAMS) end def set_organisation diff --git a/app/controllers/participations_controller.rb b/app/controllers/participations_controller.rb index 87f18fa5f..4c65169d3 100644 --- a/app/controllers/participations_controller.rb +++ b/app/controllers/participations_controller.rb @@ -23,6 +23,6 @@ def set_participation end def participation_params - params.require(:participation).permit(:status) + params.expect(participation: [:status]) end end diff --git a/app/controllers/super_admins/webhook_endpoints_controller.rb b/app/controllers/super_admins/webhook_endpoints_controller.rb index d9e23e378..0436ef6dd 100644 --- a/app/controllers/super_admins/webhook_endpoints_controller.rb +++ b/app/controllers/super_admins/webhook_endpoints_controller.rb @@ -18,7 +18,7 @@ def duplicate private def webhook_endpoint_params - params.require(:webhook_endpoint).permit(:target_id) + params.expect(webhook_endpoint: [:target_id]) end end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index c71fd736e..346fe7fac 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -30,6 +30,6 @@ def set_organisation end def tag_params - params.require(:tag).permit(:value) + params.expect(tag: [:value]) end end diff --git a/app/controllers/users/orientations_controller.rb b/app/controllers/users/orientations_controller.rb index 7d1e5a214..dd2741477 100644 --- a/app/controllers/users/orientations_controller.rb +++ b/app/controllers/users/orientations_controller.rb @@ -35,8 +35,8 @@ def destroy private def orientation_params - params.require(:orientation).permit(:starts_at, :ends_at, :orientation_type_id, - :organisation_id, :agent_id) + params.expect(orientation: [:starts_at, :ends_at, :orientation_type_id, + :organisation_id, :agent_id]) end def set_user diff --git a/app/controllers/users/parcours_documents_controller.rb b/app/controllers/users/parcours_documents_controller.rb index d2bb5bc9d..d23d17483 100644 --- a/app/controllers/users/parcours_documents_controller.rb +++ b/app/controllers/users/parcours_documents_controller.rb @@ -41,10 +41,10 @@ def destroy private def parcours_document_params - params.require(:parcours_document) - .permit(:type, :file, :user_id, :document_date) - .merge(agent: current_agent, user: @user) - .merge(department: current_department) + params + .expect(parcours_document: [:type, :file, :user_id, :document_date]) + .merge(agent: current_agent, user: @user) + .merge(department: current_department) end def set_parcours_document diff --git a/app/controllers/users/referent_assignations_controller.rb b/app/controllers/users/referent_assignations_controller.rb index da53c1c08..05d44c2e3 100644 --- a/app/controllers/users/referent_assignations_controller.rb +++ b/app/controllers/users/referent_assignations_controller.rb @@ -31,7 +31,7 @@ def destroy private def referent_assignation_params - params.require(:referent_assignation).permit(:agent_email, :agent_id) + params.expect(referent_assignation: [:agent_email, :agent_id]) end def agent_id diff --git a/app/controllers/users/searches_controller.rb b/app/controllers/users/searches_controller.rb index 86bf7a228..54ab93dac 100644 --- a/app/controllers/users/searches_controller.rb +++ b/app/controllers/users/searches_controller.rb @@ -52,8 +52,8 @@ def search_in_department_organisations end def users_params - params.require(:users).permit( - nirs: [], department_internal_ids: [], uids: [], emails: [], phone_numbers: [] + params.expect( + users: [nirs: [], department_internal_ids: [], uids: [], emails: [], phone_numbers: []] ).to_h.deep_symbolize_keys end diff --git a/app/controllers/users/tag_assignations_controller.rb b/app/controllers/users/tag_assignations_controller.rb index 3cd16aea7..69cf6422e 100644 --- a/app/controllers/users/tag_assignations_controller.rb +++ b/app/controllers/users/tag_assignations_controller.rb @@ -32,7 +32,7 @@ def set_user end def tag_assignation_params - params.require(:tag_assignation).permit(tag_ids: []) + params.expect(tag_assignation: [tag_ids: []]) end def department diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 59a22f7dc..1924115a6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -82,7 +82,7 @@ def update private def user_params - params.require(:user).permit(*PERMITTED_PARAMS).to_h.deep_symbolize_keys + params.expect(user: PERMITTED_PARAMS).to_h.deep_symbolize_keys end def restricted_user_attributes = UserPolicy.restricted_user_attributes_for(user: @user, agent: current_agent) diff --git a/app/controllers/users_organisations_controller.rb b/app/controllers/users_organisations_controller.rb index 77fa42a10..1dd15a735 100644 --- a/app/controllers/users_organisations_controller.rb +++ b/app/controllers/users_organisations_controller.rb @@ -35,7 +35,7 @@ def destroy private def users_organisation_params - params.require(:users_organisation).permit(:organisation_id, :user_id) + params.expect(users_organisation: [:organisation_id, :user_id]) end def user_id diff --git a/app/dashboards/unavailable_creneau_log_dashboard.rb b/app/dashboards/unavailable_creneau_log_dashboard.rb index dfcb698a5..f81e8cef5 100644 --- a/app/dashboards/unavailable_creneau_log_dashboard.rb +++ b/app/dashboards/unavailable_creneau_log_dashboard.rb @@ -20,8 +20,8 @@ class UnavailableCreneauLogDashboard < Administrate::BaseDashboard FORM_ATTRIBUTES = %i[].freeze COLLECTION_FILTERS = { - created_before: ->(resources, value) { resources.where("created_at <= ?", value) }, - created_after: ->(resources, value) { resources.where("created_at >= ?", value) } + created_before: ->(resources, value) { resources.where(created_at: ..value) }, + created_after: ->(resources, value) { resources.where(created_at: value..) } }.freeze def display_resource(unavailable_creneau_log) diff --git a/app/jobs/concerns/locked_jobs.rb b/app/jobs/concerns/locked_jobs.rb index 0c6262ef0..e22ed6a8d 100644 --- a/app/jobs/concerns/locked_jobs.rb +++ b/app/jobs/concerns/locked_jobs.rb @@ -7,11 +7,11 @@ module LockedJobs private - def perform_with_lock(&block) + def perform_with_lock(&) # if the lock is not available, we raise an WithAdvisoryLock::FailedToAcquireLockError # and the job will be retried ActiveRecord::Base.with_advisory_lock!( - self.class.lock_key(*arguments), timeout_seconds: 0, &block + self.class.lock_key(*arguments), timeout_seconds: 0, & ) end diff --git a/app/jobs/destroy_old_ressources_job.rb b/app/jobs/destroy_old_ressources_job.rb index f42bca098..72ad5ec7c 100644 --- a/app/jobs/destroy_old_ressources_job.rb +++ b/app/jobs/destroy_old_ressources_job.rb @@ -12,7 +12,7 @@ def destroy_inactive_users # rubocop:disable Metrics/MethodLength # we check the orgs because being added to an organisation is a sign that the user is in an active process inactive_users = User.left_outer_joins(:invitations, :participations, :users_organisations) - .where("users.created_at < ?", date_limit) + .where(users: { created_at: ...date_limit }) .where("NOT EXISTS ( SELECT 1 FROM invitations @@ -38,7 +38,7 @@ def destroy_inactive_users # rubocop:disable Metrics/MethodLength end def destroy_useless_rdvs - useless_rdvs = Rdv.where.missing(:participations).where("rdvs.created_at < ?", date_limit) + useless_rdvs = Rdv.where.missing(:participations).where(rdvs: { created_at: ...date_limit }) # On envoit pas de webhook de destroy rgpd pour les rdvs du département 13 bdr_rdv_ids = useless_rdvs.joins(organisation: :department) @@ -60,7 +60,7 @@ def destroy_useless_rdvs def destroy_useless_notifications # notifications with no participation_id are useless code-wise, so we can clean them manually - useless_notifications = Notification.where(participation_id: nil).where("created_at < ?", date_limit).destroy_all + useless_notifications = Notification.where(participation_id: nil).where(created_at: ...date_limit).destroy_all MattermostClient.send_to_notif_channel( "🚮 Les notifications suivantes ont été supprimées automatiquement : " \ diff --git a/app/jobs/remove_organisation_users_for_expired_archives_job.rb b/app/jobs/remove_organisation_users_for_expired_archives_job.rb index 6cf362734..e7b85b251 100644 --- a/app/jobs/remove_organisation_users_for_expired_archives_job.rb +++ b/app/jobs/remove_organisation_users_for_expired_archives_job.rb @@ -9,7 +9,7 @@ def perform private def expired_archives - Archive.where("created_at < ?", 2.years.ago) + Archive.where(created_at: ...2.years.ago) end def notify_on_mattermost diff --git a/app/lib/redis_connection.rb b/app/lib/redis_connection.rb index ada76929e..c625d7cb1 100644 --- a/app/lib/redis_connection.rb +++ b/app/lib/redis_connection.rb @@ -3,7 +3,7 @@ module RedisConnection Redis.new(url: Rails.configuration.x.redis_url) end - def self.with_redis(&block) - CONNECTION_POOL.with(&block) + def self.with_redis(&) + CONNECTION_POOL.with(&) end end diff --git a/app/lib/sidekiq/logger/formatters/custom_log_formatter.rb b/app/lib/sidekiq/logger/formatters/custom_log_formatter.rb index 1ec413f06..a759904d4 100644 --- a/app/lib/sidekiq/logger/formatters/custom_log_formatter.rb +++ b/app/lib/sidekiq/logger/formatters/custom_log_formatter.rb @@ -11,7 +11,7 @@ def call(severity, time, program_name, message) # rubocop:enable Layout/LineLength message = filter_message(message) if message.include?("Job raised exception") - super(severity, time, program_name, message) + super end private diff --git a/app/models/flash_message.rb b/app/models/flash_message.rb index c451d3ef8..458099ba9 100644 --- a/app/models/flash_message.rb +++ b/app/models/flash_message.rb @@ -5,7 +5,7 @@ def self.from_type_and_value(value, type:) if value.is_a?(String) new(description: value, type:) elsif value.is_a?(Hash) - new(**value.deep_symbolize_keys.merge(type:)) + new(**value.deep_symbolize_keys, type:) else raise ArgumentError, "Invalid flash message value: #{value}" end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 11eb8d257..e1ffab8ad 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -31,7 +31,7 @@ class Invitation < ApplicationRecord after_commit :set_follow_up_status scope :valid, -> { where("expires_at > ?", Time.zone.now).or(never_expire) } - scope :expired, -> { where("expires_at <= ?", Time.zone.now) } + scope :expired, -> { where(expires_at: ..Time.zone.now) } scope :expireable, -> { where.not(expires_at: nil) } scope :never_expire, -> { where(expires_at: nil) } diff --git a/app/models/rdv_solidarites/rdv.rb b/app/models/rdv_solidarites/rdv.rb index 392c5ae9c..6e5bc8d85 100644 --- a/app/models/rdv_solidarites/rdv.rb +++ b/app/models/rdv_solidarites/rdv.rb @@ -9,7 +9,7 @@ class Rdv < Base delegate :presential?, :collectif?, :motif_category, to: :motif def initialize(attributes = {}) - super(attributes) + super end def users diff --git a/app/models/user.rb b/app/models/user.rb index 18fa0652a..0f6b55501 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -194,7 +194,7 @@ def tag_users_attributes=(attributes) attributes.uniq! { |attr| attr["tag_id"] } attributes.reject! { |attr| tag_users.any? { |tu| tu.tag_id == attr["tag_id"] } } - super(attributes) + super end private diff --git a/app/services/stats/compute_follow_up_seen_rate_within_delays.rb b/app/services/stats/compute_follow_up_seen_rate_within_delays.rb index dbe05f0df..4789de9a2 100644 --- a/app/services/stats/compute_follow_up_seen_rate_within_delays.rb +++ b/app/services/stats/compute_follow_up_seen_rate_within_delays.rb @@ -64,7 +64,7 @@ def mature_seen_follow_ups def mature_follow_ups # Ignore recent follow-ups as we can't determine if they'll meet the delay criteria yet @mature_follow_ups ||= follow_ups - .where("follow_ups.created_at < ?", target_delay_days.days.ago) + .where(follow_ups: { created_at: ...target_delay_days.days.ago }) end end end diff --git a/config/application.rb b/config/application.rb index 17ba953c9..52d17c272 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 7.1 - config.autoload_paths += Dir[Rails.root.join("app/models/concerns/validators")] + config.autoload_paths += Rails.root.glob("app/models/concerns/validators") # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading @@ -20,7 +20,7 @@ class Application < Rails::Application config.time_zone = "Paris" config.i18n.available_locales = [:fr, :en] config.i18n.default_locale = :fr - config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.{rb,yml}")] + config.i18n.load_path += Rails.root.glob("config/locales/**/*.{rb,yml}") config.exceptions_app = routes config.active_storage.draw_routes = false if Rails.env.production? diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 3c4ac9c83..a280d85a5 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,6 +1,6 @@ require "sidekiq" -Dir[Rails.root.join("app/lib/sidekiq/**/*.rb")].each do |file| +Rails.root.glob("app/lib/sidekiq/**/*.rb").each do |file| require file end diff --git a/spec/jobs/inbound_webhooks/rdv_solidarites/process_agent_role_job_spec.rb b/spec/jobs/inbound_webhooks/rdv_solidarites/process_agent_role_job_spec.rb index d6f732ed9..1a4a2c75f 100644 --- a/spec/jobs/inbound_webhooks/rdv_solidarites/process_agent_role_job_spec.rb +++ b/spec/jobs/inbound_webhooks/rdv_solidarites/process_agent_role_job_spec.rb @@ -117,7 +117,6 @@ let!(:organisation) { create(:organisation, rdv_solidarites_organisation_id: 2131) } it "does not remove the agent from the org" do - subject expect { subject }.not_to change(AgentRole, :count) end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index d5379bf72..fab0db65d 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -20,7 +20,7 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Rails.root.glob("spec/support/**/*.rb").each { |f| require f } # Calls Sidekiq::Testing.fake! which fakes pushing jobs to Redis require "sidekiq/testing" diff --git a/spec/support/assets_build.rb b/spec/support/assets_build.rb index fb11fe809..73ac81196 100644 --- a/spec/support/assets_build.rb +++ b/spec/support/assets_build.rb @@ -8,9 +8,9 @@ # We only run this if feature specs are being run elsif config.files_to_run.any? { |file| file.include?("/spec/features/") } - source_files = Dir[Rails.root.join("app/javascript/**/*.{js,jsx,css,scss,sass}")] + source_files = Rails.root.glob("app/javascript/**/*.{js,jsx,css,scss,sass}") - built_assets = Dir[Rails.root.join("app/assets/builds/*.{js,css}")] + built_assets = Rails.root.glob("app/assets/builds/*.{js,css}") source_last_modified = source_files.map { |f| File.mtime(f) }.max