Skip to content

Commit e693fe2

Browse files
committed
rubocop -a
1 parent cd28e66 commit e693fe2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+545
-386
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Naming/MethodName:
8989
Naming/MethodParameterName:
9090
Enabled: false
9191

92+
Style/MultilineBlockChain:
93+
Exclude:
94+
- "spec/**/*.rb"
95+
9296
Style/MutableConstant:
9397
Exclude:
9498
- "spec/**/*.rb"

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "rspec/core/rake_task"
1+
require 'rspec/core/rake_task'
22

33
RSpec::Core::RakeTask.new(:spec)
44

lib/rom/plugins/relation/sql/auto_restrictions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def self.restriction_methods(schema)
4646
next if index.partial?
4747

4848
attributes = index.to_a
49-
meth_name = :"by_#{ attributes.map(&:name).join('_and_') }"
49+
meth_name = :"by_#{attributes.map(&:name).join("_and_")}"
5050

5151
next if generated.include?(meth_name)
5252

lib/rom/plugins/relation/sql/instrumentation.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ module Instrumentation
3131
subscribe('configuration.relations.registry.created') do |event|
3232
registry = event[:registry]
3333

34-
relations = registry.select { |_, r| r.adapter == :sql && r.respond_to?(:notifications) }.to_h
35-
db_notifications = relations.values.map { |r| [r.dataset.db, r.notifications] }.uniq.to_h
34+
relations = registry.select { |_, r|
35+
r.adapter == :sql && r.respond_to?(:notifications)
36+
}.to_h
37+
db_notifications = relations.values.map { |r|
38+
[r.dataset.db, r.notifications]
39+
}.uniq.to_h
3640

3741
db_notifications.each do |db, notifications|
3842
next if db.respond_to?(:rom_instrumentation?)

lib/rom/plugins/relation/sql/postgres/full_text_search.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ module FullTextSearch
3636
# @see https://www.postgresql.org/docs/current/textsearch.html PostgreSQL docs
3737
#
3838
# @api public
39-
def full_text_search(*args, &block)
40-
new dataset.__send__(__method__, *args, &block)
39+
def full_text_search(...)
40+
new dataset.__send__(__method__, ...)
4141
end
4242
end
4343
end
@@ -48,6 +48,8 @@ def full_text_search(*args, &block)
4848

4949
ROM.plugins do
5050
adapter :sql do
51-
register :pg_full_text_search, ROM::Plugins::Relation::SQL::Postgres::FullTextSearch, type: :relation
51+
register :pg_full_text_search,
52+
ROM::Plugins::Relation::SQL::Postgres::FullTextSearch,
53+
type: :relation
5254
end
5355
end

lib/rom/plugins/relation/sql/postgres/streaming.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ module Streaming
1313

1414
class StreamingNotSupportedError < StandardError; end
1515

16-
subscribe("configuration.gateway.connected") do |opts|
16+
subscribe('configuration.gateway.connected') do |opts|
1717
conn = opts[:connection]
1818

1919
next unless conn.database_type.to_sym == :postgres
2020

2121
next if defined?(JRUBY_VERSION)
2222

2323
begin
24-
require "sequel_pg"
24+
require 'sequel_pg'
2525
rescue LoadError
26-
raise StreamingNotSupportedError, "add sequel_pg to Gemfile to use pg_streaming"
26+
raise StreamingNotSupportedError, 'add sequel_pg to Gemfile to use pg_streaming'
2727
end
2828

2929
unless Sequel::Postgres.supports_streaming?
30-
raise StreamingNotSupportedError, "postgres version does not support streaming"
30+
raise StreamingNotSupportedError, 'postgres version does not support streaming'
3131
end
3232

3333
conn.extension(:pg_streaming)
@@ -52,7 +52,7 @@ def self.included(klass)
5252
#
5353
# @api publicY_VERSION
5454
def stream_each
55-
raise StreamingNotSupportedError, "not supported on jruby"
55+
raise StreamingNotSupportedError, 'not supported on jruby'
5656
end
5757
else
5858
# Allows you to stream returned rows one at a time, instead of
@@ -80,7 +80,7 @@ def stream_each
8080

