Skip to content

Commit

Permalink
Address some rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jan 2, 2025
1 parent 1f095fc commit 45bd59b
Show file tree
Hide file tree
Showing 33 changed files with 101 additions and 91 deletions.
2 changes: 1 addition & 1 deletion changeset/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
task default: [:ci]

desc 'Run specs in isolation'
task :"spec:isolation" do
task :'spec:isolation' do
FileList['spec/**/*_spec.rb'].each do |spec|
sh 'rspec', spec
end
Expand Down
9 changes: 5 additions & 4 deletions changeset/rom-changeset.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Gem::Specification.new do |gem|
'source_code_uri' => 'https://github.com/rom-rb/rom/tree/master/changeset',
'documentation_uri' => 'https://api.rom-rb.org/rom/',
'mailing_list_uri' => 'https://discourse.rom-rb.org/',
'bug_tracker_uri' => 'https://github.com/rom-rb/rom/issues'
'bug_tracker_uri' => 'https://github.com/rom-rb/rom/issues',
'rubygems_mfa_required' => 'true'
}

gem.add_runtime_dependency 'dry-core', '~> 1.0'
gem.add_runtime_dependency 'rom-core', '~> 5.3'
gem.add_runtime_dependency 'transproc', '~> 1.0', '>= 1.1.0'
gem.add_dependency 'dry-core', '~> 1.0'
gem.add_dependency 'rom-core', '~> 5.3'
gem.add_dependency 'transproc', '~> 1.0', '>= 1.1.0'

gem.add_development_dependency 'rake', '~> 11.2'
gem.add_development_dependency 'rspec', '~> 3.5'
Expand Down
8 changes: 4 additions & 4 deletions core/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ RSpec::Core::RakeTask.new(:spec)
task default: [:ci]

desc 'Run specs in isolation'
task :"spec:isolation" do
task :'spec:isolation' do
FileList['spec/**/*_spec.rb'].each do |spec|
sh "COVERAGE=false bundle exec rspec #{spec}"
end
end

desc 'Run CI tasks'
if RUBY_ENGINE != 'ruby'
task ci: %i[spec lint]
else
if RUBY_ENGINE == 'ruby'
task ci: %i[spec lint spec:isolation]
else
task ci: %i[spec lint]
end

Rake::TestTask.new(:lint) do |test|
Expand Down
10 changes: 5 additions & 5 deletions core/benchmarks/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def puts(*)
super unless VERIFY
end

def run(title, &block)
def run(title, &)
if VERIFY
Verifier.run(&block)
Verifier.run(&)
else
benchmark(title, &block)
benchmark(title, &)
end
end

Expand All @@ -78,8 +78,8 @@ def initialize
yield self
end

def self.run(&block)
new(&block)
def self.run(&)
new(&)
end

def report(name)
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ def meta_options_ast
private

# @api private
def method_missing(meth, *args, **kwargs, &block)
def method_missing(meth, ...)
if type.respond_to?(meth)
response = type.__send__(meth, *args, **kwargs, &block)
response = type.__send__(meth, ...)

if response.is_a?(type.class)
self.class.new(response, **options)
Expand Down
8 changes: 4 additions & 4 deletions core/lib/rom/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def [](key)
end

# @api private
def fetch_or_store(*args, &block)
cache.fetch_or_store([namespace, args.hash].hash, &block)
def fetch_or_store(*args, &)
cache.fetch_or_store([namespace, args.hash].hash, &)
end

# @api private
Expand All @@ -55,8 +55,8 @@ def [](key)
end

# @api private
def fetch_or_store(*args, &block)
objects.fetch_or_store(args.hash, &block)
def fetch_or_store(*args, &)
objects.fetch_or_store(args.hash, &)
end

# @api private
Expand Down
12 changes: 4 additions & 8 deletions core/lib/rom/command_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def visit_relation(node, parent_relation = nil)
default_mapping
end

