mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
c4b944a273
commit
bbbc861f71
20 changed files with 49 additions and 40 deletions
|
@ -253,6 +253,9 @@ Performance/BindCall:
|
|||
Performance/FlatMap:
|
||||
Enabled: true
|
||||
|
||||
Performance/MapCompact:
|
||||
Enabled: true
|
||||
|
||||
Performance/RedundantMerge:
|
||||
Enabled: true
|
||||
|
||||
|
|
16
Gemfile.lock
16
Gemfile.lock
|
@ -221,6 +221,9 @@ GEM
|
|||
tzinfo
|
||||
event_emitter (0.2.6)
|
||||
eventmachine (1.2.7)
|
||||
eventmachine (1.2.7-java)
|
||||
eventmachine (1.2.7-x64-mingw32)
|
||||
eventmachine (1.2.7-x86-mingw32)
|
||||
execjs (2.7.0)
|
||||
faraday (1.3.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
|
@ -288,12 +291,14 @@ GEM
|
|||
hiredis (0.6.3)
|
||||
hiredis (0.6.3-java)
|
||||
http_parser.rb (0.6.0)
|
||||
http_parser.rb (0.6.0-java)
|
||||
httpclient (2.8.3)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
image_processing (1.12.1)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
ruby-vips (>= 2.0.17, < 3)
|
||||
jar-dependencies (0.4.1)
|
||||
jdbc-mysql (5.1.47)
|
||||
jdbc-postgres (42.2.14)
|
||||
jdbc-sqlite3 (3.28.0)
|
||||
|
@ -305,6 +310,7 @@ GEM
|
|||
mustache
|
||||
nokogiri
|
||||
libxml-ruby (3.2.1)
|
||||
libxml-ruby (3.2.1-x64-mingw32)
|
||||
listen (3.5.1)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
|
@ -361,7 +367,11 @@ GEM
|
|||
ast (~> 2.4.1)
|
||||
path_expander (1.1.0)
|
||||
pg (1.2.3)
|
||||
pg (1.2.3-x64-mingw32)
|
||||
pg (1.2.3-x86-mingw32)
|
||||
psych (3.3.1)
|
||||
psych (3.3.1-java)
|
||||
jar-dependencies (>= 0.1.7)
|
||||
public_suffix (4.0.6)
|
||||
puma (5.2.2)
|
||||
nio4r (~> 2.0)
|
||||
|
@ -417,7 +427,7 @@ GEM
|
|||
retriable (3.1.2)
|
||||
rexml (3.2.5)
|
||||
rouge (3.26.0)
|
||||
rubocop (1.12.1)
|
||||
rubocop (1.13.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
|
@ -430,8 +440,8 @@ GEM
|
|||
parser (>= 2.7.1.5)
|
||||
rubocop-packaging (0.5.1)
|
||||
rubocop (>= 0.89, < 2.0)
|
||||
rubocop-performance (1.10.2)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-performance (1.11.0)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.9.1)
|
||||
activesupport (>= 4.2.0)
|
||||
|
|
|
@ -130,7 +130,7 @@ module ActionDispatch
|
|||
states = "function tt() { return #{to_json}; }"
|
||||
|
||||
fun_routes = paths.sample(3).map do |ast|
|
||||
ast.map { |n|
|
||||
ast.filter_map { |n|
|
||||
case n
|
||||
when Nodes::Symbol
|
||||
case n.left
|
||||
|
@ -143,7 +143,7 @@ module ActionDispatch
|
|||
else
|
||||
nil
|
||||
end
|
||||
}.compact.join
|
||||
}.join
|
||||
end
|
||||
|
||||
stylesheets = [fsm_css]
|
||||
|
|
|
@ -31,7 +31,7 @@ module ActionText
|
|||
|
||||
def encryptable_rich_texts
|
||||
@encryptable_rich_texts ||= self.class.rich_text_association_names
|
||||
.collect { |attribute_name| send(attribute_name) }.compact
|
||||
.filter_map { |attribute_name| send(attribute_name) }
|
||||
.find_all { |record| record.is_a?(ActionText::EncryptedRichText) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -793,9 +793,9 @@ module ActionView
|
|||
|
||||
def extract_values_from_collection(collection, value_method, selected)
|
||||
if selected.is_a?(Proc)
|
||||
collection.map do |element|
|
||||
collection.filter_map do |element|
|
||||
element.public_send(value_method) if selected.call(element)
|
||||
end.compact
|
||||
end
|
||||
else
|
||||
selected
|
||||
end
|
||||
|
|
|
@ -399,7 +399,7 @@ module ActiveModel
|
|||
|
||||
def attribute_method_matchers_matching(method_name)
|
||||
attribute_method_matchers_cache.compute_if_absent(method_name) do
|
||||
attribute_method_matchers.map { |matcher| matcher.match(method_name) }.compact
|
||||
attribute_method_matchers.filter_map { |matcher| matcher.match(method_name) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ module ActiveModel
|
|||
|
||||
private
|
||||
def setup!(klass)
|
||||
klass.attr_reader(*attributes.map do |attribute|
|
||||
klass.attr_reader(*attributes.filter_map do |attribute|
|
||||
:"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation")
|
||||
end.compact)
|
||||
end)
|
||||
|
||||
klass.attr_writer(*attributes.map do |attribute|
|
||||
klass.attr_writer(*attributes.filter_map do |attribute|
|
||||
:"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation=")
|
||||
end.compact)
|
||||
end)
|
||||
end
|
||||
|
||||
def confirmation_value_equal?(record, attribute, value, confirmed)
|
||||
|
|
|
@ -46,9 +46,9 @@ module ActiveRecord
|
|||
|
||||
def likely_reflections
|
||||
parent_classes = parent.target_classes
|
||||
parent_classes.map do |parent_klass|
|
||||
parent_classes.filter_map do |parent_klass|
|
||||
parent_klass._reflect_on_association(@association)
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
def root?
|
||||
|
|
|
@ -498,10 +498,10 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def build_fixture_statements(fixture_set)
|
||||
fixture_set.map do |table_name, fixtures|
|
||||
fixture_set.filter_map do |table_name, fixtures|
|
||||
next if fixtures.empty?
|
||||
build_fixture_sql(fixtures, table_name)
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
def build_truncate_statement(table_name)
|
||||
|
|
|
@ -787,14 +787,13 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
# Gather up all of the SET variables...
|
||||
variable_assignments = variables.map do |k, v|
|
||||
variable_assignments = variables.filter_map do |k, v|
|
||||
if defaults.include?(v)
|
||||
"@@SESSION.#{k} = DEFAULT" # Sets the value to the global or compile default
|
||||
elsif !v.nil?
|
||||
"@@SESSION.#{k} = #{quote(v)}"
|
||||
end
|
||||
# or else nil; compact to clear nils out
|
||||
end.compact.join(", ")
|
||||
end.join(", ")
|
||||
|
||||
# ...and send them all in one query
|
||||
execute("SET #{encoding} #{sql_mode_assignment} #{variable_assignments}", "SCHEMA")
|
||||
|
|
|
@ -917,9 +917,7 @@ module ActiveRecord
|
|||
WHERE t.typname IN (%s)
|
||||
SQL
|
||||
coders = execute_and_clear(query, "SCHEMA", []) do |result|
|
||||
result
|
||||
.map { |row| construct_coder(row, coders_by_name[row["typname"]]) }
|
||||
.compact
|
||||
result.filter_map { |row| construct_coder(row, coders_by_name[row["typname"]]) }
|
||||
end
|
||||
|
||||
map = PG::TypeMapByOid.new
|
||||
|
|
|
@ -6,7 +6,7 @@ module ActiveRecord
|
|||
module SchemaStatements # :nodoc:
|
||||
# Returns an array of indexes for the given table.
|
||||
def indexes(table_name)
|
||||
exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", "SCHEMA").map do |row|
|
||||
exec_query("PRAGMA index_list(#{quote_table_name(table_name)})", "SCHEMA").filter_map do |row|
|
||||
# Indexes SQLite creates implicitly for internal use start with "sqlite_".
|
||||
# See https://www.sqlite.org/fileformat2.html#intschema
|
||||
next if row["name"].start_with?("sqlite_")
|
||||
|
@ -49,7 +49,7 @@ module ActiveRecord
|
|||
where: where,
|
||||
orders: orders
|
||||
)
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
def add_foreign_key(from_table, to_table, **options)
|
||||
|
|
|
@ -796,11 +796,11 @@ module ActiveRecord
|
|||
# We check defined?(@attributes) not to issue warnings if the object is
|
||||
# allocated but not initialized.
|
||||
inspection = if defined?(@attributes) && @attributes
|
||||
self.class.attribute_names.collect do |name|
|
||||
self.class.attribute_names.filter_map do |name|
|
||||
if _has_attribute?(name)
|
||||
"#{name}: #{attribute_for_inspect(name)}"
|
||||
end
|
||||
end.compact.join(", ")
|
||||
end.join(", ")
|
||||
else
|
||||
"not initialized"
|
||||
end
|
||||
|
|
|
@ -196,11 +196,11 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def touch_model_timestamps_unless(&block)
|
||||
model.timestamp_attributes_for_update_in_model.map do |column_name|
|
||||
model.timestamp_attributes_for_update_in_model.filter_map do |column_name|
|
||||
if touch_timestamp_attribute?(column_name)
|
||||
"#{column_name}=(CASE WHEN (#{updatable_columns.map(&block).join(" AND ")}) THEN #{model.quoted_table_name}.#{column_name} ELSE CURRENT_TIMESTAMP END),"
|
||||
end
|
||||
end.compact.join
|
||||
end.join
|
||||
end
|
||||
|
||||
def raw_update_sql
|
||||
|
|
|
@ -1159,13 +1159,13 @@ module ActiveRecord
|
|||
def migrations_status # :nodoc:
|
||||
db_list = schema_migration.normalized_versions
|
||||
|
||||
file_list = migration_files.map do |file|
|
||||
file_list = migration_files.filter_map do |file|
|
||||
version, name, scope = parse_migration_filename(file)
|
||||
raise IllegalMigrationNameError.new(file) unless version
|
||||
version = schema_migration.normalize_migration_number(version)
|
||||
status = db_list.delete(version) ? "up" : "down"
|
||||
[status, version, (name + scope).humanize]
|
||||
end.compact
|
||||
end
|
||||
|
||||
db_list.map! do |version|
|
||||
["up", version, "********** NO FILE **********"]
|
||||
|
|
|
@ -94,7 +94,7 @@ module ActiveRecord
|
|||
sslcapath: "--ssl-capath",
|
||||
sslcipher: "--ssl-cipher",
|
||||
sslkey: "--ssl-key"
|
||||
}.map { |opt, arg| "#{arg}=#{configuration_hash[opt]}" if configuration_hash[opt] }.compact
|
||||
}.filter_map { |opt, arg| "#{arg}=#{configuration_hash[opt]}" if configuration_hash[opt] }
|
||||
|
||||
args
|
||||
end
|
||||
|
|
|
@ -148,8 +148,7 @@ module ActiveRecord
|
|||
|
||||
def max_updated_column_timestamp
|
||||
timestamp_attributes_for_update_in_model
|
||||
.map { |attr| self[attr]&.to_time }
|
||||
.compact
|
||||
.filter_map { |attr| self[attr]&.to_time }
|
||||
.max
|
||||
end
|
||||
|
||||
|
|
|
@ -75,11 +75,11 @@ class Hash
|
|||
#
|
||||
# This method is also aliased as +to_param+.
|
||||
def to_query(namespace = nil)
|
||||
query = collect do |key, value|
|
||||
query = filter_map do |key, value|
|
||||
unless (value.is_a?(Hash) || value.is_a?(Array)) && value.empty?
|
||||
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
query.sort! unless namespace.to_s.include?("[]")
|
||||
query.join("&")
|
||||
|
|
|
@ -45,13 +45,13 @@ module TestUnit # :nodoc:
|
|||
def attributes_hash
|
||||
return {} if attributes_names.empty?
|
||||
|
||||
attributes_names.map do |name|
|
||||
attributes_names.filter_map do |name|
|
||||
if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
|
||||
["#{name}", "'secret'"]
|
||||
elsif !virtual?(name)
|
||||
["#{name}", "@#{singular_table_name}.#{name}"]
|
||||
end
|
||||
end.compact.sort.to_h
|
||||
end.sort.to_h
|
||||
end
|
||||
|
||||
def boolean?(name)
|
||||
|
|
|
@ -54,11 +54,11 @@ namespace :zeitwerk do
|
|||
end
|
||||
|
||||
require "active_support/core_ext/object/try"
|
||||
eager_load_paths = Rails.configuration.eager_load_namespaces.map do |eln|
|
||||
eager_load_paths = Rails.configuration.eager_load_namespaces.filter_map do |eln|
|
||||
# Quick regression fix for 6.0.3 to support namespaces that do not have
|
||||
# eager load paths, like the recently added i18n. I'll rewrite this task.
|
||||
eln.try(:config).try(:eager_load_paths)
|
||||
end.compact.flatten
|
||||
end.flatten
|
||||
|
||||
not_checked = ActiveSupport::Dependencies.autoload_paths - eager_load_paths
|
||||
not_checked.select! { |dir| Dir.exist?(dir) }
|
||||
|
|
Loading…
Reference in a new issue