From 358ae8b5dd6f6cbb8961c819c0a13cda2cd23003 Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Thu, 5 Dec 2024 13:23:38 -0600 Subject: [PATCH] Update Standard Ruby and comply --- Gemfile.lock | 37 ++++++++---- .../concerns/resolvers/submissionable.rb | 2 +- app/graphql/resolvers/offer_resolver.rb | 2 +- app/helpers/submissions_helper.rb | 2 +- app/helpers/utm_params_helper.rb | 2 +- app/mailers/admin_mailer.rb | 24 ++++---- app/mailers/partner_mailer.rb | 6 +- app/mailers/user_mailer.rb | 56 +++++++++---------- app/models/concerns/percentize.rb | 6 +- app/models/offer.rb | 2 +- app/models/submission.rb | 4 +- .../application_controller_renderer.rb | 1 + config/initializers/backtrace_silencers.rb | 1 + .../initializers/content_security_policy.rb | 1 + config/initializers/inflections.rb | 1 + config/initializers/mime_types.rb | 1 + config/initializers/permissions_policy.rb | 1 + .../mutations/add_user_to_submission_spec.rb | 10 ++-- 18 files changed, 89 insertions(+), 70 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 062710558..09784eedc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -254,6 +254,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.9.0) jwt (2.2.3) kaminari (1.2.1) activesupport (>= 4.1.0) @@ -271,6 +272,8 @@ GEM rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) listen (3.4.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -444,20 +447,21 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.10.2) - rubocop (1.14.0) + rubocop (1.68.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.5.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) + unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.36.2) parser (>= 3.3.1.0) - rubocop-performance (1.11.2) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + rubocop-performance (1.22.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) ruby_parser (3.15.1) @@ -530,9 +534,18 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - standard (1.1.1) - rubocop (= 1.14.0) - rubocop-performance (= 1.11.2) + standard (1.42.1) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.68.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.5) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.5.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.22.0) temple (0.8.2) thor (1.3.2) tilt (2.4.0) diff --git a/app/graphql/resolvers/concerns/resolvers/submissionable.rb b/app/graphql/resolvers/concerns/resolvers/submissionable.rb index ad14a3410..f2a551f6f 100644 --- a/app/graphql/resolvers/concerns/resolvers/submissionable.rb +++ b/app/graphql/resolvers/concerns/resolvers/submissionable.rb @@ -37,7 +37,7 @@ def external_submission_id end def compute_error - return IdsNotPassed unless ids_passed? + IdsNotPassed unless ids_passed? end def ids_passed? diff --git a/app/graphql/resolvers/offer_resolver.rb b/app/graphql/resolvers/offer_resolver.rb index 201fd6a4e..23b593941 100644 --- a/app/graphql/resolvers/offer_resolver.rb +++ b/app/graphql/resolvers/offer_resolver.rb @@ -24,7 +24,7 @@ def run private def compute_error - return BadArgumentError unless admin? || partner? || user? + BadArgumentError unless admin? || partner? || user? end def validate_user(offer) diff --git a/app/helpers/submissions_helper.rb b/app/helpers/submissions_helper.rb index 807f4ffc6..17088e2ed 100644 --- a/app/helpers/submissions_helper.rb +++ b/app/helpers/submissions_helper.rb @@ -129,7 +129,7 @@ def formatted_minimum_price_for_email(submission) def artist_supply_priority(is_p1: false, target_supply: false, **) return "P1" if is_p1 - return "P2" if target_supply + "P2" if target_supply end def assignable_admin?(user) diff --git a/app/helpers/utm_params_helper.rb b/app/helpers/utm_params_helper.rb index 03ce9c881..0ad2b2658 100644 --- a/app/helpers/utm_params_helper.rb +++ b/app/helpers/utm_params_helper.rb @@ -1,7 +1,7 @@ module UtmParamsHelper def utm_params(source:, campaign:, **args) initial = {utm_campaign: campaign, utm_medium: "email", utm_source: source} - transformed_args = args.each_with_object({}) { |(key, value), obj| obj["utm_#{key}".to_sym] = value } + transformed_args = args.each_with_object({}) { |(key, value), obj| obj[:"utm_#{key}"] = value } initial.merge(transformed_args) end diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 941ed44fa..d7c538446 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -16,9 +16,9 @@ def submission(submission:, user:, artist:) ) smtpapi category: %w[submission], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: Convection.config.admin_email_address, subject: "Submission ##{@submission.id}" @@ -33,9 +33,9 @@ def submission_approved(submission:, artist:) assigned_admin = AdminUser.find_by(gravity_user_id: submission.assigned_to) smtpapi category: %w[submission], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: assigned_admin.email, @@ -51,9 +51,9 @@ def submission_resubmitted(submission:, artist:) assigned_admin = AdminUser.find_by(gravity_user_id: submission.assigned_to) smtpapi category: %w[submission], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: assigned_admin.email, @@ -72,9 +72,9 @@ def artwork_updated(submission:, artwork_data:, changes: nil, image_added: nil) @image_added = image_added smtpapi category: %w[submission], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: assigned_admin.email, diff --git a/app/mailers/partner_mailer.rb b/app/mailers/partner_mailer.rb index e95f4a98a..cb5d63251 100644 --- a/app/mailers/partner_mailer.rb +++ b/app/mailers/partner_mailer.rb @@ -21,9 +21,9 @@ def submission_digest( content: "sub-digest-auction" ) smtpapi category: %w[submission_digest], - unique_args: { - partner_name: partner_name - } + unique_args: { + partner_name: partner_name + } current_date = Time.now.utc.strftime("%B %-d") mail( diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index a7b28c493..ce8dae358 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -16,9 +16,9 @@ def submission_receipt(submission:, artist:) ) smtpapi category: %w[submission_receipt], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: submission.email, subject: "Thank you for submitting your artwork to Artsy", @@ -35,9 +35,9 @@ def first_upload_reminder(submission:) ) smtpapi category: %w[first_upload_reminder], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail to: submission.email, subject: "You're Almost Done" end @@ -50,11 +50,11 @@ def second_upload_reminder(submission:) ) smtpapi category: %w[second_upload_reminder], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail to: submission.email, - subject: "Artsy Consignments - complete your submission" + subject: "Artsy Consignments - complete your submission" end def submission_approved(submission:, artist:) @@ -69,9 +69,9 @@ def submission_approved(submission:, artist:) ) smtpapi category: %w[submission_approved], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail( to: submission.email, subject: "Artsy Approved Submission | Next Steps" @@ -90,9 +90,9 @@ def artist_submission_rejected(submission:, artist:) ) smtpapi category: %w[artist_submission_rejected], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail(to: submission.email, subject: "An update about your submission") end @@ -108,9 +108,9 @@ def fake_submission_rejected(submission:, artist:) ) smtpapi category: %w[fake_submission_rejected], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail(to: submission.email, subject: "Artsy Submission") end @@ -128,9 +128,9 @@ def nsv_bsv_submission_rejected(submission:, artist:, logged_in:) ) smtpapi category: %w[nsv_bsv_submission_rejected], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } title = submission.title || "Unknown" artist_name = artist&.name subject = "Update on \"#{title}\" #{artist_name ? "by #{artist_name}" : ""}" @@ -150,9 +150,9 @@ def non_target_supply_artist_rejected(submission:, artist:) ) smtpapi category: %w[non_target_supply_artist_rejected], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail(to: submission.email, subject: "An update about your submission") end @@ -168,9 +168,9 @@ def other_submission_rejected(submission:, artist:) ) smtpapi category: %w[other_submission_rejected], - unique_args: { - submission_id: submission.id - } + unique_args: { + submission_id: submission.id + } mail(to: submission.email, subject: "An update about your submission") end diff --git a/app/models/concerns/percentize.rb b/app/models/concerns/percentize.rb index 6ad8e8f4b..6ea9e373a 100644 --- a/app/models/concerns/percentize.rb +++ b/app/models/concerns/percentize.rb @@ -9,15 +9,15 @@ module Percentize class_methods do def percentize(*method_names) method_names.each do |method_name| - attribute "#{method_name}_whole".to_sym + attribute :"#{method_name}_whole" - define_method "#{method_name}_whole" do + define_method :"#{method_name}_whole" do return if self[method_name].blank? (self[method_name] * 100).round(2) end - define_method "#{method_name}_whole=" do |percent_whole| + define_method :"#{method_name}_whole=" do |percent_whole| if percent_whole.blank? self[method_name] = nil else diff --git a/app/models/offer.rb b/app/models/offer.rb index 9ed8f4a86..29217e66e 100644 --- a/app/models/offer.rb +++ b/app/models/offer.rb @@ -82,7 +82,7 @@ def set_state # defines methods sent?, accepted?, etc. for each possible offer state STATES.each do |method| - define_method "#{method}?".to_sym do + define_method :"#{method}?" do state == method end end diff --git a/app/models/submission.rb b/app/models/submission.rb index c58d3783b..582ce0300 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -117,7 +117,7 @@ def sale_state end def sorted_images - images.sort_by.with_index { |a, i| a == primary_image ? -1 : i } + images.sort_by.with_index { |a, i| (a == primary_image) ? -1 : i } end def as_json(options = {}) @@ -170,7 +170,7 @@ def thumbnail # defines methods submitted?, approved?, etc. for each possible submission state STATES.each do |method| - define_method "#{method}?".to_sym do + define_method :"#{method}?" do state == method end end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index f4556db39..6d56e4390 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index d0f0d3b5d..4b63f2893 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 98230c980..87fd451f0 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index aa7435fbc..dc8474221 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 6e1d16f02..be6fedc53 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 50bcf4ead..810aadeb9 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Define an application-wide HTTP permissions policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # diff --git a/spec/requests/api/graphql/mutations/add_user_to_submission_spec.rb b/spec/requests/api/graphql/mutations/add_user_to_submission_spec.rb index 4c8869618..ab09ebda2 100644 --- a/spec/requests/api/graphql/mutations/add_user_to_submission_spec.rb +++ b/spec/requests/api/graphql/mutations/add_user_to_submission_spec.rb @@ -22,7 +22,7 @@ mutation = <<-GRAPHQL mutation { - addUserToSubmission(input: { id: \"#{submission.uuid}\" }) { + addUserToSubmission(input: { id: "#{submission.uuid}" }) { clientMutationId consignmentSubmission { externalId @@ -46,7 +46,7 @@ mutation = <<-GRAPHQL mutation { - addUserToSubmission(input: { id: \"#{submission.uuid}\" }) { + addUserToSubmission(input: { id: "#{submission.uuid}" }) { clientMutationId consignmentSubmission { externalId @@ -68,7 +68,7 @@ mutation = <<-GRAPHQL mutation { - addUserToSubmission(input: { id: \"#{submission.uuid}\" }) { + addUserToSubmission(input: { id: "#{submission.uuid}" }) { clientMutationId consignmentSubmission { externalId @@ -94,7 +94,7 @@ mutation = <<-GRAPHQL mutation { - addUserToSubmission(input: { id: \"#{submission.uuid}\" }) { + addUserToSubmission(input: { id: "#{submission.uuid}" }) { clientMutationId consignmentSubmission { externalId @@ -120,7 +120,7 @@ mutation = <<-GRAPHQL mutation { - addUserToSubmission(input: { id: \"#{submission.id}\" }) { + addUserToSubmission(input: { id: "#{submission.id}" }) { clientMutationId consignmentSubmission { externalId