You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have a class that has uses the new Ruby 3.0 endless method syntax for a class method, and it is not the last line of the class body, Layout/EmptyLineBetweenDefs gives an error.
There is no error if the endless class method is the last line of the body, or if the method is an instance method instead of a class method.
Expected behavior
The following syntax is supported:
class A
def self.b = 1
def c
2
end
end
Actual behavior
$ rubocop --debug
For /Users/josh/apps/surely/api: configuration from /Users/josh/apps/surely/api/.rubocop.yml
Default configuration from /Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/config/default.yml
Inspecting 22 files
Scanning /Users/josh/apps/surely/api/app/controllers/application_controller.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/88a889285b48b359988abc64aca9629d9b35a7d7
.Scanning /Users/josh/apps/surely/api/app/controllers/categories_controller.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/6a5c578b47fa453e1a6a44dec8a1792e50f84b45
.Scanning /Users/josh/apps/surely/api/app/controllers/todos_controller.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/9f918ce733bd3942baa4423115724371846a93dd
.Scanning /Users/josh/apps/surely/api/app/controllers/users_controller.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/d8c79c66e08e364638b102494c5949c0273e6da4
.Scanning /Users/josh/apps/surely/api/app/jobs/application_job.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/5bb3b39786ba9f46e281466d63f880bebc0614c4
.Scanning /Users/josh/apps/surely/api/app/mailers/application_mailer.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/77107480fc546be40fe6cf5d57b850388aa219be
.Scanning /Users/josh/apps/surely/api/app/models/application_record.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/ed1d1b360edadcb25affdad74e7518fb91646e90
.Scanning /Users/josh/apps/surely/api/app/models/category.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/f552664d6f9fa094dec32ce5050bbf3d15962932
.Scanning /Users/josh/apps/surely/api/app/models/todo.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/59220297ec02219d913e83acbe7162963b616872
.Scanning /Users/josh/apps/surely/api/app/models/user.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/5d58153bc7e97240e6584356214aea78f0fbe571
.Scanning /Users/josh/apps/surely/api/app/resources/application_resource.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/0a262cf3a334573dad6c3f38e20278e3ad9bc5a0
.Scanning /Users/josh/apps/surely/api/app/resources/category_resource.rb
An error occurred while Layout/EmptyLineBetweenDefs cop was inspecting /Users/josh/apps/surely/api/app/resources/category_resource.rb:3:2.
undefined method `line' for nil:NilClass
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:209:in `def_end'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:197:in `lines_between_defs'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:185:in `blank_lines_count_between'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:180:in `blank_lines_between?'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:110:in `check_defs'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:105:in `block in on_begin'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:103:in `each'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:103:in `each_cons'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/layout/empty_line_between_defs.rb:103:in `on_begin'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:100:in `public_send'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:166:in `with_cop_error_handling'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:98:in `each'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:98:in `trigger_responding_cops'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:69:in `on_begin'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:153:in `on_class'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.3.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/team.rb:157:in `investigate_partial'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cop/team.rb:83:in `investigate'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:315:in `inspect_file'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:259:in `block in do_inspection_loop'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:293:in `block in iterate_until_no_changes'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:286:in `loop'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:286:in `iterate_until_no_changes'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:255:in `do_inspection_loop'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:132:in `block in file_offenses'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:157:in `file_offense_cache'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:131:in `file_offenses'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:122:in `process_file'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:100:in `each'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:100:in `reduce'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:86:in `inspect_files'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/runner.rb:47:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/command.rb:11:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli/environment.rb:18:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli.rb:65:in `run_command'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli.rb:72:in `execute_runners'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/lib/rubocop/cli.rb:41:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/exe/rubocop:13:in `block in <top (required)>'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rubocop-1.7.0/exe/rubocop:12:in `<top (required)>'
/Users/josh/.rbenv/versions/3.0.0/bin/rubocop:23:in `load'
/Users/josh/.rbenv/versions/3.0.0/bin/rubocop:23:in `<top (required)>'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `load'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:63:in `kernel_load'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli/exec.rb:28:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:497:in `exec'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:30:in `dispatch'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/cli.rb:24:in `start'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/libexec/bundle:49:in `block in <top (required)>'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/3.0.0/bundler/friendly_errors.rb:130:in `with_friendly_errors'
/Users/josh/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/libexec/bundle:37:in `<top (required)>'
/Users/josh/.rbenv/versions/3.0.0/bin/bundle:23:in `load'
/Users/josh/.rbenv/versions/3.0.0/bin/bundle:23:in `<main>'
.Scanning /Users/josh/apps/surely/api/app/resources/todo_resource.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/ed2f5b955e2c2b650154a7ccf4e1bc54e86c580a
.Scanning /Users/josh/apps/surely/api/app/resources/user_resource.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/cc14cdc89d90244e6ba57d7b0715e9e1a662a4cf
.Scanning /Users/josh/apps/surely/api/db/seeds.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/2976a9f94cc11caf8c26b50a15a50c5966e7ee41
.Scanning /Users/josh/apps/surely/api/spec/factories/access_token.rb
For /Users/josh/apps/surely/api/spec/factories: configuration from /Users/josh/apps/surely/api/spec/factories/.rubocop.yml
Inheriting configuration from /Users/josh/apps/surely/api/.rubocop.yml
AllCops/Exclude configuration from /Users/josh/apps/surely/api/.rubocop.yml
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/df6ef9b14b416fd9df7599b1201e6cccd9617a84
.Scanning /Users/josh/apps/surely/api/spec/factories/category.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/87ebd19dbc7f5a533938c22835efc1b810568432
.Scanning /Users/josh/apps/surely/api/spec/factories/todo.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/92eadc43fd25e192813f1cd8d4b3f0404fce4cea
.Scanning /Users/josh/apps/surely/api/spec/factories/user.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/fd0a81d0333530e84463c77bbf0a69b73493b1aa
.Scanning /Users/josh/apps/surely/api/spec/requests/categories_spec.rb
For /Users/josh/apps/surely/api/spec/requests: configuration from /Users/josh/apps/surely/api/spec/.rubocop.yml
Inheriting configuration from /Users/josh/apps/surely/api/.rubocop.yml
AllCops/Exclude configuration from /Users/josh/apps/surely/api/.rubocop.yml
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/1252392a0403dab2e6adfebf857a394b8baf417e
.Scanning /Users/josh/apps/surely/api/spec/requests/todos_spec.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/30b447978a2fc59177bdb0cc6da22500e4d3f6a1
.Scanning /Users/josh/apps/surely/api/spec/support/with_a_logged_in_user.rb
Loading cache from /Users/josh/.cache/rubocop_cache/86c3ddec686aab78ca4ee980c21d1c8cee941777/6d7a3b621ca1730e04accd938619e4bdab66cfb1/9bd90469f2db0ac22f40c003dd40808c306add6c
.
22 files inspected, no offenses detected
1 error occurred:
An error occurred while Layout/EmptyLineBetweenDefs cop was inspecting /Users/josh/apps/surely/api/app/resources/category_resource.rb:3:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues
Mention the following information in the issue report:
1.7.0 (using Parser 3.0.0.0, rubocop-ast 1.3.0, running on ruby 3.0.0 x86_64-darwin20)
Finished in 0.5081510000163689 seconds
Rubocop Issue
When I have a class that has uses the new Ruby 3.0 endless method syntax for a class method, and it is not the last line of the class body, Layout/EmptyLineBetweenDefs gives an error.
There is no error if the endless class method is the last line of the body, or if the method is an instance method instead of a class method.
Expected behavior
The following syntax is supported:
Actual behavior
Steps to reproduce the problem
Run Rubocop on the following class:
Here is a minimal repro repo: https://github.com/CodingItWrong/endless-class-method
RuboCop version
The text was updated successfully, but these errors were encountered: