diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2d540c9..9ee7f5e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,37 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 180` -# on 2023-04-20 23:33:11 UTC using RuboCop version 1.50.2. +# on 2023-05-18 23:33:13 UTC using RuboCop version 1.51.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 53 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'lib/dispatch-rider/callbacks/storage.rb' - - 'lib/dispatch-rider/demultiplexer.rb' - - 'lib/dispatch-rider/integrations/appsignal.rb' - - 'spec/lib/dispatch-rider/airbrake_error_handler_spec.rb' - - 'spec/lib/dispatch-rider/configuration_spec.rb' - - 'spec/lib/dispatch-rider/default_error_handler_spec.rb' - - 'spec/lib/dispatch-rider/demultiplexer_spec.rb' - - 'spec/lib/dispatch-rider/dispatcher_spec.rb' - - 'spec/lib/dispatch-rider/publisher/base_spec.rb' - - 'spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb' - - 'spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb' - - 'spec/lib/dispatch-rider/publisher/configuration_spec.rb' - - 'spec/lib/dispatch-rider/publisher/configuration_support_spec.rb' - - 'spec/lib/dispatch-rider/publisher_spec.rb' - - 'spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb' - - 'spec/lib/dispatch-rider/queue_services/received_message_spec.rb' - - 'spec/lib/dispatch-rider/runner_spec.rb' - - 'spec/lib/dispatch-rider/subscriber_spec.rb' - - 'spec/lib/dispatch-rider_spec.rb' - # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. diff --git a/lib/dispatch-rider/callbacks/storage.rb b/lib/dispatch-rider/callbacks/storage.rb index 24be2e6..00bd072 100644 --- a/lib/dispatch-rider/callbacks/storage.rb +++ b/lib/dispatch-rider/callbacks/storage.rb @@ -23,11 +23,9 @@ def before(event, block_param = nil, &block) # @param [Proc] &block def after(event, block_param = nil, &block) around(event) do |job, *args| - job.call ensure (block_param || block).call(*args) - end end diff --git a/lib/dispatch-rider/demultiplexer.rb b/lib/dispatch-rider/demultiplexer.rb index e412ae4..1564b34 100644 --- a/lib/dispatch-rider/demultiplexer.rb +++ b/lib/dispatch-rider/demultiplexer.rb @@ -19,13 +19,11 @@ def initialize(queue, dispatcher, error_handler) def start do_loop do - sleep 1 handle_next_queue_item rescue => exception error_handler.call(Message.new(subject: "TopLevelError", body: {}), exception) throw :done - end self end diff --git a/lib/dispatch-rider/integrations/appsignal.rb b/lib/dispatch-rider/integrations/appsignal.rb index f7a03a8..fc418ee 100644 --- a/lib/dispatch-rider/integrations/appsignal.rb +++ b/lib/dispatch-rider/integrations/appsignal.rb @@ -27,11 +27,9 @@ def self.wrap_message(job, message) end DispatchRider.configure do |config| - config.around(:dispatch_message) do |job, message| DispatchRider::Integrations::Appsignal.wrap_message(job, message) end - end end diff --git a/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb b/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb index 59e2f17..b4f408f 100644 --- a/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb +++ b/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb @@ -3,7 +3,6 @@ require "spec_helper" describe DispatchRider::AirbrakeErrorHandler do - describe ".call" do let(:message) { DispatchRider::Message.new(subject: "TestMessage", body: "foo") } let(:exception) { Exception.new("Something went terribly wrong") } @@ -21,5 +20,4 @@ described_class.call(message, exception) end end - end diff --git a/spec/lib/dispatch-rider/configuration_spec.rb b/spec/lib/dispatch-rider/configuration_spec.rb index f8f6738..d490afa 100644 --- a/spec/lib/dispatch-rider/configuration_spec.rb +++ b/spec/lib/dispatch-rider/configuration_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Configuration do - subject { described_class.new } describe "defaults" do @@ -54,7 +53,6 @@ end describe "#logger" do - describe "default" do example { expect(subject.logger).to be_a(Logger) } end @@ -72,5 +70,4 @@ expect(subject.logger).to eq new_logger end end - end diff --git a/spec/lib/dispatch-rider/default_error_handler_spec.rb b/spec/lib/dispatch-rider/default_error_handler_spec.rb index 6374418..1ce08f1 100644 --- a/spec/lib/dispatch-rider/default_error_handler_spec.rb +++ b/spec/lib/dispatch-rider/default_error_handler_spec.rb @@ -3,7 +3,6 @@ require "spec_helper" describe DispatchRider::DefaultErrorHandler do - describe ".call" do let(:exception) { Exception.new("Something went terribly wrong") } @@ -13,5 +12,4 @@ }.to raise_exception exception end end - end diff --git a/spec/lib/dispatch-rider/demultiplexer_spec.rb b/spec/lib/dispatch-rider/demultiplexer_spec.rb index 52ace96..2d7a319 100644 --- a/spec/lib/dispatch-rider/demultiplexer_spec.rb +++ b/spec/lib/dispatch-rider/demultiplexer_spec.rb @@ -51,7 +51,6 @@ def process(options) end context "when the queue is not empty" do - before do queue.push message end @@ -115,5 +114,4 @@ def process(options) expect(demultiplexer_thread).not_to be_alive # looper should close the loop end end - end diff --git a/spec/lib/dispatch-rider/dispatcher_spec.rb b/spec/lib/dispatch-rider/dispatcher_spec.rb index d0e2c23..38145eb 100644 --- a/spec/lib/dispatch-rider/dispatcher_spec.rb +++ b/spec/lib/dispatch-rider/dispatcher_spec.rb @@ -32,13 +32,11 @@ def process(_params) before do allow(DispatchRider.config).to receive(:callbacks) { storage } storage.around(:dispatch_message) do |block, message| - dummy.before dummy.log(message) block.call ensure dummy.after - end subject.register('handle_something') end diff --git a/spec/lib/dispatch-rider/publisher/base_spec.rb b/spec/lib/dispatch-rider/publisher/base_spec.rb index 56e458d..08f4d41 100644 --- a/spec/lib/dispatch-rider/publisher/base_spec.rb +++ b/spec/lib/dispatch-rider/publisher/base_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Publisher::Base do - class DummyPublisher < DispatchRider::Publisher::Base destinations %i[sns_message_queue file_system_queue] subject "Loud Cheering" @@ -77,5 +76,4 @@ def self.publish(body, publisher) end end end - end diff --git a/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb b/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb index b3293be..cc3bdf1 100644 --- a/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb +++ b/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Publisher::Configuration::NotificationService do - subject { described_class.new("file_system", options) } let(:options) do @@ -59,5 +58,4 @@ it { is_expected.not_to eq other } end end - end diff --git a/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb b/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb index bc72b1d..89afc4a 100644 --- a/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb +++ b/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb @@ -3,13 +3,11 @@ require 'spec_helper' describe DispatchRider::Publisher::ConfigurationReader do - let :publisher do double(:publisher) end describe ".load_config" do - subject { described_class } it "responds to :load_config" do @@ -29,11 +27,9 @@ end describe "notification_services parsing" do - let(:configuration) { DispatchRider::Publisher::Configuration.new(configuration_hash) } context "when notification_services has no items in it" do - let :configuration_hash do { notification_services: {} @@ -86,15 +82,12 @@ subject.load_config(configuration, publisher) end end - end describe "destinations" do - let(:configuration) { DispatchRider::Publisher::Configuration.new(configuration_hash) } context "when destinations has no items in it" do - let :configuration_hash do { destinations: {} @@ -105,11 +98,9 @@ expect(publisher).not_to receive(:register_destination) subject.load_config(configuration, publisher) end - end context "when destinations has items in it" do - let :configuration_hash do { destinations: { @@ -129,11 +120,7 @@ expect(publisher).to receive(:register_destination).once.with(*params) subject.load_config(configuration, publisher) end - end - end - end # .load_config - end diff --git a/spec/lib/dispatch-rider/publisher/configuration_spec.rb b/spec/lib/dispatch-rider/publisher/configuration_spec.rb index 6727a97..7fb1161 100644 --- a/spec/lib/dispatch-rider/publisher/configuration_spec.rb +++ b/spec/lib/dispatch-rider/publisher/configuration_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Publisher::Configuration do - subject { described_class.new(configuration_hash) } let(:configuration_hash) do @@ -147,5 +146,4 @@ expect(subject.destinations).to match_array([destination]) end end - end diff --git a/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb b/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb index 0b23883..3d9681b 100644 --- a/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb +++ b/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Publisher::ConfigurationSupport do - subject { Object.new.extend(described_class) } describe ".configuration" do @@ -87,5 +86,4 @@ end end end - end diff --git a/spec/lib/dispatch-rider/publisher_spec.rb b/spec/lib/dispatch-rider/publisher_spec.rb index cbaf968..59c9fcf 100644 --- a/spec/lib/dispatch-rider/publisher_spec.rb +++ b/spec/lib/dispatch-rider/publisher_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Publisher do - subject(:publisher) { described_class.new } describe "#initialize" do @@ -109,12 +108,10 @@ end around do |ex| - DispatchRider.config.debug = true ex.call ensure DispatchRider.config.debug = false - end it "publishes the message to the notification service" do diff --git a/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb b/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb index 297000e..71ebfeb 100644 --- a/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb +++ b/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::QueueServices::AwsSqs do - subject(:aws_sqs_queue) do described_class.new(:name => "normal_priority") end @@ -22,9 +21,7 @@ end describe "#assign_storage" do - context "when the aws gem is installed" do - context "when the name of the queue is passed in the options" do it "should return an instance representing the aws sqs queue" do aws_sqs_queue.assign_storage(:name => 'normal_priority') @@ -101,7 +98,6 @@ }.to raise_exception(/message: foo,.+ took .+ seconds while the timeout was 1/) end end - end context "when the sqs queue is empty" do @@ -115,7 +111,6 @@ }.not_to yield_control end end - end describe "received message methods" do diff --git a/spec/lib/dispatch-rider/queue_services/received_message_spec.rb b/spec/lib/dispatch-rider/queue_services/received_message_spec.rb index 59d513e..d7e2575 100644 --- a/spec/lib/dispatch-rider/queue_services/received_message_spec.rb +++ b/spec/lib/dispatch-rider/queue_services/received_message_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::QueueServices::ReceivedMessage do - subject { described_class.new("test_message", double(:item)) } describe "#extend_timeout" do @@ -21,5 +20,4 @@ }.to raise_error NotImplementedError end end - end diff --git a/spec/lib/dispatch-rider/runner_spec.rb b/spec/lib/dispatch-rider/runner_spec.rb index 1a45a6a..4e537b6 100644 --- a/spec/lib/dispatch-rider/runner_spec.rb +++ b/spec/lib/dispatch-rider/runner_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider::Runner do - describe ".run" do let(:subscriber) { double(:subscriber) } @@ -27,5 +26,4 @@ described_class.run end end - end diff --git a/spec/lib/dispatch-rider/subscriber_spec.rb b/spec/lib/dispatch-rider/subscriber_spec.rb index 6d96993..2e713ae 100644 --- a/spec/lib/dispatch-rider/subscriber_spec.rb +++ b/spec/lib/dispatch-rider/subscriber_spec.rb @@ -167,5 +167,4 @@ def process(_options) end end end - end diff --git a/spec/lib/dispatch-rider_spec.rb b/spec/lib/dispatch-rider_spec.rb index 322ffda..d53c6a7 100644 --- a/spec/lib/dispatch-rider_spec.rb +++ b/spec/lib/dispatch-rider_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe DispatchRider do - describe ".configuration" do example do expect(described_class.configuration).to be_a(DispatchRider::Configuration) @@ -25,5 +24,4 @@ expect(described_class.config.queue_kind).to eq(:test_queue) end end - end