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
New cop for ..
operator precedence
#4182
Labels
Comments
It can also be unexpected on the "other side" of the range: 1..2.to_a will attempt to send On that note, I think the cop should be a parenthesizing cop (possibly with an additional ambiguity cop.) I've seen some code like this in RuboCop: (foo.bar)..(baz.qux) and we don't have any cops for enforcing a style. I also don't think there is a Style Guide entry. 🙂 |
True. I've made this mistake like a million times. :-)
…On Sun, Apr 2, 2017 at 08:53 Ted Johansson ***@***.***> wrote:
It can also be unexpected on the "other side" of the range:
1..2.to_a
will attempt to send #to_a to 2, rather than the range.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4182 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGVypdJu6kYYnTQvP_UcpfGEeev0lfAks5rrzfcgaJpZM4MqOjD>
.
|
bbatsov
added
the
high priority
A ticket considered important by RuboCop's Core Team
label
Sep 12, 2018
@Drenmi is it actual issue? |
dvandersluis
added a commit
to dvandersluis/rubocop
that referenced
this issue
Aug 6, 2021
…with ambiguous boundaries.
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The following code has a bug.
The code is interpreted as
(x || 1)..2
, but it looks likex || (1..2)
to me.I think it is confusing, so, we need a cop for this problem. However we don't have the cop.
The cause is
..
operator's precedence. https://ruby-doc.org/core-2.2.0/doc/syntax/precedence_rdoc.htmlExpected behavior
RuboCop adds an offence for the above code.
Actual behavior
The cop for this problem does not exist.
RuboCop version
The text was updated successfully, but these errors were encountered: