Skip to content

Commit

Permalink
feat: enable Naming/BlockForwarding and Style/ArgumentsForwarding
Browse files Browse the repository at this point in the history
… rubocop rules
  • Loading branch information
ymtdzzz committed Feb 5, 2025
1 parent 711be26 commit 22fb6d6
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 32 deletions.
5 changes: 2 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ Metrics/PerceivedComplexity:
Naming/FileName:
Exclude:
- '**/opentelemetry-*'
### TODO: Enable this is a separate PR
Naming/BlockForwarding:
Enabled: false
Enabled: true
Style/ArgumentsForwarding:
Enabled: false
Enabled: true
#######################
Style/Documentation:
Exclude:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
end
end

def with_configuration(values, &block)
def with_configuration(values, &)
original_config = instrumentation.instance_variable_get(:@config)
modified_config = original_config.merge(values)
instrumentation.instance_variable_set(:@config, modified_config)
Expand All @@ -126,14 +126,14 @@ def with_configuration(values, &block)
instrumentation.instance_variable_set(:@config, original_config)
end

def subscribing_to_deliver(&block)
def subscribing_to_deliver(&)
subscription = OpenTelemetry::Instrumentation::ActionMailer::Railtie.subscribe_to_deliver
yield
ensure
ActiveSupport::Notifications.unsubscribe(subscription)
end

def subscribing_to_process(&block)
def subscribing_to_process(&)
subscription = OpenTelemetry::Instrumentation::ActionMailer::Railtie.subscribe_to_process
yield
ensure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class << base

# Contains ActiveRecord::Persistence::ClassMethods to be patched
module ClassMethods
def create(attributes = nil, &block)
def create(attributes = nil, &)
tracer.in_span("#{self}.create") do
super
end
end

def create!(attributes = nil, &block)
def create!(attributes = nil, &)
tracer.in_span("#{self}.create!") do
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class << base

# Contains ActiveRecord::Transactions::ClassMethods to be patched
module ClassMethods
def transaction(**options, &block)
def transaction(**options, &)
tracer.in_span('ActiveRecord.transaction', attributes: { 'code.namespace' => name }) do
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
# NOTE: The test for service_update_metadata.active_storage is skipped because this event is only for GCS service.
# https://github.com/rails/rails/blob/fa9cf269191c5077de1abdd1e3f934fbeaf2a5d0/guides/source/active_support_instrumentation.md?plain=1#L928

def with_configuration(values, &block)
def with_configuration(values, &)
original_config = instrumentation.instance_variable_get(:@config)
modified_config = original_config.merge(values)
instrumentation.instance_variable_set(:@config, modified_config)
Expand All @@ -351,7 +351,7 @@ def with_configuration(values, &block)
instrumentation.instance_variable_set(:@config, original_config)
end

def with_subscription(&block)
def with_subscription(&)
OpenTelemetry::Instrumentation::ActiveStorage::Railtie.subscribe
yield
ensure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def preview(**options)

private

def draw_sample_image(file, &block)
draw 'echo', '"test previewer called"', &block
def draw_sample_image(file, &)
draw('echo', '"test previewer called"', &)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def call(context)

private

def span_wrapper(context, &block)
def span_wrapper(context, &)
service_id = HandlerHelper.service_id(context)
client_method = HandlerHelper.client_method(service_id, context)
context.tracer.in_span(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ module Bunny
# For additional details around trace messaging semantics
# See https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/messaging.md#messaging-attributes
module PatchHelpers
def self.with_send_span(channel, tracer, exchange, routing_key, &block)
def self.with_send_span(channel, tracer, exchange, routing_key, &)
attributes = basic_attributes(channel, channel.connection, exchange, routing_key)
destination = destination_name(exchange, routing_key)

tracer.in_span("#{destination} publish", attributes: attributes, kind: :producer, &block)
tracer.in_span("#{destination} publish", attributes: attributes, kind: :producer, &)
end

def self.with_process_span(channel, tracer, delivery_info, properties, &block)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Patches
# Concurrent::ThreadPoolExecutor patch for instrumentation
module ThreadPoolExecutor
# @see Concurrent::ExecutorService#post
def post(*args, **kwargs, &task)
def post(*args, **kwargs, &)
context = OpenTelemetry::Context.current
return super unless context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Plugins
# Delayed Job plugin that instruments invoke_job and other hooks
class TracerPlugin < Delayed::Plugin
class << self
def instrument_enqueue(job, &block)
def instrument_enqueue(job, &)
return yield(job) unless enabled?

attributes = build_attributes(job)
Expand All @@ -27,7 +27,7 @@ def instrument_enqueue(job, &block)
end
end

def instrument_invoke(job, &block)
def instrument_invoke(job, &)
return yield(job) unless enabled?

attributes = build_attributes(job)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,32 +302,32 @@ def initialize(events:, **_options)
super
end

def platform_execute_field(platform_key, &block)
def platform_execute_field(platform_key, &)
@events << platform_key
yield
end

def platform_execute_field_lazy(platform_key, &block)
def platform_execute_field_lazy(platform_key, &)
@events << platform_key
yield
end

def platform_authorized(platform_key, &block)
def platform_authorized(platform_key, &)
@events << platform_key
yield
end

def platform_authorized_lazy(platform_key, &block)
def platform_authorized_lazy(platform_key, &)
@events << platform_key
yield
end

def platform_resolve_type(platform_key, &block)
def platform_resolve_type(platform_key, &)
@events << platform_key
yield
end

def platform_resolve_type_lazy(platform_key, &block)
def platform_resolve_type_lazy(platform_key, &)
@events << platform_key
yield
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Client

private

def do_get_block(req, proxy, conn, &block)
def do_get_block(req, proxy, conn, &)
uri = req.header.request_uri
url = "#{uri.scheme}://#{uri.host}"
request_method = req.header.request_method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Koala
module Patches
# Module to prepend to Koala::Facebook::API for instrumentation
module Api
def graph_call(path, args = {}, verb = 'get', options = {}, &post_processing)
def graph_call(path, args = {}, verb = 'get', options = {}, &)
OpenTelemetry::Common::HTTP::ClientContext.with_attributes('peer.service' => 'facebook', 'koala.verb' => verb, 'koala.path' => path) do
super
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Instrumentation
# Constant for the HTTP status range
HTTP_STATUS_SUCCESS_RANGE = (100..399)

def request(req, body = nil, &block)
def request(req, body = nil, &)
# Do not trace recursive call for starting the connection
return super unless started?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Que
module Middlewares
# Server middleware to trace Que jobs
class ServerMiddleware
def self.call(job, &block)
def self.call(job, &)
job_class = job_class(job)
span_name = "#{job_class} process"
attributes = attributes_before_job_completion(job, job_class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def gem_version
end

if Gem.loaded_specs['que'].version >= Gem::Version.new('2.1.0')
def bulk_enqueue(**_kwargs, &block)
def bulk_enqueue(**_kwargs, &)
tracer = Que::Instrumentation.instance.tracer
otel_config = Que::Instrumentation.instance.config

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Request
# Constant for the HTTP status range
HTTP_STATUS_SUCCESS_RANGE = (100..399)

def execute(&block)
def execute(&)
trace_request do |_span|
super
end
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/rspec/test/rspec_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module RSpec
module Core
module DSL
def self.change_global_dsl(&blk)
def self.change_global_dsl(&)
nil
end
end
Expand Down

0 comments on commit 22fb6d6

Please sign in to comment.