Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with case..when without an else when AllowComments is true #13176

Closed
chaadow opened this issue Aug 31, 2024 · 3 comments
Closed

Issue with case..when without an else when AllowComments is true #13176

chaadow opened this issue Aug 31, 2024 · 3 comments
Labels

Comments

@chaadow
Copy link

chaadow commented Aug 31, 2024

Related to #13086


Expected behavior

I expect this piece of code to not trigger Rubocop errors.

      def ayo
        case variable
        when 1
          'hey'
        end
      end

Actual behavior

1 error occurred:
An error occurred while Style/EmptyElse cop was inspecting /Users/chedli/code/file..rb:24:8.
configuration from /Users/chedli/code/work/hoggo/.rubocop.yml
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.66.0 (using Parser 3.3.4.2, rubocop-ast 1.32.1, running on ruby 3.3.4) [arm64-darwin23]
Finished in 0.5535610000079032 seconds

**Here is the stacktrace: **

Stacktrace undefined method `join' for nil /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/style/empty_else.rb:183:in `comment_in_else?' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/style/empty_else.rb:146:in `check' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/style/empty_else.rb:140:in `on_case' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:107:in `public_send' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:105:in `each' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:69:in `on_case' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.1/lib/rubocop/ast/traversal.rb:154:in `on_def' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.0/lib/rubocop/cop/commissioner.rb:71:in `on_def' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.1/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.1/lib/rubocop/ast/traversal.rb:137:in `each' /Users/chedli/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.1/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
It seems that when a case..when does not have an else clause it trieggers this bug. here is a minimal rubocop.yml which triggers the error.

Style/EmptyElse:
  AllowComments: true

without AllowComments: true this piece of code works, so I guess it's related

RuboCop version

1.66.0 (using Parser 3.3.4.2, rubocop-ast 1.32.1, running on ruby 3.3.4) [arm64-darwin23]
Finished in 0.5535610000079032 seconds
@vlad-pisanov
Copy link
Contributor

vlad-pisanov commented Sep 1, 2024

We ran into this too 😞It also affects if and unless without an else. Fix: #13177

@koic koic closed this as completed Sep 1, 2024
@koic koic added the bug label Sep 1, 2024
@chaadow
Copy link
Author

chaadow commented Sep 1, 2024

@koic Since this broke 1.66 is it possible to release 1.66.1 please 🙏🏼

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 1, 2024

@chaadow I will likely cut a bugfix release in the next couple of days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants