From eaedaa96bb872f82c3dd982184792b5a99ff9c06 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 2 Apr 2026 12:48:28 +0300 Subject: [PATCH] fix rubocop --- .rubocop.yml | 9 +++++++++ app/controllers/api/templates_clone_controller.rb | 2 +- app/controllers/esign_settings_controller.rb | 2 +- app/controllers/submissions_controller.rb | 2 +- .../templates_clone_and_replace_controller.rb | 2 +- app/controllers/templates_clone_controller.rb | 2 +- app/controllers/templates_controller.rb | 2 +- app/controllers/templates_debug_controller.rb | 2 +- app/controllers/templates_preferences_controller.rb | 4 ++-- app/controllers/templates_preview_controller.rb | 2 +- app/views/submission_events/index.html.erb | 4 ++-- app/views/submissions/show.html.erb | 2 +- app/views/submit_form/show.html.erb | 2 +- lib/generate_certificate.rb | 2 +- lib/params/base_validator.rb | 4 ++-- lib/submissions/generate_audit_trail.rb | 6 +++--- lib/submissions/generate_export_files.rb | 2 +- lib/submitters/serialize_for_api.rb | 4 ++-- lib/submitters/serialize_for_webhook.rb | 2 +- lib/templates/detect_fields.rb | 4 ++-- lib/templates/image_to_fields.rb | 2 +- lib/templates/replace_attachments.rb | 2 +- 22 files changed, 37 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9be296e5..02967126 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,6 +51,15 @@ Style/NumericPredicate: Style/MinMaxComparison: Enabled: false +Style/EmptyClassDefinition: + Enabled: false + +Style/OneClassPerFile: + Enabled: false + +Layout/MultilineMethodCallIndentation: + Enabled: false + Naming/PredicateMethod: Enabled: false diff --git a/app/controllers/api/templates_clone_controller.rb b/app/controllers/api/templates_clone_controller.rb index d87a2eb1..f8da7f92 100644 --- a/app/controllers/api/templates_clone_controller.rb +++ b/app/controllers/api/templates_clone_controller.rb @@ -9,7 +9,7 @@ module Api ActiveRecord::Associations::Preloader.new( records: [@template], - associations: [schema_documents: :preview_images_attachments] + associations: [{ schema_documents: :preview_images_attachments }] ).call cloned_template = Templates::Clone.call( diff --git a/app/controllers/esign_settings_controller.rb b/app/controllers/esign_settings_controller.rb index 81c75fae..78630f45 100644 --- a/app/controllers/esign_settings_controller.rb +++ b/app/controllers/esign_settings_controller.rb @@ -3,7 +3,7 @@ class EsignSettingsController < ApplicationController DEFAULT_CERT_NAME = 'DocuSeal Self-Host Autogenerated' - CertFormRecord = Struct.new(:name, :file, :password, keyword_init: true) do + CertFormRecord = Struct.new(:name, :file, :password) do include ActiveModel::Validations def to_key diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index d0caf466..2e1bba67 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -26,7 +26,7 @@ class SubmissionsController < ApplicationController unless @submission.submitters.all?(&:completed_at?) ActiveRecord::Associations::Preloader.new( records: [@submission], - associations: [submitters: :start_form_submission_events] + associations: [{ submitters: :start_form_submission_events }] ).call end diff --git a/app/controllers/templates_clone_and_replace_controller.rb b/app/controllers/templates_clone_and_replace_controller.rb index 2d7c7782..de64d86d 100644 --- a/app/controllers/templates_clone_and_replace_controller.rb +++ b/app/controllers/templates_clone_and_replace_controller.rb @@ -8,7 +8,7 @@ class TemplatesCloneAndReplaceController < ApplicationController ActiveRecord::Associations::Preloader.new( records: [@template], - associations: [schema_documents: :preview_images_attachments] + associations: [{ schema_documents: :preview_images_attachments }] ).call cloned_template = Templates::Clone.call(@template, author: current_user) diff --git a/app/controllers/templates_clone_controller.rb b/app/controllers/templates_clone_controller.rb index 51a4de28..d001087f 100644 --- a/app/controllers/templates_clone_controller.rb +++ b/app/controllers/templates_clone_controller.rb @@ -12,7 +12,7 @@ class TemplatesCloneController < ApplicationController def create ActiveRecord::Associations::Preloader.new( records: [@base_template], - associations: [schema_documents: :preview_images_attachments] + associations: [{ schema_documents: :preview_images_attachments }] ).call @template = Templates::Clone.call(@base_template, author: current_user, diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index e402f53a..2adb18b3 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -29,7 +29,7 @@ class TemplatesController < ApplicationController def edit ActiveRecord::Associations::Preloader.new( records: [@template], - associations: [schema_documents: [:blob, { preview_images_attachments: :blob }]] + associations: [{ schema_documents: [:blob, { preview_images_attachments: :blob }] }] ).call @template_data = diff --git a/app/controllers/templates_debug_controller.rb b/app/controllers/templates_debug_controller.rb index 54fa23e1..333e8847 100644 --- a/app/controllers/templates_debug_controller.rb +++ b/app/controllers/templates_debug_controller.rb @@ -30,7 +30,7 @@ class TemplatesDebugController < ApplicationController ActiveRecord::Associations::Preloader.new( records: [@template], - associations: [schema_documents: { preview_images_attachments: :blob }] + associations: [{ schema_documents: { preview_images_attachments: :blob } }] ).call @template_data = diff --git a/app/controllers/templates_preferences_controller.rb b/app/controllers/templates_preferences_controller.rb index 49041cfc..80865e94 100644 --- a/app/controllers/templates_preferences_controller.rb +++ b/app/controllers/templates_preferences_controller.rb @@ -58,8 +58,8 @@ class TemplatesPreferencesController < ApplicationController default_expire_at_duration shared_link_2fa default_expire_at request_email_enabled completed_notification_email_subject completed_notification_email_body completed_notification_email_enabled completed_notification_email_attach_audit] + - [completed_message: %i[title body], - submitters: [%i[uuid request_email_subject request_email_body]], link_form_fields: []] + [{ completed_message: %i[title body], + submitters: [%i[uuid request_email_subject request_email_body]], link_form_fields: [] }] ).tap do |attrs| attrs[:preferences].delete(:submitters) if params[:request_email_per_submitter] != '1' diff --git a/app/controllers/templates_preview_controller.rb b/app/controllers/templates_preview_controller.rb index b9325bfa..e132b131 100644 --- a/app/controllers/templates_preview_controller.rb +++ b/app/controllers/templates_preview_controller.rb @@ -6,7 +6,7 @@ class TemplatesPreviewController < ApplicationController def show ActiveRecord::Associations::Preloader.new( records: [@template], - associations: [schema_documents: { preview_images_attachments: :blob }] + associations: [{ schema_documents: { preview_images_attachments: :blob } }] ).call @template_data = diff --git a/app/views/submission_events/index.html.erb b/app/views/submission_events/index.html.erb index 7dc604c9..cfc13e58 100644 --- a/app/views/submission_events/index.html.erb +++ b/app/views/submission_events/index.html.erb @@ -20,7 +20,7 @@ <% end %>