if !other.empty?
[mapping, [type, other]]
else
if other.empty?
[mapping, type]
else
[mapping, [type, other]]
end
else
registry[name][id] = commands[name][id]
Expand Down Expand Up @@ -241,11 +241,7 @@ def setup_associates(klass, relation, _meta, parent_relation)
singular_name if relation.associations.key?(singular_name)
end

if assoc_name
klass.associates(assoc_name)
else
klass.associates(parent_relation)
end
klass.associates(assoc_name || parent_relation)
end
end
end
16 changes: 8 additions & 8 deletions core/lib/rom/commands/class_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module ClassInterface
# @api private
def inherited(klass)
super
klass.instance_variable_set(:'@before', before.dup)
klass.instance_variable_set(:'@after', after.dup)
klass.instance_variable_set(:@before, before.dup)
klass.instance_variable_set(:@after, after.dup)
end

# Sets up the base class
Expand Down Expand Up @@ -163,10 +163,10 @@ def extend_for_relation(relation)
#
# @api public
def before(*hooks)
if !hooks.empty?
set_hooks(:before, hooks)
else
if hooks.empty?
@before
else
set_hooks(:before, hooks)
end
end

Expand Down Expand Up @@ -208,10 +208,10 @@ def before(*hooks)
#
# @api public
def after(*hooks)
if !hooks.empty?
set_hooks(:after, hooks)
else
if hooks.empty?
@after
else
set_hooks(:after, hooks)
end
end

Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/commands/graph/class_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def build_command(registry, spec, other, path)
end

command = registry[relation][name]
tuple_path = Array[*path] << key
tuple_path = [*path] << key
input_proc = InputEvaluator.build(tuple_path, nodes)

command = command.curry(input_proc, opts)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/commands/graph/input_evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.extract_excluded_keys(nodes)
#
# @api private
def self.exclude_proc(excluded_keys)
-> input { input.reject { |k, _| excluded_keys.include?(k) } }
-> input { input.except(*excluded_keys) }
end

# Initialize a new input evaluator
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/commands/lazy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def respond_to_missing?(name, include_private = false)
private

# @api private
def method_missing(name, *args, **kwargs, &block)
def method_missing(name, ...)
if command.respond_to?(name)
response = command.public_send(name, *args, **kwargs, &block)
response = command.public_send(name, ...)

if response.instance_of?(command.class)
self.class.new(response, evaluator, command_proc)
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/configuration_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def relation(name, options = EMPTY_HASH, &block)
# end
#
# @api public
def commands(name, &block)
register_command(*CommandDSL.new(name, default_adapter, &block).command_classes)
def commands(name, &)
register_command(*CommandDSL.new(name, default_adapter, &).command_classes)
end

# Mapper definition DSL
Expand Down
8 changes: 4 additions & 4 deletions core/lib/rom/configuration_dsl/command_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class CommandDSL
attr_reader :relation, :adapter, :command_classes

# @api private
def initialize(relation, adapter = nil, &block)
def initialize(relation, adapter = nil, &)
@relation = relation
@adapter = adapter
@command_classes = []
instance_exec(&block)
instance_exec(&)
end

# Define a command class
Expand All @@ -27,9 +27,9 @@ def initialize(relation, adapter = nil, &block)
# @return [Class] generated class
#
# @api public
def define(name, options = EMPTY_HASH, &block)
def define(name, options = EMPTY_HASH, &)
@command_classes << Command.build_class(
name, relation, { adapter: adapter }.merge(options), &block
name, relation, { adapter: adapter }.merge(options), &
)
end
end
Expand Down
9 changes: 7 additions & 2 deletions core/lib/rom/configuration_dsl/mapper_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ def initialize(configuration, mapper_classes, block)
# @return [Class]
#
# @api public
def define(name, options = EMPTY_HASH, &block)
@defined_mappers << Mapper::Builder.build_class(name, (@mapper_classes + @defined_mappers), options, &block)
def define(name, options = EMPTY_HASH, &)
@defined_mappers << Mapper::Builder.build_class(
name,
@mapper_classes + @defined_mappers,
options,
&
)
self
end