8181
module Combined
8282
def stream_each
83-
raise StreamingNotSupportedError, "not supported on combined relations"
83+
raise StreamingNotSupportedError, 'not supported on combined relations'
8484
end
8585
end
8686

lib/rom/sql/associations/many_to_many.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def call(target: self.target)
1717

1818
schema =
1919
if left.schema.key?(foreign_key)
20-
if target != self.target
21-
target.schema.merge(join_schema)
22-
else
20+
if target == self.target
2321
left.schema.uniq.project(*columns)
22+
else
23+
target.schema.merge(join_schema)
2424
end
2525
else
2626
target_schema

lib/rom/sql/attribute.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ def in(*args)
263263
# @return [SQL::Function]
264264
#
265265
# @api public
266-
def func(&block)
267-
ProjectionDSL.new(name => self).call(&block).first
266+
def func(&)
267+
ProjectionDSL.new(name => self).call(&).first
268268
end
269269

270270
# Create a CONCAT function from the attribute
@@ -380,19 +380,19 @@ def case(mapping)
380380
#
381381
# @api private
382382
def sql_expr
383-
@sql_expr ||= (meta[:sql_expr] || to_sql_name)
383+
@sql_expr ||= meta[:sql_expr] || to_sql_name
384384
end
385385

386386
# Delegate to sql expression if it responds to a given method
387387
#
388388
# @api private
389-
def method_missing(meth, *args, &block)
389+
def method_missing(meth, *args, &)
390390
if OPERATORS.include?(meth)
391391
__cmp__(meth, args[0])
392392
elsif extensions.key?(meth)
393-
extensions[meth].(type, sql_expr, *args, &block)
393+
extensions[meth].(type, sql_expr, *args, &)
394394
elsif sql_expr.respond_to?(meth)
395-
meta(sql_expr: sql_expr.__send__(meth, *args, &block))
395+
meta(sql_expr: sql_expr.__send__(meth, *args, &))
396396
else
397397
super
398398
end

lib/rom/sql/attribute_aliasing.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def aliased(alias_name)
1919
sql_expr: alias_sql_expr(sql_expr, new_alias_name)
2020
)
2121
end
22-
alias as aliased
23-
22+
alias_method :as, :aliased
2423

2524
# Return true if this attribute is an aliased projection
2625
#
@@ -46,16 +45,18 @@ def aliased(alias_name)
4645
#
4746
# @api private
4847
def aliased_projection?
49-
self.meta[:sql_expr].is_a?(Sequel::SQL::AliasedExpression)
48+
meta[:sql_expr].is_a?(::Sequel::SQL::AliasedExpression)
5049
end
5150

5251
private
5352

5453
# @api private
5554
def alias_sql_expr(sql_expr, new_alias)
5655
case sql_expr
57-
when Sequel::SQL::AliasedExpression
58-
Sequel::SQL::AliasedExpression.new(sql_expr.expression, new_alias, sql_expr.columns)
56+
when ::Sequel::SQL::AliasedExpression
57+
::Sequel::SQL::AliasedExpression.new(
58+
sql_expr.expression, new_alias, sql_expr.columns
59+
)
5960
else
6061
sql_expr.as(new_alias)
6162
end
@@ -70,7 +71,7 @@ def extract_alias_names(alias_name)
7071
# attribute in a way that will map the the requested alias name.
7172
# Without this, the attribute will silently ignore the requested alias
7273
# name and default to the pre-existing name.
73-
new_name = "#{meta[:wrapped]}_#{options[:alias]}".to_sym
74+
new_name = :"#{meta[:wrapped]}_#{options[:alias]}"
7475

7576
# Essentially, this makes it so "wrapped" attributes aren't true
7677
# aliases, in that we actually alias the wrapped attribute, we use

lib/rom/sql/commands/create.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ def multi_insert(tuples)
6060
# Yields tuples for insertion or return an enumerator
6161
#
6262
# @api private
63-
def with_input_tuples(tuples)
64-
input_tuples = Array([tuples]).flatten(1).map
63+
def with_input_tuples(tuples, &)
64+
input_tuples = [tuples].flatten(1).map
6565
return input_tuples unless block_given?
66-
input_tuples.each { |tuple| yield(tuple) }
66+
67+
input_tuples.each(&)
6768
end
6869
end
6970
end

0 commit comments

Comments
 (0)