-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Rubocop converting single-line methods to Endless methods on unsupported Rubies #9466
Comments
Sounds like we need to add a check for the Ruby version before handling anything with endless methods. A quick look into the code, As a quick workaround, it looks like you can either disable |
Thanks for digging in @rrosenblum |
Thanks @searls I overlooked this will fix shortly. |
…ess methods if the target ruby is < 3.0.
[Fix #9466] Don't correct `Style/SingleLineMethods` using endless methods if the target ruby is < 3.0
Holy cow, @dvandersluis -- what incredible turnaround time. Thank you!! ✨ |
Happy to, thanks for the bug report! |
Noticed this while updating Standard to support 1.8.1, but verified in this repro repo that it persists in 1.9.0 as well
Expected behavior
When running on Rubies older than 3.0, I'd expect Rubocop's defaults to not change code into endless methods, as they won't be valid Ruby.
Given:
I'd expect it to correct to:
Actual behavior
In fact, it looks like Rubocop is doing a first-pass and converting it to an endless method, then blowing up because it's not parseable. Full output follows:
Steps to reproduce the problem
Here's a repro repo: https://github.com/searls/rubocop-endless-method-repro#rubocop-and-endless-methods
RuboCop version
Tested under Ruby 2.4 and 2.7 FWIW
The text was updated successfully, but these errors were encountered: