Skip to content

Commit 48a9448

Browse files
authored
Merge pull request #560 from koic/fix_error_for_rails_relative_date_constant
[Fix #559] Fix an error for `Rails/RelativeDateConstant`
2 parents 32ae8f0 + 0e2a2f4 commit 48a9448

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#559](https://github.com/rubocop/rubocop-rails/issues/559): Fix an error for `Rails/RelativeDateConstant` when using multiple assignment. ([@koic][])

lib/rubocop/cop/rails/relative_date_constant.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def offense_range(name, value)
9090
end
9191

9292
def nested_relative_date(node, &callback)
93-
return if node.block_type?
93+
return if node.nil? || node.block_type?
9494

9595
node.each_child_node do |child|
9696
nested_relative_date(child, &callback)

spec/rubocop/cop/rails/relative_date_constant_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,14 @@ class SomeClass
172172
RUBY
173173
end
174174
end
175+
176+
context 'when using multiple assignment' do
177+
it 'does not register an offense' do
178+
expect_no_offenses(<<~RUBY)
179+
class SomeClass
180+
FOO, BAR = *do_something
181+
end
182+
RUBY
183+
end
184+
end
175185
end

0 commit comments

Comments
 (0)