- <% submitter_versions_index = @submission.submitters.preload(:submitter_versions).each_with_object({}) { |s, h| h[s.id] = s.submitter_versions.to_a.sort_by(&:created_at) } %> + <% submitter_versions_index = @submission.submitters.preload(:submitter_versions).to_h { |s| [s.id, s.submitter_versions.to_a.sort_by(&:created_at)] } %> <% @submission.submission_events.order(:event_timestamp).each do |event| %> <% submitter = @submission.submitters.find { |e| e.id == event.submitter_id } %> <% bg_class = event_colors[submitters_uuids.index(submitter.uuid) % event_colors.length] %> @@ -47,7 +47,7 @@ <% elsif event.event_type == 'invite_party' && (invited_submitter = @submission.submitters.find { |e| e.uuid == event.data['uuid'] }) && (name = @submission.template_submitters.find { |e| e['uuid'] == event.data['uuid'] }&.dig('name')) %> <%= t('submission_event_names.invite_party_by_html', invited_submitter_name: [invited_submitter.name || invited_submitter.email || invited_submitter.phone, name].join(' '), submitter_name:) %> <% elsif event.event_type == 'delegate_form' %> - <% delegate_from = event.data['old_email'].presence || versions.reverse.find { |v| v.created_at <= event.event_timestamp }&.then { |v| v.name || v.phone } %> + <% delegate_from = event.data['old_email'].presence || versions.rfind { |v| v.created_at <= event.event_timestamp }&.then { |v| v.name || v.phone } %> <%= t('submission_event_names.delegate_form_by_html', from: delegate_from, to: event.data['email']) %> <% elsif event.event_type.include?('send_') %> <%= t("submission_event_names.#{event.event_type}_to_html", submitter_name:) %> diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 3d113368..f925f6ce 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -96,7 +96,7 @@ <% submitters_index = @submission.submitters.index_by(&:uuid) %> <% submitters_order_index = nil %> <% attachments_index = ActiveStorage::Attachment.where(record: @submission.submitters, name: :attachments).preload(:blob).index_by(&:uuid) %> - <% page_blob_struct = Struct.new(:url, :metadata, keyword_init: true) %> + <% page_blob_struct = Struct.new(:url, :metadata) %> <% bg_classes = %w[bg-red-100 bg-sky-100 bg-emerald-100 bg-yellow-100 bg-purple-100 bg-pink-100 bg-cyan-100 bg-orange-100 bg-lime-100 bg-indigo-100] %> <% schema.each do |item| %> <% document = @submission.schema_documents.find { |e| e.uuid == item['attachment_uuid'] } %> diff --git a/app/views/submit_form/show.html.erb b/app/views/submit_form/show.html.erb index 85db38ef..949f6d1d 100644 --- a/app/views/submit_form/show.html.erb +++ b/app/views/submit_form/show.html.erb @@ -5,7 +5,7 @@ <% fields_index = Templates.build_field_areas_index(@submitter.submission.template_fields || @submitter.submission.template.fields) %> <% values = @submitter.submission.submitters.reduce({}) { |acc, sub| acc.merge(sub.values) } %> <% submitters_index = @submitter.submission.submitters.index_by(&:uuid) %> -<% page_blob_struct = Struct.new(:url, :metadata, keyword_init: true) %> +<% page_blob_struct = Struct.new(:url, :metadata) %> <% schema = Submissions.filtered_conditions_schema(@submitter.submission, values:, include_submitter_uuid: @submitter.uuid) %> <% font_scale = 1000.0 / PdfUtils::US_LETTER_W %> <% decline_modal_checkbox_uuid = nil %> diff --git a/lib/generate_certificate.rb b/lib/generate_certificate.rb index e8463705..4803c69b 100644 --- a/lib/generate_certificate.rb +++ b/lib/generate_certificate.rb @@ -3,7 +3,7 @@ module GenerateCertificate SIZE = 2**11 - Pkcs12Struct = Struct.new(:certificate, :ca_certs, keyword_init: true) + Pkcs12Struct = Struct.new(:certificate, :ca_certs) module_function diff --git a/lib/params/base_validator.rb b/lib/params/base_validator.rb index cd0005f6..d9a23ce6 100644 --- a/lib/params/base_validator.rb +++ b/lib/params/base_validator.rb @@ -92,7 +92,7 @@ module Params def in_path(params, path = [], skip_blank: false) old_path = @current_path - @current_path = [old_path, *path].compact_blank.map(&:to_s).join('.') + @current_path = [old_path, *path].compact_blank.join('.') param = params.dig(*path) param = nil if skip_blank && param.blank? @@ -106,7 +106,7 @@ module Params old_path = @current_path params.dig(*path)&.each_with_index do |item, index| - @current_path = [old_path, [*path].map(&:to_s).join('.') + "[#{index}]"].compact_blank.join('.') + @current_path = [old_path, [*path].join('.') + "[#{index}]"].compact_blank.join('.') yield item if item end diff --git a/lib/submissions/generate_audit_trail.rb b/lib/submissions/generate_audit_trail.rb index 794d0dc7..82d79dd2 100644 --- a/lib/submissions/generate_audit_trail.rb +++ b/lib/submissions/generate_audit_trail.rb @@ -438,8 +438,8 @@ module Submissions composer.text(I18n.t('event_log'), font_size: 12, padding: [10, 0, 20, 0]) - submitter_versions_index = submission.submitters.preload(:submitter_versions).each_with_object({}) do |s, h| - h[s.id] = s.submitter_versions.to_a.sort_by(&:created_at) + submitter_versions_index = submission.submitters.preload(:submitter_versions).to_h do |s| + [s.id, s.submitter_versions.to_a.sort_by(&:created_at)] end events_data = submission.submission_events.sort_by(&:event_timestamp).filter_map do |event| @@ -475,7 +475,7 @@ module Submissions ].join("\n") elsif event.event_type == 'delegate_form' from = event.data['old_email'].presence || - versions.reverse.find { |v| v.created_at <= event.event_timestamp }&.then { |v| v.name || v.phone } + versions.rfind { |v| v.created_at <= event.event_timestamp }&.then { |v| v.name || v.phone } I18n.t('submission_event_names.delegate_form_by_html', from:, to: event.data['email']) elsif event.event_type.include?('send_') I18n.t("submission_event_names.#{event.event_type}_to_html", submitter_name:) diff --git a/lib/submissions/generate_export_files.rb b/lib/submissions/generate_export_files.rb index b2b8f076..23bc843d 100644 --- a/lib/submissions/generate_export_files.rb +++ b/lib/submissions/generate_export_files.rb @@ -58,7 +58,7 @@ module Submissions end def build_table_rows(submissions, expires_at: nil) - submissions.preload(submitters: [attachments_attachments: :blob, documents_attachments: :blob]) + submissions.preload(submitters: [{ attachments_attachments: :blob, documents_attachments: :blob }]) .find_each.map do |submission| submission_data = [] submitters_count = submission.submitters.size diff --git a/lib/submitters/serialize_for_api.rb b/lib/submitters/serialize_for_api.rb index b8df4be0..db76b3c8 100644 --- a/lib/submitters/serialize_for_api.rb +++ b/lib/submitters/serialize_for_api.rb @@ -15,9 +15,9 @@ module Submitters ActiveRecord::Associations::Preloader.new( records: [submitter], associations: if with_documents - [documents_attachments: :blob, attachments_attachments: :blob] + [{ documents_attachments: :blob, attachments_attachments: :blob }] elsif with_values - [attachments_attachments: :blob] + [{ attachments_attachments: :blob }] end ).call diff --git a/lib/submitters/serialize_for_webhook.rb b/lib/submitters/serialize_for_webhook.rb index c19b8537..4eb7a715 100644 --- a/lib/submitters/serialize_for_webhook.rb +++ b/lib/submitters/serialize_for_webhook.rb @@ -12,7 +12,7 @@ module Submitters def call(submitter, expires_at: Accounts.link_expires_at(Account.new(id: submitter.account_id))) ActiveRecord::Associations::Preloader.new( - records: [submitter], associations: [documents_attachments: :blob, attachments_attachments: :blob] + records: [submitter], associations: [{ documents_attachments: :blob, attachments_attachments: :blob }] ).call values = build_values_array(submitter, expires_at:) diff --git a/lib/templates/detect_fields.rb b/lib/templates/detect_fields.rb index 4419d57e..a0c81334 100755 --- a/lib/templates/detect_fields.rb +++ b/lib/templates/detect_fields.rb @@ -4,7 +4,7 @@ module Templates module DetectFields module_function - TextFieldBox = Struct.new(:x, :y, :w, :h, keyword_init: true) do + TextFieldBox = Struct.new(:x, :y, :w, :h) do def endy @endy ||= y + h end @@ -14,7 +14,7 @@ module Templates end end - PageNode = Struct.new(:prev, :next, :elem, :page, :attachment_uuid, keyword_init: true) + PageNode = Struct.new(:prev, :next, :elem, :page, :attachment_uuid) DATE_REGEXP = / (?: diff --git a/lib/templates/image_to_fields.rb b/lib/templates/image_to_fields.rb index 2da4b925..c25bd2fe 100755 --- a/lib/templates/image_to_fields.rb +++ b/lib/templates/image_to_fields.rb @@ -4,7 +4,7 @@ module Templates module ImageToFields module_function - Field = Struct.new(:type, :x, :y, :w, :h, :confidence, keyword_init: true) do + Field = Struct.new(:type, :x, :y, :w, :h, :confidence) do def endy @endy ||= y + h end diff --git a/lib/templates/replace_attachments.rb b/lib/templates/replace_attachments.rb index 91984206..5edaee24 100644 --- a/lib/templates/replace_attachments.rb +++ b/lib/templates/replace_attachments.rb @@ -34,7 +34,7 @@ module Templates if index.positive? && pdf_fields.present? preview_document = template.schema[index - 1] - preview_document_last_field = template.fields.reverse.find do |f| + preview_document_last_field = template.fields.rfind do |f| f['areas']&.any? do |a| a['attachment_uuid'] == preview_document[:attachment_uuid] end