Skip to content

Commit

Permalink
standardrb update
Browse files Browse the repository at this point in the history
  • Loading branch information
murb committed Jan 9, 2024
1 parent 62a989b commit 55f40a4
Show file tree
Hide file tree
Showing 27 changed files with 60 additions and 63 deletions.
36 changes: 17 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ GEM
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
base64 (0.1.1)
bcrypt (3.1.19)
bindex (0.8.1)
bootsnap (1.16.0)
Expand Down Expand Up @@ -280,7 +279,7 @@ GEM
activesupport (>= 5.0.0)
jsbundling-rails (1.2.1)
railties (>= 6.0.0)
json (2.6.3)
json (2.7.1)
jwt (2.2.3)
keyword_finder (0.3.1)
kramdown (2.4.0)
Expand Down Expand Up @@ -357,16 +356,16 @@ GEM
request_store (~> 1.4)
paper_trail-association_tracking (2.2.1)
paper_trail (>= 12.0)
parallel (1.23.0)
parser (3.2.2.4)
parallel (1.24.0)
parser (3.3.0.2)
ast (~> 2.4.1)
racc
pg (1.5.4)
public_suffix (5.0.4)
puma (6.4.0)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.7.1)
racc (1.7.3)
rack (2.2.8)
rack-headers_filter (0.0.1)
rack-mini-profiler (3.1.1)
Expand Down Expand Up @@ -426,7 +425,7 @@ GEM
redis-store (>= 1.2, < 2)
redis-store (1.10.0)
redis (>= 4, < 6)
regexp_parser (2.8.2)
regexp_parser (2.9.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.1.0)
Expand Down Expand Up @@ -455,23 +454,22 @@ GEM
rspec-support (3.12.1)
rspec_junit_formatter (0.6.0)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (1.56.4)
base64 (~> 0.1.1)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-ole (1.2.12.2)
ruby-progressbar (1.13.0)
ruby-vips (2.2.0)
Expand Down Expand Up @@ -542,18 +540,18 @@ GEM
net-ssh (>= 2.8.0)
ssrf_filter (1.1.2)
stackprof (0.2.25)
standard (1.31.2)
standard (1.33.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.56.4)
rubocop (~> 1.59.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-performance (~> 1.3)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
standard-performance (1.3.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
rubocop-performance (~> 1.20.1)
stimulus-rails (1.3.0)
railties (>= 6.0.0)
strip_attributes (1.13.0)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/batch/base_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def removable_fields
end

def strategy_attribute_for(field_name)
"update_#{field_name}_strategy".to_sym
:"update_#{field_name}_strategy"
end

def strategies_for(field_name)
Expand All @@ -50,7 +50,7 @@ def strategies_for(field_name)

def default_to_ignore!
self.class.batch_fields.each do |field_name|
send("#{self.class.strategy_attribute_for(field_name)}=", :IGNORE) if send(self.class.strategy_attribute_for(field_name)).nil?
send(:"#{self.class.strategy_attribute_for(field_name)}=", :IGNORE) if send(self.class.strategy_attribute_for(field_name)).nil?
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ def authentication_callbacks
end

def named_collection_url
@collection ? send("collection_#{controlled_class.table_name}_url", @collection) : send("#{controlled_class.table_name}_url")
@collection ? send(:"collection_#{controlled_class.table_name}_url", @collection) : send(:"#{controlled_class.table_name}_url")
end

def singularized_name
controlled_class.table_name.singularize
end

def named_collection_variable= values
instance_variable_set("@#{controlled_class.table_name}", values)
instance_variable_set(:"@#{controlled_class.table_name}", values)
end

def named_variable= value
instance_variable_set("@#{singularized_name}", value)
instance_variable_set(:"@#{singularized_name}", value)
end

def named_variable
instance_variable_get("@#{singularized_name}")
instance_variable_get(:"@#{singularized_name}")
end

def set_named_variable_by_class
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/works/zip_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def show_zip_response
@works.each do |work|
base_file_name = work.base_file_name
file_editions.each do |field|
if work.send("#{field}?".to_sym)
if work.send(:"#{field}?")
filename_components = [base_file_name]
filename_components << field.gsub("photo_", "") unless only_front
filename = "#{filename_components.join("_")}.jpg"
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def works_modified_forms_path options = {}
def link_to_edit item
if item.is_a? Array
item_part = item.collect { |a| a.class.model_name.singular }.join("_")
url = send("edit_#{item_part}_path".to_sym, *item)
url = send(:"edit_#{item_part}_path", *item)
name = item.last.name
else
url = send("edit_#{item.class.model_name.singular}_path".to_sym, item)
url = send(:"edit_#{item.class.model_name.singular}_path", item)
name = item.name
end
link_to name, url
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/works_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def filter_hidden field_name
def options_from_aggregation_for_select aggregation, selected = nil
html = ""
aggregation.each do |k, v|
selected_true = (selected && (selected == k) || (selected.methods.include?(:include?) && selected.collect { |a| a.to_param }.include?(k.to_param)))
selected_true = selected && (selected == k) || (selected.methods.include?(:include?) && selected.collect { |a| a.to_param }.include?(k.to_param))
html += "<option value=\"#{k.to_param}\""
html += "selected=\"selected\"" if selected_true
html += ">#{v[:name]}</option>"
Expand Down
2 changes: 1 addition & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(user)
alias_action :read_location, :edit_location, to: :manage_location

# default role settings
send("initialize_#{user.role}")
send(:"initialize_#{user.role}")

# specific cross role functionality
message_rules
Expand Down
6 changes: 3 additions & 3 deletions app/models/artist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ def to_parameters
def import!(other)
other.to_parameters.each do |k, v|
skip_name_fields = prefix? || artist_name?
empty_value = (v.nil? || v.to_s.empty?)
name_fields = ((k == "first_name") || (k == "last_name"))
empty_value = v.nil? || v.to_s.empty?
name_fields = (k == "first_name") || (k == "last_name")

if !empty_value && !(name_fields && skip_name_fields)
send("#{k}=".to_sym, v)
send(:"#{k}=", v)
end
end
educational_involvements = []
Expand Down
2 changes: 1 addition & 1 deletion app/models/batch_photo_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def couple!
if image.file_exists? && image.work
attribute = image.image_type
work = image.work
work.send("#{attribute}=".to_sym, image.file)
work.send(:"#{attribute}=", image.file)
work.save
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/collection/hierarchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def expand_with_child_collections(depth = 5)
joins(join_sql)
.select(select_sql)
.each do |intermediate_result|
(depth + 1).times { |a| ids << intermediate_result.send("_child_level#{a}".to_sym) }
(depth + 1).times { |a| ids << intermediate_result.send(:"_child_level#{a}") }
end
::Collection.unscoped.where(id: ids.compact.uniq)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/fast_aggregatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def fast_aggregations attributes
end
private def _fast_aggregate_column_values rv, attribute
self.select(attribute).group(attribute).collect { |a| a.send(attribute) }.sort_by(&:to_s).each do |a|
value = (a || Work::Search::NOT_SET_VALUE)
value = a || Work::Search::NOT_SET_VALUE
if value.is_a? String
if attribute == :grade_within_collection
value = value[0]
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/has_collection_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def collection_attributes_attributes= collection_attribute_params
# for new and create actions
def populate_collection_attributes(collection:)
collection = collection.base_collection
default_collection_attributes = collection.send("default_collection_attributes_for_#{self.class.table_name}")&.select(&:present?)
default_collection_attributes = collection.send(:"default_collection_attributes_for_#{self.class.table_name}")&.select(&:present?)
default_collection_languages = collection.supported_languages&.select(&:present?) || [:nl]

default_collection_attributes&.each do |attribute_type|
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/method_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def has_cache_for_method(*method_names)
# end
# end

define_method("cache_#{method_name}!") do |update_column = false|
define_method(:"cache_#{method_name}!") do |update_column = false|
new_cache_value = send(method_name).to_json
if update_column
update_column("#{method_name}_cache", new_cache_value)
Expand All @@ -31,7 +31,7 @@ def has_cache_for_method(*method_names)
end
end

define_method("cached_#{method_name}") do # |arg=nil| # default arg to allow before_blah callbacks
define_method(:"cached_#{method_name}") do # |arg=nil| # default arg to allow before_blah callbacks
column_value = read_attribute("#{method_name}_cache")
JSON.parse(column_value) if column_value
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/o_auth_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def oauthable?
end

def oauth_strategy
@oauth_strategy ||= "::OmniAuth::Strategies::#{oauth_provider.classify}".constantize.new(name, Rails.application.secrets.send("#{oauth_provider}_id"), Rails.application.secrets.send("#{oauth_provider}_secret"), client_options: {site: Rails.application.secrets.send("#{oauth_provider}_site")})
@oauth_strategy ||= "::OmniAuth::Strategies::#{oauth_provider.classify}".constantize.new(name, Rails.application.secrets.send(:"#{oauth_provider}_id"), Rails.application.secrets.send(:"#{oauth_provider}_secret"), client_options: {site: Rails.application.secrets.send(:"#{oauth_provider}_site")})
end

def client
Expand Down
2 changes: 1 addition & 1 deletion app/models/import_collection/class_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ImportCollection::ClassAssociation

def initialize(options = {})
options.each do |k, v|
send("#{k}=", v)
send(:"#{k}=", v)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/import_collection/workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def analyze_field_properties(field)
column = Work.columns.find { |a| a.name == property.to_s }
if column
field_type = column.type
elsif Work.instance_methods.include?(fieldname.to_sym) && Work.instance_methods.include?("#{fieldname}=".to_sym)
elsif Work.instance_methods.include?(fieldname.to_sym) && Work.instance_methods.include?(:"#{fieldname}=")
field_type = Work.new.send(fieldname).class
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def name= name
return if name.blank?
name_split = name.split(NAME_SPLITTER)
if name_split.size > 1 && !persisted?
super name_split[0].strip
super(name_split[0].strip)
self.address = name_split[1...].map(&:strip).join("\n").strip
else
super name.strip
super(name.strip)
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/report/builder_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def basic_aggregation_snippet key, postfix = "", field = nil, missing = nil
rv = {
key.to_sym => {
terms: {
field: (field || "#{key}#{postfix}"), size: 999
field: field || "#{key}#{postfix}", size: 999
}
}
}
Expand All @@ -16,9 +16,9 @@ def basic_aggregation_snippet key, postfix = "", field = nil, missing = nil

def basic_aggregation_snippet_with_missing key, postfix = "", field = nil
rv = basic_aggregation_snippet(key, postfix, field)
rv["#{key}_missing".to_sym] = {
rv[:"#{key}_missing"] = {
missing: {
field: (field || "#{key}#{postfix}")
field: field || "#{key}#{postfix}"
}
}
rv
Expand Down
2 changes: 1 addition & 1 deletion app/models/simple_artist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def id

def initialize kvs = {}
kvs.each do |k, v|
send("#{k}=", v)
send(:"#{k}=", v)
end
end

Expand Down
7 changes: 3 additions & 4 deletions app/models/time_span.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class TimeSpan < ApplicationRecord
(time_spans.starts_at <= :start AND time_spans.ends_at IS NULL) OR
(time_spans.starts_at > :start AND time_spans.starts_at < :end) OR
(time_spans.starts_at <= :start AND time_spans.status = 'active')
", {start: (period.begin || 2000.years.ago), end: (period.end || 2000.years.from_now)})
", {start: period.begin || 2000.years.ago, end: period.end || 2000.years.from_now})
}
scope :current, -> { period(Time.now...Time.now) }
scope :sold, -> { where(status: [:active, :finished]).where(classification: :purchase) }
Expand Down Expand Up @@ -143,13 +143,12 @@ def next_time_span

def current?
current_time = Time.current
(
(starts_at.nil? && ends_at.nil?) or

(starts_at.nil? && ends_at.nil?) or
(starts_at.nil? && ends_at > current_time) or
(ends_at.nil? && starts_at <= current_time) or
(starts_at <= current_time && ends_at > current_time) or
(starts_at <= current_time && status == "active")
)
end

def status= new_status
Expand Down
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ def accessible_contacts
end

def accessible_roles
@accessible_roles ||= User::ROLES.select { |role| ability.can?("update_#{role}".to_sym, User) }
@accessible_roles ||= User::ROLES.select { |role| ability.can?(:"update_#{role}", User) }
end

def role= new_role
User::ROLES.each do |r|
send("#{r}=", r.to_s == new_role.to_s) if methods.include?(r)
send(:"#{r}=", r.to_s == new_role.to_s) if methods.include?(r)
end
role
end
Expand Down Expand Up @@ -252,7 +252,7 @@ def messages_sent
def reset_all_roles
ROLES.each do |role|
unless role == :read_only # "default" role
send("#{role}=", false)
send(:"#{role}=", false)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def quick_destroy_all
end

def human_attribute_name_for_alt_number_field(field_name, collection)
custom_label_name = collection&.send("label_override_work_#{field_name}_with_inheritance".to_sym)
custom_label_name = collection&.send(:"label_override_work_#{field_name}_with_inheritance")
custom_label_name || Work.human_attribute_name(field_name)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/work/time_spans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def availability_status
end

def current_active_time_span
@current_active_time_span ||= (time_spans.reverse.find(&:current_and_active?) || time_spans.reverse.find(&:current_and_active_or_reserved?))
@current_active_time_span ||= time_spans.reverse.find(&:current_and_active?) || time_spans.reverse.find(&:current_and_active_or_reserved?)
end

def last_active_time_span
Expand Down
Loading

0 comments on commit 55f40a4

Please sign in to comment.