lib/three_scale/sidekiq_retry_support.rb
ThreeScale::SidekiqRetrySupport::Middleware#call manually dispatches method call Open
Open
worker.retry_attempt = (msg['retry_count'] || -1) + 1 if worker.respond_to?(:retry_attempt)
- Read upRead up
- Exclude checks
Reek reports a Manual Dispatch smell if it finds source code that manually checks whether an object responds to a method before that method is called. Manual dispatch is a type of Simulated Polymorphism which leads to code that is harder to reason about, debug, and refactor.
Example
class MyManualDispatcher
attr_reader :foo
def initialize(foo)
@foo = foo
end
def call
foo.bar if foo.respond_to?(:bar)
end
end
Reek would emit the following warning:
test.rb -- 1 warning:
[9]: MyManualDispatcher manually dispatches method call (ManualDispatch)
ThreeScale::SidekiqRetrySupport::Worker#retry_attempt is a writable attribute Open
Open
attr_writer :retry_attempt
- Read upRead up
- Exclude checks
A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.
The same holds to a lesser extent for getters, but Reek doesn't flag those.
Example
Given:
class Klass
attr_accessor :dummy
end
Reek would emit the following warning:
reek test.rb
test.rb -- 1 warning:
[2]:Klass declares the writable attribute dummy (Attribute)
ThreeScale::SidekiqRetrySupport::Middleware#call doesn't depend on instance state (maybe move it to another class?) Open
Open
def call(worker, msg, *)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.