-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
When using the Layout/EmptyLineBetweenDefs cop with the DefLikeMacros option, errors are not reported nor autocorrected when two macros do not have an empty line between them.
Rubocop config:
# .rubobop.yml
plugins:
- rubocop-factory_bot
- rubocop-performance
- rubocop-rails
- rubocop-rake
- rubocop-rspec
- rubocop-rspec_rails
AllCops:
NewCops: enable
TargetRubyVersion: 3.4.5
Layout/EmptyLineBetweenDefs:
Enabled: true
DefLikeMacros: [monetize]
Expected behavior
class TestClass
monetize :price
monetize :other_price
endHere is a test that seems to validate the expected behavior:
| context 'DefLikeMacros: [\'foo\']' do |
Actual behavior
class TestClass
monetize :price
monetize :other_price
endOutput of rubocop --debug:
For /app: configuration from /app/.rubocop.yml
Default configuration from /usr/local/bundle/gems/rubocop-1.80.1/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-factory_bot-2.27.1/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-performance-1.25.0/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-rails-2.33.3/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-rake-0.7.1/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-rspec-3.6.0/config/default.yml
Plugin configuration from /usr/local/bundle/gems/rubocop-rspec_rails-2.31.0/config/default.yml
Use parallel by default.
Running parallel inspection
Inspecting 4 files
Scanning /app/Gemfile
Loading cache from /root/.cache/rubocop_cache/9969a80ad293c4977dce6159aac2711461d93ca0/6d7a3b621ca1730e04accd938619e4bdab66cfb1/22a189253b26d6cde2ba5218571f8c485dc346e1
.Scanning /app/Rakefile
Loading cache from /root/.cache/rubocop_cache/9969a80ad293c4977dce6159aac2711461d93ca0/6d7a3b621ca1730e04accd938619e4bdab66cfb1/e33e15c9f3e5cfcc10f948c2fcce738379c2d3f0
.Scanning /app/lib/test_class.rb
Loading cache from /root/.cache/rubocop_cache/9969a80ad293c4977dce6159aac2711461d93ca0/6d7a3b621ca1730e04accd938619e4bdab66cfb1/8e4664d0607939b6428978aa32139a15aa6771ba
.Scanning /app/spec/spec_helper.rb
Loading cache from /root/.cache/rubocop_cache/9969a80ad293c4977dce6159aac2711461d93ca0/6d7a3b621ca1730e04accd938619e4bdab66cfb1/be18d96b9179563484e23ff379bc484bb355fecd
Steps to reproduce the problem
Add the following to the rubocop config:
Layout/EmptyLineBetweenDefs:
Enabled: true
DefLikeMacros: [monetize]
Then add two monetize calls to a class without an empty line between them and run rubocop. For example:
class TestClass
monetize :price
monetize :other_price
endRuboCop version
bundle exec rubocop -V
1.80.1 (using Parser 3.3.9.0, Prism 1.4.0, rubocop-ast 1.46.0, analyzing as Ruby 3.4, running on ruby 3.4.5) [aarch64-linux]
- rubocop-factory_bot 2.27.1
- rubocop-performance 1.25.0
- rubocop-rails 2.33.3
- rubocop-rake 0.7.1
- rubocop-rspec 3.6.0
- rubocop-rspec_rails 2.31.0