Skip to content

Commit 5c4edc4

Browse files
committed
Corrected some RuboCop glitches.
Signed-off-by: Hermann Mayer <[email protected]>
1 parent 727107a commit 5c4edc4

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
require:
22
- rubocop-rspec
3+
4+
plugins:
35
- rubocop-rails
46

57
Rails:

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### next
22

3-
* TODO: Replace this bullet point with an actual description of a change.
3+
* Corrected some RuboCop glitches (#17)
44

55
### 1.6.0 (30 January 2025)
66

lib/alarmable.rb

+5-9
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module Alarmable
7171
attr_accessor :alarm_job, :alarm_base_date_property
7272
end
7373

74-
# rubocop:disable Metrics/BlockLength because Active Support like it
74+
# rubocop:disable Metrics/BlockLength -- because Active Support like it
7575
included do
7676
# Hooks
7777
after_initialize :validate_alarm_settings, :alarm_defaults
@@ -89,16 +89,12 @@ module Alarmable
8989
# Getter for the alarm job class.
9090
#
9191
# @return [Class] The alarm job class
92-
def alarm_job
93-
self.class.alarm_job
94-
end
92+
delegate :alarm_job, to: :class
9593

9694
# Getter for the alarm base date property.
9795
#
9896
# @return [Symbol] The user defined base date property
99-
def alarm_base_date_property
100-
self.class.alarm_base_date_property
101-
end
97+
delegate :alarm_base_date_property, to: :class
10298

10399
# Set some defaults on the relevant alarm properties.
104100
def alarm_defaults
@@ -110,7 +106,7 @@ def alarm_defaults
110106
# of the specified class. Also validate the +alarm_base_date_property+
111107
# setting.
112108
#
113-
# rubocop:disable Style/GuardClause because its fine like this
109+
# rubocop:disable Style/GuardClause -- because its fine like this
114110
# :reek:NilCheck because we validate concern usage
115111
def validate_alarm_settings
116112
raise 'Alarmable +alarm_job+ is not configured' if alarm_job.nil?
@@ -151,7 +147,7 @@ def alarm_id(channel, before_minutes)
151147
# @return [Object] The new alarm_jobs instance (partial)
152148
# Example: { "alarm id": "job id" }
153149
#
154-
# rubocop:disable Metrics/AbcSize because its already broken down
150+
# rubocop:disable Metrics/AbcSize -- because its already broken down
155151
# :reek:TooManyStatements because see above
156152
# :reek:NilCheck because we dont want to cancel 'nil' job id
157153
# :reek:DuplicateMethodCall because hash access is fast

spec/alarmable_spec.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def drop_tables(*tables)
5656
end
5757
end
5858

59-
# rubocop:disable RSpec/BeforeAfterAll because we are aware
59+
# rubocop:disable RSpec/BeforeAfterAll -- because we are aware
6060
before(:all) { create_tables(*tables) }
6161

6262
before { enqueued_jobs.clear }
@@ -222,7 +222,7 @@ def drop_tables(*tables)
222222
alarmable.reschedule_alarm_jobs
223223
end
224224

225-
# rubocop:disable RSpec/ExampleLength because we need 6 lines here :(
225+
# rubocop:disable RSpec/ExampleLength -- because we need 6 lines here :(
226226
it 'cancels none updated jobs' do
227227
allow(alarmable).to receive(:reschedule_alarm_job)
228228
.and_return({ alarm_id => 'something-new' })
@@ -282,8 +282,8 @@ def drop_tables(*tables)
282282
raise_error(RuntimeError, /alarm_job/)
283283
end
284284

285-
# rubocop:disable RSpec/RepeatedExample because it looks like the same
286-
# but the background is different
285+
# rubocop:disable RSpec/RepeatedExample -- because it looks like the
286+
# same but the background is different
287287
it 'raise not when set' do
288288
expect { TestAlarmable.new }.not_to raise_error
289289
end
@@ -294,8 +294,8 @@ def drop_tables(*tables)
294294
raise_error(RuntimeError, /alarm_job/)
295295
end
296296

297-
# rubocop:disable RSpec/RepeatedExample because it looks like the same
298-
# but the background is different
297+
# rubocop:disable RSpec/RepeatedExample -- because it looks like the
298+
# same but the background is different
299299
it 'raise not when a class' do
300300
expect { TestAlarmable.new }.not_to raise_error
301301
end
@@ -308,8 +308,8 @@ def drop_tables(*tables)
308308
raise_error(RuntimeError, /alarm_base_date_property/)
309309
end
310310

311-
# rubocop:disable RSpec/RepeatedExample because it looks like the same
312-
# but the background is different
311+
# rubocop:disable RSpec/RepeatedExample -- because it looks like the
312+
# same but the background is different
313313
it 'raise not when set' do
314314
expect { TestAlarmable.new }.not_to raise_error
315315
end
@@ -320,8 +320,8 @@ def drop_tables(*tables)
320320
raise_error(RuntimeError, /alarm_base_date_property/)
321321
end
322322

323-
# rubocop:disable RSpec/RepeatedExample because it looks like the same
324-
# but the background is different
323+
# rubocop:disable RSpec/RepeatedExample -- because it looks like the
324+
# same but the background is different
325325
it 'raise not when an useable property' do
326326
expect { TestAlarmable.new }.not_to raise_error
327327
end

0 commit comments

Comments
 (0)