Expand Down
8 changes: 4 additions & 4 deletions core/lib/rom/create_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def finalize(environment, setup)
# @api private
class InlineCreateContainer < CreateContainer
# @api private
def initialize(*args, &block)
def initialize(*args, &)
case args.first
when Configuration
environment = args.first.environment
Expand All @@ -53,7 +53,7 @@ def initialize(*args, &block)
environment = args.first
setup = args[1]
else
configuration = Configuration.new(*args, &block)
configuration = Configuration.new(*args, &)
environment = configuration.environment
setup = configuration.setup
end
Expand All @@ -63,7 +63,7 @@ def initialize(*args, &block)
end

# @api private
def self.container(*args, &block)
InlineCreateContainer.new(*args, &block).container
def self.container(...)
InlineCreateContainer.new(...).container
end
end
4 changes: 2 additions & 2 deletions core/lib/rom/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def disconnect
# the transaction was rolled back
#
# @api public
def transaction(opts = EMPTY_HASH, &block)
transaction_runner(opts).run(opts, &block)
def transaction(opts = EMPTY_HASH, &)
transaction_runner(opts).run(opts, &)
end

private
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def self.extended(rom)
# end
#
# @api public
def plugins(*args, &block)
PluginDSL.new(plugin_registry, *args, &block)
def plugins(...)
PluginDSL.new(plugin_registry, ...)
end

# Register adapter namespace under a specified identifier
Expand Down
8 changes: 4 additions & 4 deletions core/lib/rom/global/plugin_dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class PluginDSL
attr_reader :registry

# @api private
def initialize(registry, defaults = EMPTY_HASH, &block)
def initialize(registry, defaults = EMPTY_HASH, &)
@registry = registry
@defaults = defaults
instance_exec(&block)
instance_exec(&)
end

# Register a plugin
Expand All @@ -43,8 +43,8 @@ def register(name, mod, options = EMPTY_HASH)
# @param [Symbol] type The adapter identifier
#
# @api public
def adapter(type, &block)
self.class.new(registry, adapter: type, &block)
def adapter(type, &)
self.class.new(registry, adapter: type, &)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/mapper/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def dsl
# Delegate Attribute DSL method to the dsl instance
#
# @api private
def method_missing(name, *args, **kwargs, &block)
def method_missing(name, ...)
if dsl.respond_to?(name)
dsl.public_send(name, *args, **kwargs, &block)
dsl.public_send(name, ...)
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/open_struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def respond_to_missing?(meth, include_private = false)
private

# @api private
def method_missing(meth, *args, &block)
def method_missing(meth, *args, &)
ivar = IVAR[meth]

if instance_variables.include?(ivar)
Expand Down
4 changes: 2 additions & 2 deletions core/lib/rom/pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def decorate?(response)
end

# @api private
def method_missing(name, *args, **kwargs, &block)
def method_missing(name, ...)
if left.respond_to?(name)
response = left.__send__(name, *args, **kwargs, &block)
response = left.__send__(name, ...)

if decorate?(response)
self.class.new(response, right)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/rom/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Plugins
class << self
# @api private
def register(entity_type, plugin_type: Plugin, adapter: true)
super(entity_type, plugin_type: plugin_type, adapter: adapter)
super
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions core/lib/rom/plugins/relation/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ def instrument(*methods)
# Execute a block using instrumentation
#
# @api public
def instrument(&block)
notifications.instrument(self.class.adapter, name: name.relation, **notification_payload(self), &block)
def instrument(&)
notifications.instrument(
self.class.adapter,
name: name.relation,
**notification_payload(self),
&
)
end

private
Expand Down
3 changes: 2 additions & 1 deletion core/lib/rom/relation/combined.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def command(type, **)
if type == :create
super
else
raise NotImplementedError, "#{self.class}#command doesn't work with #{type.inspect} command type yet"
raise NotImplementedError,
"#{self.class}#command doesn't work with #{type.inspect} command type yet"
end
end

Expand Down
Loading

0 comments on commit 45bd59b

Please sign in to comment.